diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ddc44777bc..11958b2e51 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -76,4 +76,4 @@ jobs: run: go mod tidy - name: Ensure clean git state. - run: git diff-index --quiet HEAD -- || (echo "Please run go mod tidy." && exit 1) + run: git diff-index --quiet HEAD -- || (echo "Please run 'go mod tidy' and commit changes." && exit 1) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdfa307d0a..912f05af9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ This format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Support for 'namespacing' / multi-environments. All types can now belong to a namespace allowing you to seperate your flags/segments/etc. + +### Changed + +- All existing objects have been moved to the 'default' namespace to be fully backward compatible. +- Import/Export have been updated to be 'namespace-aware' +- Dependency updates + ## [v1.19.3](https://github.com/flipt-io/flipt/releases/tag/v1.19.3) - 2023-03-22 ### Changed diff --git a/cmd/flipt/export.go b/cmd/flipt/export.go index 60ad6b56f2..8e38a5670c 100644 --- a/cmd/flipt/export.go +++ b/cmd/flipt/export.go @@ -5,73 +5,100 @@ import ( "fmt" "io" "os" - "os/signal" - "syscall" "time" + "github.com/spf13/cobra" "go.flipt.io/flipt/internal/ext" - "go.flipt.io/flipt/internal/storage" - "go.flipt.io/flipt/internal/storage/sql" - "go.flipt.io/flipt/internal/storage/sql/mysql" - "go.flipt.io/flipt/internal/storage/sql/postgres" - "go.flipt.io/flipt/internal/storage/sql/sqlite" "go.uber.org/zap" ) -var exportFilename string - -func runExport(ctx context.Context, logger *zap.Logger) error { - ctx, cancel := context.WithCancel(ctx) - - defer cancel() - - interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) +type exportCommand struct { + filename string + address string + token string + namespace string +} - go func() { - <-interrupt - cancel() - }() +func newExportCommand() *cobra.Command { + export := &exportCommand{} - db, driver, err := sql.Open(*cfg) - if err != nil { - return fmt.Errorf("opening db: %w", err) + cmd := &cobra.Command{ + Use: "export", + Short: "Export flags/segments/rules to file/stdout", + RunE: export.run, } - defer db.Close() - - var store storage.Store - - switch driver { - case sql.SQLite: - store = sqlite.NewStore(db, logger) - case sql.Postgres, sql.CockroachDB: - store = postgres.NewStore(db, logger) - case sql.MySQL: - store = mysql.NewStore(db, logger) - } + cmd.Flags().StringVarP( + &export.filename, + "output", "o", + "", + "export to filename (default STDOUT)", + ) + + cmd.Flags().StringVarP( + &export.address, + "address", "a", + "", + "address of remote Flipt instance to export from (defaults to direct DB export if not supplied)", + ) + + cmd.Flags().StringVarP( + &export.token, + "token", "t", + "", + "client token used to authenticate access to remote Flipt instance when exporting.", + ) + + cmd.Flags().StringVarP( + &export.namespace, + "namespace", "n", + "default", + "source namespace for exported resources.", + ) + + return cmd +} - // default to stdout - var out io.WriteCloser = os.Stdout +func (c *exportCommand) run(cmd *cobra.Command, _ []string) error { + var ( + // default to stdout + out io.Writer = os.Stdout + logger = zap.Must(zap.NewDevelopment()) + ) // export to file - if exportFilename != "" { - logger.Debug("exporting", zap.String("destination_path", exportFilename)) + if c.filename != "" { + logger.Debug("exporting", zap.String("destination_path", c.filename)) - out, err = os.Create(exportFilename) + fi, err := os.Create(c.filename) if err != nil { return fmt.Errorf("creating output file: %w", err) } - fmt.Fprintf(out, "# exported by Flipt (%s) on %s\n\n", version, time.Now().UTC().Format(time.RFC3339)) + defer fi.Close() + + fmt.Fprintf(fi, "# exported by Flipt (%s) on %s\n\n", version, time.Now().UTC().Format(time.RFC3339)) + + out = fi } - defer out.Close() + // Use client when remote address is configured. + if c.address != "" { + return c.export(cmd.Context(), out, fliptClient(logger, c.address, c.token)) + } - exporter := ext.NewExporter(store) - if err := exporter.Export(ctx, out); err != nil { - return fmt.Errorf("exporting: %w", err) + // Otherwise, go direct to the DB using Flipt configuration file. + logger, cfg := buildConfig() + server, cleanup, err := fliptServer(logger, cfg) + if err != nil { + return err } - return nil + defer cleanup() + + return c.export(cmd.Context(), out, server) +} + +func (c *exportCommand) export(ctx context.Context, dst io.Writer, lister ext.Lister) error { + return ext.NewExporter(lister, c.namespace).Export(ctx, dst) } diff --git a/cmd/flipt/import.go b/cmd/flipt/import.go index 7569c1c133..bab3ea511a 100644 --- a/cmd/flipt/import.go +++ b/cmd/flipt/import.go @@ -1,63 +1,88 @@ package main import ( - "context" "errors" "fmt" "io" "os" - "os/signal" "path/filepath" - "syscall" + "github.com/spf13/cobra" "go.flipt.io/flipt/internal/ext" - "go.flipt.io/flipt/internal/storage" "go.flipt.io/flipt/internal/storage/sql" - "go.flipt.io/flipt/internal/storage/sql/mysql" - "go.flipt.io/flipt/internal/storage/sql/postgres" - "go.flipt.io/flipt/internal/storage/sql/sqlite" "go.uber.org/zap" ) -var ( +type importCommand struct { dropBeforeImport bool importStdin bool -) - -func runImport(ctx context.Context, logger *zap.Logger, args []string) error { - ctx, cancel := context.WithCancel(ctx) - - defer cancel() - - interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) + address string + token string + namespace string + createNamespace bool +} - go func() { - <-interrupt - cancel() - }() +func newImportCommand() *cobra.Command { + importCmd := &importCommand{} - db, driver, err := sql.Open(*cfg) - if err != nil { - return fmt.Errorf("opening db: %w", err) + cmd := &cobra.Command{ + Use: "import", + Short: "Import flags/segments/rules from file", + RunE: importCmd.run, } - defer db.Close() - - var store storage.Store - - switch driver { - case sql.SQLite: - store = sqlite.NewStore(db, logger) - case sql.Postgres, sql.CockroachDB: - store = postgres.NewStore(db, logger) - case sql.MySQL: - store = mysql.NewStore(db, logger) - } + cmd.Flags().BoolVar( + &importCmd.dropBeforeImport, + "drop", + false, + "drop database before import", + ) + + cmd.Flags().BoolVar( + &importCmd.importStdin, + "stdin", + false, + "import from STDIN", + ) + + cmd.Flags().StringVarP( + &importCmd.address, + "address", "a", + "", + "address of remote Flipt instance to import into (defaults to direct DB import if not supplied)", + ) + + cmd.Flags().StringVarP( + &importCmd.token, + "token", "t", + "", + "client token used to authenticate access to remote Flipt instance when importing.", + ) + + cmd.Flags().StringVarP( + &importCmd.namespace, + "namespace", "n", + "default", + "destination namespace for imported resources.", + ) + + cmd.Flags().BoolVar( + &importCmd.createNamespace, + "create-namespace", + false, + "create the namespace if it does not exist.", + ) + + return cmd +} - var in io.ReadCloser = os.Stdin +func (c *importCommand) run(cmd *cobra.Command, args []string) error { + var ( + in io.Reader = os.Stdin + logger = zap.Must(zap.NewDevelopment()) + ) - if !importStdin { + if !c.importStdin { importFilename := args[0] if importFilename == "" { return errors.New("import filename required") @@ -67,13 +92,26 @@ func runImport(ctx context.Context, logger *zap.Logger, args []string) error { logger.Debug("importing", zap.String("source_path", f)) - in, err = os.Open(f) + fi, err := os.Open(f) if err != nil { return fmt.Errorf("opening import file: %w", err) } + + defer fi.Close() + + in = fi + } + + // Use client when remote address is configured. + if c.address != "" { + return ext.NewImporter( + fliptClient(logger, c.address, c.token), + c.namespace, + c.createNamespace, + ).Import(cmd.Context(), in) } - defer in.Close() + logger, cfg := buildConfig() migrator, err := sql.NewMigrator(*cfg, logger) if err != nil { @@ -83,11 +121,11 @@ func runImport(ctx context.Context, logger *zap.Logger, args []string) error { defer migrator.Close() // drop tables if specified - if dropBeforeImport { - logger.Debug("dropping tables before import") + if c.dropBeforeImport { + logger.Debug("dropping tables") - if err := migrator.Down(); err != nil { - return fmt.Errorf("attempting to drop during import: %w", err) + if err := migrator.Drop(); err != nil { + return fmt.Errorf("attempting to drop: %w", err) } } @@ -99,10 +137,17 @@ func runImport(ctx context.Context, logger *zap.Logger, args []string) error { return fmt.Errorf("closing migrator: %w", err) } - importer := ext.NewImporter(store) - if err := importer.Import(ctx, in); err != nil { - return fmt.Errorf("importing: %w", err) + // Otherwise, go direct to the DB using Flipt configuration file. + server, cleanup, err := fliptServer(logger, cfg) + if err != nil { + return err } - return nil + defer cleanup() + + return ext.NewImporter( + server, + c.namespace, + c.createNamespace, + ).Import(cmd.Context(), in) } diff --git a/cmd/flipt/main.go b/cmd/flipt/main.go index e1db373d80..05e6781ff7 100644 --- a/cmd/flipt/main.go +++ b/cmd/flipt/main.go @@ -10,7 +10,6 @@ import ( "os/signal" "path/filepath" "runtime" - "sync" "syscall" "text/template" "time" @@ -34,9 +33,6 @@ import ( ) var ( - cfg *config.Config - cfgWarnings []string - cfgPath string forceMigrate bool version = "dev" @@ -47,50 +43,22 @@ var ( banner string ) -func main() { - var ( - once sync.Once - loggerConfig = zap.Config{ - Level: zap.NewAtomicLevelAt(zap.InfoLevel), - Development: false, - Encoding: "console", - EncoderConfig: zapcore.EncoderConfig{ - // Keys can be anything except the empty string. - TimeKey: "T", - LevelKey: "L", - NameKey: "N", - CallerKey: zapcore.OmitKey, - FunctionKey: zapcore.OmitKey, - MessageKey: "M", - StacktraceKey: zapcore.OmitKey, - LineEnding: zapcore.DefaultLineEnding, - EncodeLevel: zapcore.CapitalColorLevelEncoder, - EncodeTime: zapcore.RFC3339TimeEncoder, - EncodeDuration: zapcore.StringDurationEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - }, - OutputPaths: []string{"stdout"}, - ErrorOutputPaths: []string{"stderr"}, - } - l *zap.Logger - logger = func() *zap.Logger { - once.Do(func() { l = zap.Must(loggerConfig.Build()) }) - return l - } - ) - - defer func() { - _ = logger().Sync() - }() +var fatal = zap.Must(zap.NewProduction()).Fatal +func main() { var ( rootCmd = &cobra.Command{ Use: "flipt", Short: "Flipt is a modern feature flag solution", Version: version, Run: func(cmd *cobra.Command, _ []string) { - if err := run(cmd.Context(), logger()); err != nil { - logger().Fatal("flipt", zap.Error(err)) + logger, cfg := buildConfig() + defer func() { + _ = logger.Sync() + }() + + if err := run(cmd.Context(), logger, cfg); err != nil { + logger.Fatal("flipt", zap.Error(err)) } }, CompletionOptions: cobra.CompletionOptions{ @@ -98,39 +66,24 @@ func main() { }, } - exportCmd = &cobra.Command{ - Use: "export", - Short: "Export flags/segments/rules to file/stdout", - Run: func(cmd *cobra.Command, _ []string) { - if err := runExport(cmd.Context(), logger()); err != nil { - logger().Fatal("export", zap.Error(err)) - } - }, - } - - importCmd = &cobra.Command{ - Use: "import", - Short: "Import flags/segments/rules from file", - Run: func(cmd *cobra.Command, args []string) { - if err := runImport(cmd.Context(), logger(), args); err != nil { - logger().Fatal("import", zap.Error(err)) - } - }, - } - migrateCmd = &cobra.Command{ Use: "migrate", Short: "Run pending database migrations", Run: func(cmd *cobra.Command, _ []string) { - migrator, err := sql.NewMigrator(*cfg, logger()) + logger, cfg := buildConfig() + defer func() { + _ = logger.Sync() + }() + + migrator, err := sql.NewMigrator(*cfg, logger) if err != nil { - logger().Fatal("initializing migrator", zap.Error(err)) + logger.Fatal("initializing migrator", zap.Error(err)) } defer migrator.Close() if err := migrator.Up(true); err != nil { - logger().Fatal("running migrator", zap.Error(err)) + logger.Fatal("running migrator", zap.Error(err)) } }, } @@ -147,69 +100,97 @@ func main() { Date: date, GoVersion: goVersion, }); err != nil { - logger().Fatal("executing template", zap.Error(err)) + fatal("executing template", zap.Error(err)) } banner = buf.String() - cobra.OnInitialize(func() { - // read in config - res, err := config.Load(cfgPath) - if err != nil { - logger().Fatal("loading configuration", zap.Error(err)) - } + rootCmd.SetVersionTemplate(banner) + rootCmd.PersistentFlags().StringVar(&cfgPath, "config", "/etc/flipt/config/default.yml", "path to config file") + rootCmd.Flags().BoolVar(&forceMigrate, "force-migrate", false, "force migrations before running") + _ = rootCmd.Flags().MarkHidden("force-migrate") - cfg = res.Config - cfgWarnings = res.Warnings + rootCmd.AddCommand(migrateCmd) + rootCmd.AddCommand(newExportCommand()) + rootCmd.AddCommand(newImportCommand()) - loggerConfig.EncoderConfig.TimeKey = cfg.Log.Keys.Time - loggerConfig.EncoderConfig.LevelKey = cfg.Log.Keys.Level - loggerConfig.EncoderConfig.MessageKey = cfg.Log.Keys.Message - // log to file if enabled - if cfg.Log.File != "" { - loggerConfig.OutputPaths = []string{cfg.Log.File} - } + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() - // parse/set log level - loggerConfig.Level, err = zap.ParseAtomicLevel(cfg.Log.Level) - if err != nil { - logger().Fatal("parsing log level", zap.String("level", cfg.Log.Level), zap.Error(err)) - } + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) - if cfg.Log.Encoding > config.LogEncodingConsole { - loggerConfig.Encoding = cfg.Log.Encoding.String() + go func() { + <-interrupt + cancel() + }() - // don't encode with colors if not using console log output - loggerConfig.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder - } - }) + if err := rootCmd.ExecuteContext(ctx); err != nil { + fatal("execute", zap.Error(err)) + } +} - rootCmd.SetVersionTemplate(banner) - rootCmd.PersistentFlags().StringVar(&cfgPath, "config", "/etc/flipt/config/default.yml", "path to config file") - rootCmd.Flags().BoolVar(&forceMigrate, "force-migrate", false, "force migrations before running") - _ = rootCmd.Flags().MarkHidden("force-migrate") +func buildConfig() (*zap.Logger, *config.Config) { + // read in config + res, err := config.Load(cfgPath) + if err != nil { + fatal("loading configuration", zap.Error(err)) + } - exportCmd.Flags().StringVarP(&exportFilename, "output", "o", "", "export to filename (default STDOUT)") - importCmd.Flags().BoolVar(&dropBeforeImport, "drop", false, "drop database before import") - importCmd.Flags().BoolVar(&importStdin, "stdin", false, "import from STDIN") + cfg := res.Config + + loggerConfig := zap.Config{ + Level: zap.NewAtomicLevelAt(zap.InfoLevel), + Development: false, + Encoding: "console", + EncoderConfig: zapcore.EncoderConfig{ + // Keys can be anything except the empty string. + TimeKey: cfg.Log.Keys.Time, + LevelKey: cfg.Log.Keys.Level, + NameKey: "N", + CallerKey: zapcore.OmitKey, + FunctionKey: zapcore.OmitKey, + MessageKey: cfg.Log.Keys.Message, + StacktraceKey: zapcore.OmitKey, + LineEnding: zapcore.DefaultLineEnding, + EncodeLevel: zapcore.CapitalColorLevelEncoder, + EncodeTime: zapcore.RFC3339TimeEncoder, + EncodeDuration: zapcore.StringDurationEncoder, + EncodeCaller: zapcore.ShortCallerEncoder, + }, + OutputPaths: []string{"stdout"}, + ErrorOutputPaths: []string{"stderr"}, + } - rootCmd.AddCommand(migrateCmd) - rootCmd.AddCommand(exportCmd) - rootCmd.AddCommand(importCmd) + // log to file if enabled + if cfg.Log.File != "" { + loggerConfig.OutputPaths = []string{cfg.Log.File} + } - if err := rootCmd.Execute(); err != nil { - logger().Fatal("execute", zap.Error(err)) + // parse/set log level + loggerConfig.Level, err = zap.ParseAtomicLevel(cfg.Log.Level) + if err != nil { + fatal("parsing log level", zap.String("level", cfg.Log.Level), zap.Error(err)) } -} -func run(ctx context.Context, logger *zap.Logger) error { - ctx, cancel := context.WithCancel(ctx) - defer cancel() + if cfg.Log.Encoding > config.LogEncodingConsole { + loggerConfig.Encoding = cfg.Log.Encoding.String() - interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) - defer signal.Stop(interrupt) + // don't encode with colors if not using console log output + loggerConfig.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + } + + logger := zap.Must(loggerConfig.Build()) + + // print out any warnings from config parsing + for _, warning := range res.Warnings { + logger.Warn("configuration warning", zap.String("message", warning)) + } + return logger, cfg +} + +func run(ctx context.Context, logger *zap.Logger, cfg *config.Config) error { isConsole := cfg.Log.Encoding == config.LogEncodingConsole if isConsole { @@ -218,11 +199,6 @@ func run(ctx context.Context, logger *zap.Logger) error { logger.Info("flipt starting", zap.String("version", version), zap.String("commit", commit), zap.String("date", date), zap.String("go_version", goVersion)) } - // print out any warnings from config parsing - for _, warning := range cfgWarnings { - logger.Warn("configuration warning", zap.String("message", warning)) - } - var ( isRelease = release.Is(version) releaseInfo release.Info @@ -266,7 +242,7 @@ func run(ctx context.Context, logger *zap.Logger) error { g, ctx := errgroup.WithContext(ctx) - if err := initLocalState(); err != nil { + if err := initLocalState(cfg); err != nil { logger.Debug("disabling telemetry, state directory not accessible", zap.String("path", cfg.Meta.StateDirectory), zap.Error(err)) cfg.Meta.TelemetryEnabled = false } else { @@ -337,17 +313,12 @@ func run(ctx context.Context, logger *zap.Logger) error { // starts REST http(s) server g.Go(httpServer.Run) - select { - case <-interrupt: - break - case <-ctx.Done(): - break - } + // block until root context is cancelled + // and shutdown has been signalled + <-ctx.Done() logger.Info("shutting down...") - cancel() - shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 5*time.Second) defer shutdownCancel() @@ -358,7 +329,7 @@ func run(ctx context.Context, logger *zap.Logger) error { } // check if state directory already exists, create it if not -func initLocalState() error { +func initLocalState(cfg *config.Config) error { if cfg.Meta.StateDirectory == "" { configDir, err := os.UserConfigDir() if err != nil { diff --git a/cmd/flipt/server.go b/cmd/flipt/server.go new file mode 100644 index 0000000000..e6a15d804f --- /dev/null +++ b/cmd/flipt/server.go @@ -0,0 +1,72 @@ +package main + +import ( + "fmt" + "net/url" + + "go.flipt.io/flipt/internal/config" + "go.flipt.io/flipt/internal/server" + "go.flipt.io/flipt/internal/storage" + "go.flipt.io/flipt/internal/storage/sql" + "go.flipt.io/flipt/internal/storage/sql/mysql" + "go.flipt.io/flipt/internal/storage/sql/postgres" + "go.flipt.io/flipt/internal/storage/sql/sqlite" + sdk "go.flipt.io/flipt/sdk/go" + sdkgrpc "go.flipt.io/flipt/sdk/go/grpc" + sdkhttp "go.flipt.io/flipt/sdk/go/http" + "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +func fliptServer(logger *zap.Logger, cfg *config.Config) (*server.Server, func(), error) { + db, driver, err := sql.Open(*cfg) + if err != nil { + return nil, nil, fmt.Errorf("opening db: %w", err) + } + + var store storage.Store + + switch driver { + case sql.SQLite: + store = sqlite.NewStore(db, logger) + case sql.Postgres, sql.CockroachDB: + store = postgres.NewStore(db, logger) + case sql.MySQL: + store = mysql.NewStore(db, logger) + } + + return server.New(logger, store), func() { _ = db.Close() }, nil +} + +func fliptClient(logger *zap.Logger, address, token string) *sdk.Flipt { + addr, err := url.Parse(address) + if err != nil { + logger.Fatal("export address is invalid", zap.Error(err)) + } + + var transport sdk.Transport + switch addr.Scheme { + case "http": + transport = sdkhttp.NewTransport(address) + case "grpc": + conn, err := grpc.Dial(addr.Host, + grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + logger.Fatal("failed to dial Flipt", zap.Error(err)) + } + + transport = sdkgrpc.NewTransport(conn) + default: + logger.Fatal("unexpected protocol", zap.String("address", address)) + } + + var opts []sdk.Option + if token != "" { + opts = append(opts, sdk.WithClientTokenProvider( + sdk.StaticClientTokenProvider(token), + )) + } + + return sdk.New(transport, opts...).Flipt() +} diff --git a/codecov.yml b/codecov.yml index dac86e495d..ca53070c3c 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,9 @@ ignore: - "rpc/flipt/flipt_grpc.pb.*" - "rpc/flipt/flipt.pb.*" + - "rpc/flipt/auth" + - "rpc/flipt/meta" - "examples" - "ui" - "_tools" + - "hack" diff --git a/config/migrations/cockroachdb/0_initial.down.sql b/config/migrations/cockroachdb/0_initial.down.sql deleted file mode 100644 index a08552b789..0000000000 --- a/config/migrations/cockroachdb/0_initial.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS distributions; -DROP TABLE IF EXISTS rules; -DROP TABLE IF EXISTS constraints; -DROP TABLE IF EXISTS variants; -DROP TABLE IF EXISTS segments; -DROP TABLE IF EXISTS flags; diff --git a/config/migrations/cockroachdb/1_create_table_authentications.down.sql b/config/migrations/cockroachdb/1_create_table_authentications.down.sql deleted file mode 100644 index 264205bca4..0000000000 --- a/config/migrations/cockroachdb/1_create_table_authentications.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP INDEX hashed_client_token_authentications_index; -DROP TABLE IF EXISTS authentications; diff --git a/config/migrations/cockroachdb/2_create_table_operation_lock.down.sql b/config/migrations/cockroachdb/2_create_table_operation_lock.down.sql deleted file mode 100644 index 54feca6d3d..0000000000 --- a/config/migrations/cockroachdb/2_create_table_operation_lock.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS operation_lock; diff --git a/config/migrations/cockroachdb/3_create_namespaces.up.sql b/config/migrations/cockroachdb/3_create_namespaces.up.sql new file mode 100644 index 0000000000..ad983dc8f2 --- /dev/null +++ b/config/migrations/cockroachdb/3_create_namespaces.up.sql @@ -0,0 +1,12 @@ +-- Create namespaces table +CREATE TABLE IF NOT EXISTS namespaces ( + key VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + protected BOOLEAN DEFAULT FALSE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +-- Create default namespace +INSERT INTO namespaces (key, name, description, protected) VALUES ('default', 'Default', 'Default namespace', true); diff --git a/config/migrations/cockroachdb/4_namespaces_relationships.up.sql b/config/migrations/cockroachdb/4_namespaces_relationships.up.sql new file mode 100644 index 0000000000..ec61f74b39 --- /dev/null +++ b/config/migrations/cockroachdb/4_namespaces_relationships.up.sql @@ -0,0 +1,66 @@ +-- Flags +------------------ + +-- Add column namespace_key with a default value +ALTER TABLE flags ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE flags ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE flags ALTER PRIMARY KEY USING COLUMNS (namespace_key, key); +DROP INDEX IF EXISTS flags_key_key CASCADE; + +-- Variants +------------------ + +-- Add column namespace_key with a default value +ALTER TABLE variants ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created unique index +DROP INDEX IF EXISTS "variants_flag_key_key" CASCADE; + +-- Add unique index on namespace_key, flag_key and key columns +ALTER TABLE variants ADD CONSTRAINT "variants_namespace_flag_key" UNIQUE (namespace_key, flag_key, key); + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; + +-- Segments +------------------ + +-- Add column namespace_key with a default value +ALTER TABLE segments ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE segments ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE segments ALTER PRIMARY KEY USING COLUMNS (namespace_key, key); +DROP INDEX IF EXISTS segments_key_key CASCADE; + +-- Constraints +------------------ + +-- Add column namespace_key with a default value +ALTER TABLE constraints ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; + +-- Rules +------------------ + +-- Add column namespace_key with a default value +ALTER TABLE rules ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; \ No newline at end of file diff --git a/config/migrations/mysql/0_initial.down.sql b/config/migrations/mysql/0_initial.down.sql deleted file mode 100644 index a08552b789..0000000000 --- a/config/migrations/mysql/0_initial.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS distributions; -DROP TABLE IF EXISTS rules; -DROP TABLE IF EXISTS constraints; -DROP TABLE IF EXISTS variants; -DROP TABLE IF EXISTS segments; -DROP TABLE IF EXISTS flags; diff --git a/config/migrations/mysql/1_variants_attachment.down.sql b/config/migrations/mysql/1_variants_attachment.down.sql deleted file mode 100644 index b4f264a117..0000000000 --- a/config/migrations/mysql/1_variants_attachment.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE variants DROP COLUMN attachment; diff --git a/config/migrations/mysql/2_create_table_authentications.down.sql b/config/migrations/mysql/2_create_table_authentications.down.sql deleted file mode 100644 index 075057a2a9..0000000000 --- a/config/migrations/mysql/2_create_table_authentications.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP INDEX hashed_client_token_authentications_index ON authentications; -DROP TABLE IF EXISTS authentications; diff --git a/config/migrations/mysql/3_create_table_operation_lock.down.sql b/config/migrations/mysql/3_create_table_operation_lock.down.sql deleted file mode 100644 index 54feca6d3d..0000000000 --- a/config/migrations/mysql/3_create_table_operation_lock.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS operation_lock; diff --git a/config/migrations/mysql/4_create_namespaces.up.sql b/config/migrations/mysql/4_create_namespaces.up.sql new file mode 100644 index 0000000000..ac2455e3a1 --- /dev/null +++ b/config/migrations/mysql/4_create_namespaces.up.sql @@ -0,0 +1,12 @@ +-- Create namespaces table +CREATE TABLE IF NOT EXISTS namespaces ( + `key` VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + protected BOOLEAN DEFAULT FALSE NOT NULL, + created_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) NOT NULL, + updated_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) NOT NULL +); + +-- Create default namespace +INSERT INTO namespaces (`key`, name, description, protected) VALUES ('default', 'Default', 'Default namespace', true); \ No newline at end of file diff --git a/config/migrations/mysql/5_namespaces_relationships.up.sql b/config/migrations/mysql/5_namespaces_relationships.up.sql new file mode 100644 index 0000000000..14ec7289f1 --- /dev/null +++ b/config/migrations/mysql/5_namespaces_relationships.up.sql @@ -0,0 +1,83 @@ +-- Flags + +-- Add column namespace_key with a default value +ALTER TABLE flags ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created unique index +ALTER TABLE flags DROP INDEX `key`, ADD INDEX `key` (`key`) USING BTREE; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE flags ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE flags DROP PRIMARY KEY, ADD PRIMARY KEY (`namespace_key`, `key`); + +-- Variants + +-- Add column namespace_key with a default value +ALTER TABLE variants ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created foreign key +ALTER TABLE variants DROP FOREIGN KEY `variants_ibfk_1`; + +-- Drop previously created unique index and add a new unique index on namespace_key, flag_key and key columns +ALTER TABLE variants DROP INDEX `variants_flag_key_key`, ADD UNIQUE INDEX `variants_namespace_flag_key` (`namespace_key`, `flag_key`, `key`) USING BTREE; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(`namespace_key`, `key`) ON DELETE CASCADE; + +-- Segments + +-- Add column namespace_key with a default value +ALTER TABLE segments ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created unique index and add a new unique index on namespace_key and key columns +ALTER TABLE segments DROP INDEX `key`, ADD INDEX `key` (`key`) USING BTREE; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE segments ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE segments DROP PRIMARY KEY, ADD PRIMARY KEY (`namespace_key`, `key`); + +-- Constraints + +-- Add column namespace_key with a default value +ALTER TABLE constraints ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created foreign key +ALTER TABLE constraints DROP FOREIGN KEY `constraints_ibfk_1`; + +-- Drop previously created index and add a new index on namespace_key and segment_key columns +ALTER TABLE constraints DROP INDEX `segment_key`, ADD INDEX `constraints_namespace_segment_key` (`namespace_key`, `segment_key`) USING BTREE; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(`namespace_key`, `key`) ON DELETE CASCADE; + +-- Rules + +-- Add column namespace_key with a default value +ALTER TABLE rules ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created foreign keys +ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_1`; +ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_2`; + +-- Drop previously created index and add a new index on namespace_key, flag_key and segment_key columns +ALTER TABLE rules DROP INDEX `flag_key`, ADD INDEX `rules_namespace_flag_key` (`namespace_key`, `flag_key`) USING BTREE; +ALTER TABLE rules DROP INDEX `segment_key`, ADD INDEX `rules_namespace_segment_key` (`namespace_key`, `segment_key`) USING BTREE; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(`namespace_key`, `key`) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(`namespace_key`, `key`) ON DELETE CASCADE; diff --git a/config/migrations/postgres/0_initial.down.sql b/config/migrations/postgres/0_initial.down.sql deleted file mode 100644 index a08552b789..0000000000 --- a/config/migrations/postgres/0_initial.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS distributions; -DROP TABLE IF EXISTS rules; -DROP TABLE IF EXISTS constraints; -DROP TABLE IF EXISTS variants; -DROP TABLE IF EXISTS segments; -DROP TABLE IF EXISTS flags; diff --git a/config/migrations/postgres/1_variants_unique_per_flag.down.sql b/config/migrations/postgres/1_variants_unique_per_flag.down.sql deleted file mode 100644 index d8154bb23c..0000000000 --- a/config/migrations/postgres/1_variants_unique_per_flag.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE variants DROP CONSTRAINT variants_flag_key_key_key; -ALTER TABLE variants ADD UNIQUE(key); diff --git a/config/migrations/postgres/1_variants_unique_per_flag.up.sql b/config/migrations/postgres/1_variants_unique_per_flag.up.sql index a768047e63..b3e8b7ac07 100644 --- a/config/migrations/postgres/1_variants_unique_per_flag.up.sql +++ b/config/migrations/postgres/1_variants_unique_per_flag.up.sql @@ -1,2 +1,2 @@ -ALTER TABLE variants DROP CONSTRAINT variants_key_key; +ALTER TABLE variants DROP CONSTRAINT IF EXISTS variants_key_key; ALTER TABLE variants ADD UNIQUE(flag_key, key); diff --git a/config/migrations/postgres/2_segments_match_type.down.sql b/config/migrations/postgres/2_segments_match_type.down.sql deleted file mode 100644 index e30f03ae07..0000000000 --- a/config/migrations/postgres/2_segments_match_type.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE segments DROP COLUMN match_type; diff --git a/config/migrations/postgres/3_variants_attachment.down.sql b/config/migrations/postgres/3_variants_attachment.down.sql deleted file mode 100644 index b4f264a117..0000000000 --- a/config/migrations/postgres/3_variants_attachment.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE variants DROP COLUMN attachment; diff --git a/config/migrations/postgres/4_create_table_authentications.down.sql b/config/migrations/postgres/4_create_table_authentications.down.sql deleted file mode 100644 index 264205bca4..0000000000 --- a/config/migrations/postgres/4_create_table_authentications.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP INDEX hashed_client_token_authentications_index; -DROP TABLE IF EXISTS authentications; diff --git a/config/migrations/postgres/5_create_table_operation_lock.down.sql b/config/migrations/postgres/5_create_table_operation_lock.down.sql deleted file mode 100644 index 54feca6d3d..0000000000 --- a/config/migrations/postgres/5_create_table_operation_lock.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS operation_lock; diff --git a/config/migrations/postgres/6_create_namespaces.up.sql b/config/migrations/postgres/6_create_namespaces.up.sql new file mode 100644 index 0000000000..ad983dc8f2 --- /dev/null +++ b/config/migrations/postgres/6_create_namespaces.up.sql @@ -0,0 +1,12 @@ +-- Create namespaces table +CREATE TABLE IF NOT EXISTS namespaces ( + key VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + protected BOOLEAN DEFAULT FALSE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +-- Create default namespace +INSERT INTO namespaces (key, name, description, protected) VALUES ('default', 'Default', 'Default namespace', true); diff --git a/config/migrations/postgres/7_namespaces_relationships.up.sql b/config/migrations/postgres/7_namespaces_relationships.up.sql new file mode 100644 index 0000000000..dd2216210a --- /dev/null +++ b/config/migrations/postgres/7_namespaces_relationships.up.sql @@ -0,0 +1,70 @@ +-- Flags +---------------- + +-- Add column namespace_key with a default value +ALTER TABLE flags ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE flags ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE flags DROP CONSTRAINT IF EXISTS flags_pkey CASCADE; +ALTER TABLE flags ADD CONSTRAINT flags_pkey PRIMARY KEY (namespace_key, key); + +-- Variants +---------------- + +-- Add column namespace_key with a default value +ALTER TABLE variants ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Drop previously created unique index +ALTER TABLE variants DROP CONSTRAINT IF EXISTS variants_flag_key_key_key CASCADE; + +-- Add unique index on namespace_key, flag_key and key columns +ALTER TABLE variants ADD CONSTRAINT variants_namespace_flag_key UNIQUE (namespace_key, flag_key, key); + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table +ALTER TABLE variants ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; + +-- Segments +---------------- + +-- Add column namespace_key with a default value +ALTER TABLE segments ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE segments ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns +ALTER TABLE segments DROP CONSTRAINT IF EXISTS segments_pkey CASCADE; +ALTER TABLE segments ADD CONSTRAINT segments_pkey PRIMARY KEY (namespace_key, key); + +-- Constraints +---------------- + +-- Add column namespace_key with a default value +ALTER TABLE constraints ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table +ALTER TABLE constraints ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; + +-- Rules +---------------- + +-- Add column namespace_key with a default value +ALTER TABLE rules ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; + +-- Add foreign key constraint on namespace_key column referencing key column of namespaces table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; + +-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table +ALTER TABLE rules ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; \ No newline at end of file diff --git a/config/migrations/sqlite3/0_initial.down.sql b/config/migrations/sqlite3/0_initial.down.sql deleted file mode 100644 index a08552b789..0000000000 --- a/config/migrations/sqlite3/0_initial.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS distributions; -DROP TABLE IF EXISTS rules; -DROP TABLE IF EXISTS constraints; -DROP TABLE IF EXISTS variants; -DROP TABLE IF EXISTS segments; -DROP TABLE IF EXISTS flags; diff --git a/config/migrations/sqlite3/1_variants_unique_per_flag.down.sql b/config/migrations/sqlite3/1_variants_unique_per_flag.down.sql deleted file mode 100644 index 0908d1b0e0..0000000000 --- a/config/migrations/sqlite3/1_variants_unique_per_flag.down.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* SQLite doesn't allow you to drop unique constraints with ALTER TABLE - so we have to create a new table with the schema we want and copy the data over. - https://www.sqlite.org/lang_altertable.html -*/ - -PRAGMA foreign_keys=off; - -CREATE TABLE variants_temp -( - id VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, - flag_key VARCHAR(255) NOT NULL REFERENCES flags ON DELETE CASCADE, - key VARCHAR(255) NOT NULL UNIQUE ON CONFLICT REPLACE, - name VARCHAR(255) NOT NULL, - description TEXT NOT NULL, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL -); - -INSERT INTO variants_temp (id, flag_key, `key`, name, description, created_at, updated_at) - SELECT id, flag_key, `key`, name, description, created_at, updated_at - FROM variants; - -DROP TABLE variants; - -ALTER TABLE variants_temp RENAME TO variants; - -PRAGMA foreign_keys=on; diff --git a/config/migrations/sqlite3/2_segments_match_type.down.sql b/config/migrations/sqlite3/2_segments_match_type.down.sql deleted file mode 100644 index e30f03ae07..0000000000 --- a/config/migrations/sqlite3/2_segments_match_type.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE segments DROP COLUMN match_type; diff --git a/config/migrations/sqlite3/3_variants_attachment.down.sql b/config/migrations/sqlite3/3_variants_attachment.down.sql deleted file mode 100644 index b4f264a117..0000000000 --- a/config/migrations/sqlite3/3_variants_attachment.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE variants DROP COLUMN attachment; diff --git a/config/migrations/sqlite3/4_create_table_authentications.down.sql b/config/migrations/sqlite3/4_create_table_authentications.down.sql deleted file mode 100644 index 264205bca4..0000000000 --- a/config/migrations/sqlite3/4_create_table_authentications.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP INDEX hashed_client_token_authentications_index; -DROP TABLE IF EXISTS authentications; diff --git a/config/migrations/sqlite3/5_create_table_operation_lock.down.sql b/config/migrations/sqlite3/5_create_table_operation_lock.down.sql deleted file mode 100644 index 54feca6d3d..0000000000 --- a/config/migrations/sqlite3/5_create_table_operation_lock.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS operation_lock; diff --git a/config/migrations/sqlite3/6_create_namespaces.up.sql b/config/migrations/sqlite3/6_create_namespaces.up.sql new file mode 100644 index 0000000000..f63b307aff --- /dev/null +++ b/config/migrations/sqlite3/6_create_namespaces.up.sql @@ -0,0 +1,12 @@ +-- Create namespaces table +CREATE TABLE IF NOT EXISTS namespaces ( + key VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + protected BOOLEAN DEFAULT FALSE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +-- Create default namespace +INSERT INTO namespaces (key, name, description, protected) VALUES ('default', 'Default', 'Default namespace', true); \ No newline at end of file diff --git a/config/migrations/sqlite3/7_namespaces_relationships.up.sql b/config/migrations/sqlite3/7_namespaces_relationships.up.sql new file mode 100644 index 0000000000..e04e6d45e6 --- /dev/null +++ b/config/migrations/sqlite3/7_namespaces_relationships.up.sql @@ -0,0 +1,134 @@ +-- Create temporary flags table +CREATE TABLE IF NOT EXISTS flags_temp ( + key VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + enabled BOOLEAN DEFAULT FALSE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + namespace_key VARCHAR(255) NOT NULL DEFAULT 'default' REFERENCES namespaces ON DELETE CASCADE, + PRIMARY KEY (namespace_key, key) +); + +-- Copy data from flags table to temporary flags table +INSERT INTO flags_temp (key, name, description, enabled, created_at, updated_at) + SELECT key, name, description, enabled, created_at, updated_at + FROM flags; + +-- Create temporary variants table +CREATE TABLE IF NOT EXISTS variants_temp ( + id VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + flag_key VARCHAR(255) NOT NULL, + key VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + attachment TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + namespace_key VARCHAR(255) NOT NULL DEFAULT 'default' REFERENCES namespaces ON DELETE CASCADE, + UNIQUE (namespace_key, flag_key, key), + FOREIGN KEY (namespace_key, flag_key) REFERENCES flags_temp (namespace_key, key) ON DELETE CASCADE +); + +-- Copy data from variants table to temporary variants table +INSERT INTO variants_temp (id, flag_key, key, name, description, attachment, created_at, updated_at) + SELECT id, flag_key, key, name, description, attachment, created_at, updated_at + FROM variants; + +-- Create temporary segments table +CREATE TABLE IF NOT EXISTS segments_temp ( + key VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + match_type INTEGER DEFAULT 0 NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + namespace_key VARCHAR(255) NOT NULL DEFAULT 'default' REFERENCES namespaces ON DELETE CASCADE, + PRIMARY KEY (namespace_key, key) +); + +-- Copy data from segments table to temporary segments table +INSERT INTO segments_temp (key, name, description, match_type, created_at, updated_at) + SELECT key, name, description, match_type, created_at, updated_at + FROM segments; + +-- Create temporary constraints table +CREATE TABLE IF NOT EXISTS constraints_temp ( + id VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + segment_key VARCHAR(255) NOT NULL, + type INTEGER DEFAULT 0 NOT NULL, + property VARCHAR(255) NOT NULL, + operator VARCHAR(255) NOT NULL, + value TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + namespace_key VARCHAR(255) NOT NULL DEFAULT 'default' REFERENCES namespaces ON DELETE CASCADE, + FOREIGN KEY (namespace_key, segment_key) REFERENCES segments_temp (namespace_key, key) ON DELETE CASCADE +); + +-- Copy data from constraints table to temporary constraints table +INSERT INTO constraints_temp (id, segment_key, type, property, operator, value, created_at, updated_at) + SELECT id, segment_key, type, property, operator, value, created_at, updated_at + FROM constraints; + +-- Create temporary rules table +CREATE TABLE IF NOT EXISTS rules_temp ( + id VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + flag_key VARCHAR(255) NOT NULL, + segment_key VARCHAR(255) NOT NULL, + rank INTEGER DEFAULT 1 NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + namespace_key VARCHAR(255) NOT NULL DEFAULT 'default' REFERENCES namespaces ON DELETE CASCADE, + FOREIGN KEY (namespace_key, flag_key) REFERENCES flags_temp (namespace_key, key) ON DELETE CASCADE, + FOREIGN KEY (namespace_key, segment_key) REFERENCES segments_temp (namespace_key, key) ON DELETE CASCADE +); + +-- Copy data from rules table to temporary rules table +INSERT INTO rules_temp (id, flag_key, segment_key, rank, created_at, updated_at) + SELECT id, flag_key, segment_key, rank, created_at, updated_at + FROM rules; + +-- Copy data from distributions table to temporary distributions table +CREATE TABLE distributions_temp ( + id VARCHAR(255) PRIMARY KEY UNIQUE NOT NULL, + rule_id VARCHAR(255) NOT NULL REFERENCES rules_temp ON DELETE CASCADE, + variant_id VARCHAR(255) NOT NULL REFERENCES variants_temp ON DELETE CASCADE, + rollout float DEFAULT 0 NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL +); + +INSERT INTO distributions_temp (id, rule_id, variant_id, rollout, created_at, updated_at) + SELECT id, rule_id, variant_id, rollout, created_at, updated_at + FROM distributions; + +-- Drop old distributions table +DROP TABLE distributions; +-- Rename temporary distributions table to distributions +ALTER TABLE distributions_temp RENAME TO distributions; + +-- Drop old rules table +DROP TABLE rules; +-- Rename temporary rules table to rules +ALTER TABLE rules_temp RENAME TO rules; + +-- Drop old flags table +DROP TABLE flags; +-- Rename temporary flags table to flags +ALTER TABLE flags_temp RENAME TO flags; + +-- Drop old variants table +DROP TABLE variants; +-- Rename temporary variants table to variants +ALTER TABLE variants_temp RENAME TO variants; + +-- Drop old segments table +DROP TABLE segments; +-- Rename temporary segments table to segments +ALTER TABLE segments_temp RENAME TO segments; + +-- Drop old constraints table +DROP TABLE constraints; +-- Rename temporary constraints table to constraints +ALTER TABLE constraints_temp RENAME TO constraints; diff --git a/go.mod b/go.mod index d69b808ed5..b80e72d86c 100644 --- a/go.mod +++ b/go.mod @@ -38,6 +38,7 @@ require ( github.com/xo/dburl v0.13.1 go.flipt.io/flipt/errors v1.19.3 go.flipt.io/flipt/rpc/flipt v1.19.3 + go.flipt.io/flipt/sdk/go v0.1.1 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 @@ -153,4 +154,5 @@ replace ( replace ( go.flipt.io/flipt/errors => ./errors/ go.flipt.io/flipt/rpc/flipt => ./rpc/flipt/ + go.flipt.io/flipt/sdk/go => ./sdk/go/ ) diff --git a/go.work.sum b/go.work.sum index 8cfef6c434..2a290fd948 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1010,6 +1010,13 @@ golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -1045,21 +1052,12 @@ golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= -golang.org/x/tools v0.4.1-0.20221208213631-3f74d914ae6d/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= @@ -1084,8 +1082,9 @@ google.golang.org/api v0.103.0/go.mod h1:hGtW6nK1AC+d9si/UBhw8Xli+QMOf6xyNAyJw4q google.golang.org/api v0.107.0 h1:I2SlFjD8ZWabaIFOfeEDg3pf0BHJDh6iYQ1ic3Yu/UU= google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.110.0 h1:l+rh0KYUooe9JGbGVx71tbFo4SMbMTXK3I3ia2QSEeU= google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= +google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8 h1:Cpp2P6TPjujNoC5M2KHY6g7wfyLYfIWRZaSdIKfDasA= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -1125,6 +1124,14 @@ google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA= google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= +google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +honnef.co/go/tools v0.4.2/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= +k8s.io/cri-api v0.25.0/go.mod h1:J1rAyQkSJ2Q6I+aBMOVgg2/cbbebso6FNa0UagiR0kc= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= @@ -1195,9 +1202,3 @@ modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc= modernc.org/zappy v1.0.0 h1:dPVaP+3ueIUv4guk8PuZ2wiUGcJ1WUVvIheeSSTD0yk= mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ= mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d/go.mod h1:IeHQjmn6TOD+e4Z3RFiZMMsLVL+A96Nvptar8Fj71is= -rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= -rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= -rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY= -rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22 h1:fmRfl9WJ4ApJn7LxNuED4m0t18qivVQOxP6aAYG9J6c= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno= diff --git a/hack/build/integration/integration.go b/hack/build/integration/integration.go deleted file mode 100644 index 23d612611b..0000000000 --- a/hack/build/integration/integration.go +++ /dev/null @@ -1,488 +0,0 @@ -package integration - -import ( - "context" - "encoding/json" - "testing" - - "github.com/gofrs/uuid" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.flipt.io/flipt/rpc/flipt" - "go.flipt.io/flipt/rpc/flipt/auth" - sdk "go.flipt.io/flipt/sdk/go" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/types/known/timestamppb" -) - -func Core(t *testing.T, fn func(t *testing.T) sdk.SDK) { - t.Run("Core Suite", func(t *testing.T) { - client := fn(t) - - ctx := context.Background() - - t.Run("Flags and Variants", func(t *testing.T) { - t.Log("Create a new flag with key \"test\".") - - created, err := client.Flipt().CreateFlag(ctx, &flipt.CreateFlagRequest{ - Key: "test", - Name: "Test", - Description: "This is a test flag", - Enabled: true, - }) - require.NoError(t, err) - - assert.Equal(t, "test", created.Key) - assert.Equal(t, "Test", created.Name) - assert.Equal(t, "This is a test flag", created.Description) - assert.True(t, created.Enabled, "Flag should be enabled") - - t.Log("Retrieve flag with key \"test\".") - - flag, err := client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{Key: "test"}) - require.NoError(t, err) - - assert.Equal(t, created, flag) - - t.Log("Update flag with key \"test\".") - - updated, err := client.Flipt().UpdateFlag(ctx, &flipt.UpdateFlagRequest{ - Key: created.Key, - Name: "Test 2", - Description: created.Description, - Enabled: true, - }) - require.NoError(t, err) - - assert.Equal(t, "Test 2", updated.Name) - - t.Log("List all flags.") - - flags, err := client.Flipt().ListFlags(ctx, &flipt.ListFlagRequest{}) - require.NoError(t, err) - - assert.Len(t, flags.Flags, 1) - assert.Equal(t, updated.Key, flags.Flags[0].Key) - assert.Equal(t, updated.Name, flags.Flags[0].Name) - assert.Equal(t, updated.Description, flags.Flags[0].Description) - - for _, key := range []string{"one", "two"} { - t.Logf("Create variant with key %q.", key) - - createdVariant, err := client.Flipt().CreateVariant(ctx, &flipt.CreateVariantRequest{ - Key: key, - Name: key, - FlagKey: "test", - }) - require.NoError(t, err) - - assert.Equal(t, key, createdVariant.Key) - assert.Equal(t, key, createdVariant.Name) - } - - t.Log("Get flag \"test\" and check variants.") - - flag, err = client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{Key: "test"}) - require.NoError(t, err) - - assert.Len(t, flag.Variants, 2) - - t.Log(`Update variant "one" (rename from "one" to "One").`) - - updatedVariant, err := client.Flipt().UpdateVariant(ctx, &flipt.UpdateVariantRequest{ - FlagKey: "test", - Id: flag.Variants[0].Id, - Key: "one", - Name: "One", - }) - require.NoError(t, err) - - assert.Equal(t, "one", updatedVariant.Key) - assert.Equal(t, "One", updatedVariant.Name) - }) - - t.Run("Segments and Constraints", func(t *testing.T) { - t.Log(`Create segment "everyone".`) - - createdSegment, err := client.Flipt().CreateSegment(ctx, &flipt.CreateSegmentRequest{ - Key: "everyone", - Name: "Everyone", - MatchType: flipt.MatchType_ALL_MATCH_TYPE, - }) - require.NoError(t, err) - - assert.Equal(t, "everyone", createdSegment.Key) - assert.Equal(t, "Everyone", createdSegment.Name) - assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, createdSegment.MatchType) - - t.Log(`Get segment "everyone".`) - - retrievedSegment, err := client.Flipt().GetSegment(ctx, &flipt.GetSegmentRequest{ - Key: "everyone", - }) - require.NoError(t, err) - - assert.Equal(t, createdSegment.Key, retrievedSegment.Key) - assert.Equal(t, createdSegment.Name, retrievedSegment.Name) - assert.Equal(t, createdSegment.Description, retrievedSegment.Description) - assert.Equal(t, createdSegment.MatchType, createdSegment.MatchType) - - t.Log(`Update segment "everyone" (rename "Everyone" to "All the peeps").`) - - updatedSegment, err := client.Flipt().UpdateSegment(ctx, &flipt.UpdateSegmentRequest{ - Key: "everyone", - Name: "All the peeps", - }) - require.NoError(t, err) - - assert.Equal(t, "everyone", updatedSegment.Key) - assert.Equal(t, "All the peeps", updatedSegment.Name) - assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, updatedSegment.MatchType) - - for _, constraint := range []struct { - property, operator, value string - }{ - {"foo", "eq", "bar"}, - {"fizz", "neq", "buzz"}, - } { - t.Logf(`Create constraint with key %q %s %q.`, - constraint.property, - constraint.operator, - constraint.value, - ) - - createdConstraint, err := client.Flipt().CreateConstraint(ctx, &flipt.CreateConstraintRequest{ - SegmentKey: "everyone", - Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, - Property: constraint.property, - Operator: constraint.operator, - Value: constraint.value, - }) - require.NoError(t, err) - - assert.Equal(t, constraint.property, createdConstraint.Property) - assert.Equal(t, constraint.operator, createdConstraint.Operator) - assert.Equal(t, constraint.value, createdConstraint.Value) - } - - t.Log(`Get segment "everyone" with constraints.`) - - retrievedSegment, err = client.Flipt().GetSegment(ctx, &flipt.GetSegmentRequest{ - Key: "everyone", - }) - require.NoError(t, err) - - assert.Len(t, retrievedSegment.Constraints, 2) - assert.Equal(t, "foo", retrievedSegment.Constraints[0].Property) - assert.Equal(t, "fizz", retrievedSegment.Constraints[1].Property) - - t.Log(`Update constraint value (from "bar" to "baz").`) - updatedConstraint, err := client.Flipt().UpdateConstraint(ctx, &flipt.UpdateConstraintRequest{ - SegmentKey: "everyone", - Type: retrievedSegment.Constraints[0].Type, - Id: retrievedSegment.Constraints[0].Id, - Property: retrievedSegment.Constraints[0].Property, - Operator: retrievedSegment.Constraints[0].Operator, - Value: "baz", - }) - require.NoError(t, err) - - assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, updatedConstraint.Type) - assert.Equal(t, "foo", updatedConstraint.Property) - assert.Equal(t, "eq", updatedConstraint.Operator) - assert.Equal(t, "baz", updatedConstraint.Value) - }) - - t.Run("Rules and Distributions", func(t *testing.T) { - t.Log(`Create rule "rank 1".`) - - ruleOne, err := client.Flipt().CreateRule(ctx, &flipt.CreateRuleRequest{ - FlagKey: "test", - SegmentKey: "everyone", - Rank: 1, - }) - - require.NoError(t, err) - - assert.Equal(t, "test", ruleOne.FlagKey) - assert.Equal(t, "everyone", ruleOne.SegmentKey) - assert.Equal(t, int32(1), ruleOne.Rank) - - t.Log(`Get rules "rank 1".`) - - retrievedRule, err := client.Flipt().GetRule(ctx, &flipt.GetRuleRequest{ - FlagKey: "test", - Id: ruleOne.Id, - }) - require.NoError(t, err) - - assert.Equal(t, "test", retrievedRule.FlagKey) - assert.Equal(t, "everyone", retrievedRule.SegmentKey) - assert.Equal(t, int32(1), retrievedRule.Rank) - - t.Log(`Create rule "rank 2".`) - - ruleTwo, err := client.Flipt().CreateRule(ctx, &flipt.CreateRuleRequest{ - FlagKey: "test", - SegmentKey: "everyone", - Rank: 2, - }) - - require.NoError(t, err) - - assert.Equal(t, "test", ruleTwo.FlagKey) - assert.Equal(t, "everyone", ruleTwo.SegmentKey) - assert.Equal(t, int32(2), ruleTwo.Rank) - - t.Log(`List rules.`) - - allRules, err := client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ - FlagKey: "test", - }) - require.NoError(t, err) - - assert.Len(t, allRules.Rules, 2) - - assert.Equal(t, ruleOne.Id, allRules.Rules[0].Id) - assert.Equal(t, ruleTwo.Id, allRules.Rules[1].Id) - - t.Log(`Re-order rules.`) - - err = client.Flipt().OrderRules(ctx, &flipt.OrderRulesRequest{ - FlagKey: "test", - RuleIds: []string{ruleTwo.Id, ruleOne.Id}, - }) - require.NoError(t, err) - - t.Log(`List rules again.`) - - allRules, err = client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ - FlagKey: "test", - }) - require.NoError(t, err) - - assert.Len(t, allRules.Rules, 2) - - // ensure the order has switched - assert.Equal(t, ruleTwo.Id, allRules.Rules[0].Id) - assert.Equal(t, int32(1), allRules.Rules[0].Rank) - assert.Equal(t, ruleOne.Id, allRules.Rules[1].Id) - assert.Equal(t, int32(2), allRules.Rules[1].Rank) - - t.Log(`Create distribution "rollout 100".`) - - flag, err := client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{ - Key: "test", - }) - require.NoError(t, err) - - distribution, err := client.Flipt().CreateDistribution(ctx, &flipt.CreateDistributionRequest{ - FlagKey: "test", - RuleId: ruleTwo.Id, - VariantId: flag.Variants[0].Id, - Rollout: 100, - }) - require.NoError(t, err) - - assert.Equal(t, ruleTwo.Id, distribution.RuleId) - assert.Equal(t, float32(100), distribution.Rollout) - }) - - t.Run("Evaluation", func(t *testing.T) { - t.Log(`Successful match.`) - - result, err := client.Flipt().Evaluate(ctx, &flipt.EvaluationRequest{ - FlagKey: "test", - EntityId: uuid.Must(uuid.NewV4()).String(), - Context: map[string]string{ - "foo": "baz", - "fizz": "bozz", - }, - }) - require.NoError(t, err) - - require.True(t, result.Match, "Evaluation should have matched.") - assert.Equal(t, "everyone", result.SegmentKey) - assert.Equal(t, "one", result.Value) - assert.Equal(t, flipt.EvaluationReason_MATCH_EVALUATION_REASON, result.Reason) - - t.Log(`Unsuccessful match.`) - - result, err = client.Flipt().Evaluate(ctx, &flipt.EvaluationRequest{ - FlagKey: "test", - EntityId: uuid.Must(uuid.NewV4()).String(), - Context: map[string]string{ - "fizz": "buzz", - }, - }) - require.NoError(t, err) - - assert.False(t, result.Match, "Evaluation should not have matched.") - }) - - t.Run("Batch Evaluation", func(t *testing.T) { - t.Log(`Successful match.`) - - results, err := client.Flipt().BatchEvaluate(ctx, &flipt.BatchEvaluationRequest{ - Requests: []*flipt.EvaluationRequest{ - { - FlagKey: "test", - EntityId: uuid.Must(uuid.NewV4()).String(), - Context: map[string]string{ - "foo": "baz", - "fizz": "bozz", - }, - }, - }, - }) - require.NoError(t, err) - - require.Len(t, results.Responses, 1) - result := results.Responses[0] - - require.True(t, result.Match, "Evaluation should have matched.") - assert.Equal(t, "everyone", result.SegmentKey) - assert.Equal(t, "one", result.Value) - assert.Equal(t, flipt.EvaluationReason_MATCH_EVALUATION_REASON, result.Reason) - - t.Log(`Unsuccessful match.`) - - results, err = client.Flipt().BatchEvaluate(ctx, &flipt.BatchEvaluationRequest{ - Requests: []*flipt.EvaluationRequest{ - { - FlagKey: "test", - EntityId: uuid.Must(uuid.NewV4()).String(), - Context: map[string]string{ - "fizz": "buzz", - }, - }, - }, - }) - require.NoError(t, err) - - require.Len(t, results.Responses, 1) - result = results.Responses[0] - - assert.False(t, result.Match, "Evaluation should not have matched.") - }) - - t.Run("Delete", func(t *testing.T) { - t.Log(`Rules.`) - rules, err := client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ - FlagKey: "test", - }) - require.NoError(t, err) - - for _, rule := range rules.Rules { - client.Flipt().DeleteRule(ctx, &flipt.DeleteRuleRequest{ - FlagKey: "test", - Id: rule.Id, - }) - } - - t.Log(`Flag.`) - client.Flipt().DeleteFlag(ctx, &flipt.DeleteFlagRequest{ - Key: "test", - }) - - t.Log(`Segment.`) - client.Flipt().DeleteSegment(ctx, &flipt.DeleteSegmentRequest{ - Key: "everyone", - }) - }) - - t.Run("Meta", func(t *testing.T) { - t.Log(`Returns Flipt service information.`) - - info, err := client.Meta().GetInfo(ctx) - require.NoError(t, err) - - assert.Equal(t, "application/json", info.ContentType) - - var infoMap map[string]any - require.NoError(t, json.Unmarshal(info.Data, &infoMap)) - - version, ok := infoMap["version"] - assert.True(t, ok, "Missing version.") - assert.NotEmpty(t, version) - - goVersion, ok := infoMap["goVersion"] - assert.True(t, ok, "Missing Go version.") - assert.NotEmpty(t, goVersion) - - t.Log(`Returns expected configuration.`) - - config, err := client.Meta().GetConfiguration(ctx) - require.NoError(t, err) - - assert.Equal(t, "application/json", info.ContentType) - - var configMap map[string]any - require.NoError(t, json.Unmarshal(config.Data, &configMap)) - - for _, name := range []string{ - "log", - "ui", - "cache", - "server", - "db", - } { - field, ok := configMap[name] - assert.True(t, ok, "Missing %s.", name) - assert.NotEmpty(t, field) - } - }) - }) -} - -func Authenticated(t *testing.T, fn func(t *testing.T) sdk.SDK) { - t.Run("Authentication Methods", func(t *testing.T) { - client := fn(t) - - ctx := context.Background() - - t.Log(`List methods (ensure at-least 1).`) - - methods, err := client.Auth().PublicAuthenticationService().ListAuthenticationMethods(ctx) - require.NoError(t, err) - - assert.NotEmpty(t, methods) - - t.Run("Get Self", func(t *testing.T) { - authn, err := client.Auth().AuthenticationService().GetAuthenticationSelf(ctx) - require.NoError(t, err) - - assert.NotEmpty(t, authn.Id) - }) - - t.Run("Static Token", func(t *testing.T) { - t.Log(`Create token.`) - - resp, err := client.Auth().AuthenticationMethodTokenService().CreateToken(ctx, &auth.CreateTokenRequest{ - Name: "Access Token", - Description: "Some kind of access token.", - }) - require.NoError(t, err) - - assert.NotEmpty(t, resp.ClientToken) - assert.Equal(t, "Access Token", resp.Authentication.Metadata["io.flipt.auth.token.name"]) - assert.Equal(t, "Some kind of access token.", resp.Authentication.Metadata["io.flipt.auth.token.description"]) - }) - - t.Run("Expire Self", func(t *testing.T) { - err := client.Auth().AuthenticationService().ExpireAuthenticationSelf(ctx, &auth.ExpireAuthenticationSelfRequest{ - ExpiresAt: timestamppb.Now(), - }) - require.NoError(t, err) - - t.Log(`Ensure token is no longer valid.`) - - _, err = client.Auth().AuthenticationService().GetAuthenticationSelf(ctx) - - status, ok := status.FromError(err) - require.True(t, ok) - assert.Equal(t, codes.Unauthenticated, status.Code()) - }) - }) -} diff --git a/hack/build/integration/integration_test.go b/hack/build/integration/integration_test.go deleted file mode 100644 index f80a89f831..0000000000 --- a/hack/build/integration/integration_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package integration_test - -import ( - "flag" - "fmt" - "strings" - "testing" - - "github.com/stretchr/testify/require" - "go.flipt.io/flipt/build/integration" - sdk "go.flipt.io/flipt/sdk/go" - sdkgrpc "go.flipt.io/flipt/sdk/go/grpc" - sdkhttp "go.flipt.io/flipt/sdk/go/http" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" -) - -var ( - fliptAddr = flag.String("flipt-addr", "grpc://localhost:9000", "Address for running Flipt instance (gRPC only)") - fliptToken = flag.String("flipt-token", "", "Authentication token to be used during test suite") -) - -func TestFlipt(t *testing.T) { - var transport sdk.Transport - protocol, addr, _ := strings.Cut(*fliptAddr, "://") - switch protocol { - case "grpc": - conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) - require.NoError(t, err) - - transport = sdkgrpc.NewTransport(conn) - case "http", "https": - transport = sdkhttp.NewTransport(*fliptAddr) - default: - t.Fatalf("Unexpected flipt address protocol %q", *fliptAddr) - } - - var ( - name = fmt.Sprintf("(%s) No Authentication", protocol) - opts []sdk.Option - ) - - if *fliptToken != "" { - name = fmt.Sprintf("(%s) With Static Token Authentication", protocol) - opts = append(opts, sdk.WithClientTokenProvider( - sdk.StaticClientTokenProvider(*fliptToken), - )) - } - - t.Run(name, func(t *testing.T) { - fn := func(t *testing.T) sdk.SDK { - return sdk.New(transport, opts...) - } - - integration.Core(t, fn) - - // run extra tests in authenticated context - if *fliptToken != "" { - integration.Authenticated(t, fn) - } - }) -} diff --git a/hack/build/internal/test/integration.go b/hack/build/internal/test/integration.go deleted file mode 100644 index 93e1de5942..0000000000 --- a/hack/build/internal/test/integration.go +++ /dev/null @@ -1,110 +0,0 @@ -package test - -import ( - "context" - "fmt" - "log" - "strings" - - "dagger.io/dagger" - "github.com/google/uuid" - "golang.org/x/sync/errgroup" -) - -var protocolPorts = map[string]string{"http": "8080", "grpc": "9000"} - -type testCase struct { - name string - address string - extraEnvs [][2]string - extraFlags []string -} - -func Integration(ctx context.Context, client *dagger.Client, base, flipt *dagger.Container) error { - logs := client.CacheVolume(fmt.Sprintf("logs-%s", uuid.New())) - _, err := flipt.WithUser("root"). - WithMountedCache("/logs", logs). - WithExec([]string{"chown", "flipt:flipt", "/logs"}). - ExitCode(ctx) - if err != nil { - return err - } - - var cases []testCase - - for protocol, port := range protocolPorts { - address := fmt.Sprintf("%s://flipt:%s", protocol, port) - cases = append(cases, - testCase{ - name: fmt.Sprintf("%s no authentication", strings.ToUpper(protocol)), - address: address, - }, - testCase{ - name: fmt.Sprintf("%s with authentication", strings.ToUpper(protocol)), - address: address, - extraEnvs: [][2]string{ - {"FLIPT_AUTHENTICATION_REQUIRED", "true"}, - {"FLIPT_AUTHENTICATION_METHODS_TOKEN_ENABLED", "true"}, - {"FLIPT_AUTHENTICATION_METHODS_TOKEN_BOOTSTRAP_TOKEN", "some-token"}, - }, - extraFlags: []string{"-flipt-token", "some-token"}, - }, - ) - } - - var g errgroup.Group - - for _, test := range cases { - test := test - - flipt := flipt - for _, env := range test.extraEnvs { - flipt = flipt.WithEnvVariable(env[0], env[1]) - } - - g.Go(integration( - ctx, - test.name, - base, - flipt, - logs, - append(test.extraFlags, "-flipt-addr", test.address)..., - )) - } - - err = g.Wait() - - if _, lerr := client.Container().From("alpine:3.16"). - WithMountedCache("/logs", logs). - WithExec([]string{"cp", "-r", "/logs", "/out"}). - Directory("/out").Export(ctx, "hack/build/logs"); lerr != nil { - log.Println("Error copying logs", lerr) - } - - return err -} - -func integration(ctx context.Context, name string, base, flipt *dagger.Container, logs *dagger.CacheVolume, flags ...string) func() error { - name = fmt.Sprintf("flipt-%s", strings.ToLower(strings.ReplaceAll(name, " ", "-"))) - logFile := fmt.Sprintf("/var/opt/flipt/logs/%s.log", name) - - flipt = flipt. - // this ensures a unique instance of flipt is created per - // integration test - WithEnvVariable("UNIQUE", uuid.New().String()). - WithEnvVariable("FLIPT_LOG_LEVEL", "debug"). - WithMountedCache("/var/opt/flipt/logs", logs). - WithEnvVariable("FLIPT_LOG_FILE", logFile). - WithExec(nil) - - return func() error { - flags := append([]string{"-v", "-race"}, flags...) - _, err := base. - WithServiceBinding("flipt", flipt). - WithWorkdir("hack/build/integration"). - WithExec(append([]string{"go", "test"}, append(flags, ".")...)). - ExitCode(ctx) - - return err - } -} diff --git a/hack/build/magefile.go b/hack/build/magefile.go index f751f7e106..a48011db82 100644 --- a/hack/build/magefile.go +++ b/hack/build/magefile.go @@ -14,8 +14,8 @@ import ( "github.com/magefile/mage/sh" "go.flipt.io/flipt/build/internal" "go.flipt.io/flipt/build/internal/publish" - "go.flipt.io/flipt/build/internal/test" "go.flipt.io/flipt/build/release" + "go.flipt.io/flipt/build/testing" "golang.org/x/mod/modfile" "golang.org/x/sync/errgroup" ) @@ -109,7 +109,7 @@ type Test mg.Namespace func (t Test) All(ctx context.Context) error { var g errgroup.Group - for db := range test.All { + for db := range testing.All { db := db g.Go(func() error { return t.Database(ctx, db) @@ -144,7 +144,7 @@ func (t Test) Unit(ctx context.Context) error { return err } - return test.Test(ctx, client, base) + return testing.Unit(ctx, client, base) } // Database runs the unit test suite against the desired database (one of ["sqlite" "postgres" "mysql" "cockroach"]). @@ -171,7 +171,7 @@ func (t Test) Database(ctx context.Context, db string) error { return err } - return test.Test(test.All[db](ctx, client, base)) + return testing.Unit(testing.All[db](ctx, client, base)) } // Integration runs the entire integration test suite. @@ -205,7 +205,7 @@ func (t Test) Integration(ctx context.Context) error { return err } - return test.Integration(ctx, client, base, flipt) + return testing.Integration(ctx, client, base, flipt) } type Release mg.Namespace diff --git a/hack/build/testing/integration.go b/hack/build/testing/integration.go new file mode 100644 index 0000000000..b96ce31f60 --- /dev/null +++ b/hack/build/testing/integration.go @@ -0,0 +1,225 @@ +package testing + +import ( + "context" + "errors" + "fmt" + "log" + "math/rand" + "path" + "strings" + "time" + + "dagger.io/dagger" + "github.com/google/uuid" + "golang.org/x/sync/errgroup" +) + +var ( + protocolPorts = map[string]string{"http": "8080", "grpc": "9000"} + replacer = strings.NewReplacer(" ", "-", "/", "-") + sema = make(chan struct{}, 6) +) + +type testConfig struct { + name string + namespace string + address string + token string +} + +func Integration(ctx context.Context, client *dagger.Client, base, flipt *dagger.Container) error { + logs := client.CacheVolume(fmt.Sprintf("logs-%s", uuid.New())) + _, err := flipt.WithUser("root"). + WithMountedCache("/logs", logs). + WithExec([]string{"chown", "flipt:flipt", "/logs"}). + ExitCode(ctx) + if err != nil { + return err + } + + var cases []testConfig + + for _, namespace := range []string{ + "", + fmt.Sprintf("%x", rand.Int()), + } { + for protocol, port := range protocolPorts { + address := fmt.Sprintf("%s://flipt:%s", protocol, port) + cases = append(cases, + testConfig{ + name: fmt.Sprintf("%s namespace %s no authentication", strings.ToUpper(protocol), namespace), + namespace: namespace, + address: address, + }, + testConfig{ + name: fmt.Sprintf("%s namespace %s with authentication", strings.ToUpper(protocol), namespace), + namespace: namespace, + address: address, + token: "some-token", + }, + ) + } + } + + rand.Seed(time.Now().Unix()) + + var g errgroup.Group + + for _, test := range []struct { + name string + fn func(_ context.Context, base, flipt *dagger.Container, conf testConfig) func() error + }{ + { + name: "api", + fn: api, + }, + { + name: "import/export", + fn: importExport, + }, + } { + for _, config := range cases { + config := config + + flipt := flipt + if config.token != "" { + flipt = flipt. + WithEnvVariable("FLIPT_AUTHENTICATION_REQUIRED", "true"). + WithEnvVariable("FLIPT_AUTHENTICATION_METHODS_TOKEN_ENABLED", "true"). + WithEnvVariable("FLIPT_AUTHENTICATION_METHODS_TOKEN_BOOTSTRAP_TOKEN", config.token) + } + + name := strings.ToLower(replacer.Replace(fmt.Sprintf("flipt-test-%s-config-%s", test.name, config.name))) + flipt = flipt. + WithEnvVariable("FLIPT_LOG_LEVEL", "debug"). + WithEnvVariable("FLIPT_LOG_FILE", fmt.Sprintf("/var/opt/flipt/logs/%s.log", name)). + WithMountedCache("/var/opt/flipt/logs", logs) + + g.Go(take(test.fn(ctx, base, flipt, config))) + } + } + + err = g.Wait() + + if _, lerr := client.Container().From("alpine:3.16"). + WithMountedCache("/logs", logs). + WithExec([]string{"cp", "-r", "/logs", "/out"}). + Directory("/out").Export(ctx, "hack/build/logs"); lerr != nil { + log.Println("Error copying logs", lerr) + } + + return err +} + +func take(fn func() error) func() error { + return func() error { + // insert into semaphore channel to maintain + // a max concurrency + sema <- struct{}{} + defer func() { <-sema }() + + return fn() + } +} + +func api(ctx context.Context, base, flipt *dagger.Container, conf testConfig) func() error { + return suite(ctx, "api", base, + // create unique instance for test case + flipt. + WithEnvVariable("UNIQUE", uuid.New().String()). + WithExec(nil), conf) +} + +func importExport(ctx context.Context, base, flipt *dagger.Container, conf testConfig) func() error { + return func() error { + // import testdata before running readonly suite + flags := []string{"--address", conf.address} + if conf.token != "" { + flags = append(flags, "--token", conf.token) + } + + if conf.namespace != "" { + flags = append(flags, "--namespace", conf.namespace) + } + + var ( + // create unique instance for test case + fliptToTest = flipt. + WithEnvVariable("UNIQUE", uuid.New().String()). + WithExec(nil) + + importCmd = append([]string{"/bin/flipt", "import"}, append(flags, "--create-namespace", "import.yaml")...) + seed = base.File("hack/build/testing/integration/readonly/testdata/seed.yaml") + ) + // use target flipt binary to invoke import + _, err := flipt. + WithEnvVariable("UNIQUE", uuid.New().String()). + // copy testdata import yaml from base + WithFile("import.yaml", seed). + WithServiceBinding("flipt", fliptToTest). + // it appears it takes a little while for Flipt to come online + // For the go tests they have to compile and that seems to be enough + // time for the target Flipt to come up. + // However, in this case the flipt binary is prebuilt and needs a little sleep. + WithExec([]string{"sh", "-c", fmt.Sprintf("sleep 2 && %s", strings.Join(importCmd, " "))}). + ExitCode(ctx) + if err != nil { + return err + } + + // run readonly suite against imported Flipt instance + if err := suite(ctx, "readonly", base, fliptToTest, conf)(); err != nil { + return err + } + + expected, err := seed.Contents(ctx) + if err != nil { + return err + } + + // use target flipt binary to invoke import + generated, err := flipt. + WithEnvVariable("UNIQUE", uuid.New().String()). + WithServiceBinding("flipt", fliptToTest). + WithExec(append([]string{"/bin/flipt", "export"}, flags...)). + Stdout(ctx) + if err != nil { + return err + } + + if expected != generated { + fmt.Println("Unexpected difference in exported output:") + fmt.Println("Expected:") + fmt.Println(expected + "\n") + fmt.Println("Found:") + fmt.Println(generated) + + return errors.New("Exported yaml did not match.") + } + + return nil + } +} + +func suite(ctx context.Context, dir string, base, flipt *dagger.Container, conf testConfig) func() error { + return func() error { + flags := []string{"--flipt-addr", conf.address} + if conf.namespace != "" { + flags = append(flags, "--flipt-namespace", conf.namespace) + } + + if conf.token != "" { + flags = append(flags, "--flipt-token", conf.token) + } + + _, err := base. + WithServiceBinding("flipt", flipt). + WithWorkdir(path.Join("hack/build/testing/integration", dir)). + WithEnvVariable("UNIQUE", uuid.New().String()). + WithExec(append([]string{"go", "test", "-v", "-race"}, append(flags, ".")...)). + ExitCode(ctx) + + return err + } +} diff --git a/hack/build/testing/integration/api/api.go b/hack/build/testing/integration/api/api.go new file mode 100644 index 0000000000..a11c6abdcd --- /dev/null +++ b/hack/build/testing/integration/api/api.go @@ -0,0 +1,628 @@ +package api + +import ( + "context" + "encoding/json" + "fmt" + "testing" + + "github.com/gofrs/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.flipt.io/flipt/rpc/flipt" + sdk "go.flipt.io/flipt/sdk/go" +) + +func API(t *testing.T, client sdk.SDK, namespace string) { + ctx := context.Background() + + t.Run("Namespaces", func(t *testing.T) { + if !namespaceIsDefault(namespace) { + t.Log(`Create namespace.`) + + created, err := client.Flipt().CreateNamespace(ctx, &flipt.CreateNamespaceRequest{ + Key: namespace, + Name: namespace, + }) + require.NoError(t, err) + + assert.Equal(t, namespace, created.Key) + assert.Equal(t, namespace, created.Name) + + t.Log(`Get namespace by key.`) + + retrieved, err := client.Flipt().GetNamespace(ctx, &flipt.GetNamespaceRequest{ + Key: namespace, + }) + + assert.Equal(t, created.Name, retrieved.Name) + + t.Log(`List namespaces.`) + + namespaces, err := client.Flipt().ListNamespaces(ctx, &flipt.ListNamespaceRequest{}) + require.NoError(t, err) + + assert.Len(t, namespaces.Namespaces, 2) + + assert.Equal(t, "default", namespaces.Namespaces[0].Key) + assert.Equal(t, namespace, namespaces.Namespaces[1].Key) + + t.Log(`Update namespace.`) + + updated, err := client.Flipt().UpdateNamespace(ctx, &flipt.UpdateNamespaceRequest{ + Key: namespace, + Name: namespace, + Description: "Some kind of description", + }) + require.NoError(t, err) + + assert.Equal(t, "Some kind of description", updated.Description) + } else { + t.Log(`Ensure default cannot be created.`) + + _, err := client.Flipt().CreateNamespace(ctx, &flipt.CreateNamespaceRequest{ + Key: "default", + Name: "Default", + }) + require.EqualError(t, err, "rpc error: code = InvalidArgument desc = namespace \"default\" is not unique") + + t.Log(`Ensure default can be updated.`) + + updated, err := client.Flipt().UpdateNamespace(ctx, &flipt.UpdateNamespaceRequest{ + Key: "default", + Name: "Default", + Description: "Some namespace description.", + }) + require.NoError(t, err) + assert.Equal(t, "Default", updated.Name) + + t.Log(`Ensure default cannot be deleted.`) + + err = client.Flipt().DeleteNamespace(ctx, &flipt.DeleteNamespaceRequest{ + Key: "default", + }) + require.EqualError(t, err, "rpc error: code = InvalidArgument desc = namespace \"default\" is protected") + } + }) + + t.Run("Flags and Variants", func(t *testing.T) { + t.Log("Create a new flag with key \"test\".") + + created, err := client.Flipt().CreateFlag(ctx, &flipt.CreateFlagRequest{ + NamespaceKey: namespace, + Key: "test", + Name: "Test", + Description: "This is a test flag", + Enabled: true, + }) + require.NoError(t, err) + + assert.Equal(t, "test", created.Key) + assert.Equal(t, "Test", created.Name) + assert.Equal(t, "This is a test flag", created.Description) + assert.True(t, created.Enabled, "Flag should be enabled") + + t.Log("Retrieve flag with key \"test\".") + + flag, err := client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{ + NamespaceKey: namespace, + Key: "test", + }) + require.NoError(t, err) + + assert.Equal(t, created, flag) + + t.Log("Update flag with key \"test\".") + + updated, err := client.Flipt().UpdateFlag(ctx, &flipt.UpdateFlagRequest{ + NamespaceKey: namespace, + Key: created.Key, + Name: "Test 2", + Description: created.Description, + Enabled: true, + }) + require.NoError(t, err) + + assert.Equal(t, "Test 2", updated.Name) + + t.Log("List all flags.") + + flags, err := client.Flipt().ListFlags(ctx, &flipt.ListFlagRequest{ + NamespaceKey: namespace, + }) + require.NoError(t, err) + + assert.Len(t, flags.Flags, 1) + assert.Equal(t, updated.Key, flags.Flags[0].Key) + assert.Equal(t, updated.Name, flags.Flags[0].Name) + assert.Equal(t, updated.Description, flags.Flags[0].Description) + + for _, key := range []string{"one", "two"} { + t.Logf("Create variant with key %q.", key) + + createdVariant, err := client.Flipt().CreateVariant(ctx, &flipt.CreateVariantRequest{ + NamespaceKey: namespace, + Key: key, + Name: key, + FlagKey: "test", + }) + require.NoError(t, err) + + assert.Equal(t, key, createdVariant.Key) + assert.Equal(t, key, createdVariant.Name) + } + + t.Log("Get flag \"test\" and check variants.") + + flag, err = client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{ + NamespaceKey: namespace, + Key: "test", + }) + require.NoError(t, err) + + assert.Len(t, flag.Variants, 2) + + t.Log(`Update variant "one" (rename from "one" to "One").`) + + updatedVariant, err := client.Flipt().UpdateVariant(ctx, &flipt.UpdateVariantRequest{ + NamespaceKey: namespace, + FlagKey: "test", + Id: flag.Variants[0].Id, + Key: "one", + Name: "One", + }) + require.NoError(t, err) + + assert.Equal(t, "one", updatedVariant.Key) + assert.Equal(t, "One", updatedVariant.Name) + }) + + t.Run("Segments and Constraints", func(t *testing.T) { + t.Log(`Create segment "everyone".`) + + createdSegment, err := client.Flipt().CreateSegment(ctx, &flipt.CreateSegmentRequest{ + NamespaceKey: namespace, + Key: "everyone", + Name: "Everyone", + MatchType: flipt.MatchType_ALL_MATCH_TYPE, + }) + require.NoError(t, err) + + assert.Equal(t, "everyone", createdSegment.Key) + assert.Equal(t, "Everyone", createdSegment.Name) + assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, createdSegment.MatchType) + + t.Log(`Get segment "everyone".`) + + retrievedSegment, err := client.Flipt().GetSegment(ctx, &flipt.GetSegmentRequest{ + NamespaceKey: namespace, + Key: "everyone", + }) + require.NoError(t, err) + + assert.Equal(t, createdSegment.Key, retrievedSegment.Key) + assert.Equal(t, createdSegment.Name, retrievedSegment.Name) + assert.Equal(t, createdSegment.Description, retrievedSegment.Description) + assert.Equal(t, createdSegment.MatchType, createdSegment.MatchType) + + t.Log(`Update segment "everyone" (rename "Everyone" to "All the peeps").`) + + updatedSegment, err := client.Flipt().UpdateSegment(ctx, &flipt.UpdateSegmentRequest{ + NamespaceKey: namespace, + Key: "everyone", + Name: "All the peeps", + }) + require.NoError(t, err) + + assert.Equal(t, "everyone", updatedSegment.Key) + assert.Equal(t, "All the peeps", updatedSegment.Name) + assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, updatedSegment.MatchType) + + for _, constraint := range []struct { + property, operator, value string + }{ + {"foo", "eq", "bar"}, + {"fizz", "neq", "buzz"}, + } { + t.Logf(`Create constraint with key %q %s %q.`, + constraint.property, + constraint.operator, + constraint.value, + ) + + createdConstraint, err := client.Flipt().CreateConstraint(ctx, &flipt.CreateConstraintRequest{ + NamespaceKey: namespace, + SegmentKey: "everyone", + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: constraint.property, + Operator: constraint.operator, + Value: constraint.value, + }) + require.NoError(t, err) + + assert.Equal(t, constraint.property, createdConstraint.Property) + assert.Equal(t, constraint.operator, createdConstraint.Operator) + assert.Equal(t, constraint.value, createdConstraint.Value) + } + + t.Log(`Get segment "everyone" with constraints.`) + + retrievedSegment, err = client.Flipt().GetSegment(ctx, &flipt.GetSegmentRequest{ + NamespaceKey: namespace, + Key: "everyone", + }) + require.NoError(t, err) + + assert.Len(t, retrievedSegment.Constraints, 2) + assert.Equal(t, "foo", retrievedSegment.Constraints[0].Property) + assert.Equal(t, "fizz", retrievedSegment.Constraints[1].Property) + + t.Log(`Update constraint value (from "bar" to "baz").`) + updatedConstraint, err := client.Flipt().UpdateConstraint(ctx, &flipt.UpdateConstraintRequest{ + NamespaceKey: namespace, + SegmentKey: "everyone", + Type: retrievedSegment.Constraints[0].Type, + Id: retrievedSegment.Constraints[0].Id, + Property: retrievedSegment.Constraints[0].Property, + Operator: retrievedSegment.Constraints[0].Operator, + Value: "baz", + }) + require.NoError(t, err) + + assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, updatedConstraint.Type) + assert.Equal(t, "foo", updatedConstraint.Property) + assert.Equal(t, "eq", updatedConstraint.Operator) + assert.Equal(t, "baz", updatedConstraint.Value) + }) + + t.Run("Rules and Distributions", func(t *testing.T) { + t.Log(`Create rule "rank 1".`) + + ruleOne, err := client.Flipt().CreateRule(ctx, &flipt.CreateRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + SegmentKey: "everyone", + Rank: 1, + }) + + require.NoError(t, err) + + assert.Equal(t, "test", ruleOne.FlagKey) + assert.Equal(t, "everyone", ruleOne.SegmentKey) + assert.Equal(t, int32(1), ruleOne.Rank) + + t.Log(`Get rules "rank 1".`) + + retrievedRule, err := client.Flipt().GetRule(ctx, &flipt.GetRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + Id: ruleOne.Id, + }) + require.NoError(t, err) + + assert.Equal(t, "test", retrievedRule.FlagKey) + assert.Equal(t, "everyone", retrievedRule.SegmentKey) + assert.Equal(t, int32(1), retrievedRule.Rank) + + t.Log(`Create rule "rank 2".`) + + ruleTwo, err := client.Flipt().CreateRule(ctx, &flipt.CreateRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + SegmentKey: "everyone", + Rank: 2, + }) + + require.NoError(t, err) + + assert.Equal(t, "test", ruleTwo.FlagKey) + assert.Equal(t, "everyone", ruleTwo.SegmentKey) + assert.Equal(t, int32(2), ruleTwo.Rank) + + // ensure you can not link flags and segments from different namespaces. + if !namespaceIsDefault(namespace) { + t.Log(`Ensure that rules can only link entities in the same namespace.`) + _, err = client.Flipt().CreateRule(ctx, &flipt.CreateRuleRequest{ + FlagKey: "test", + SegmentKey: "everyone", + Rank: 2, + }) + + msg := "rpc error: code = NotFound desc = flag \"default/test\" or segment \"default/everyone\" not found" + require.EqualError(t, err, msg) + } + + t.Log(`List rules.`) + + allRules, err := client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + }) + require.NoError(t, err) + + assert.Len(t, allRules.Rules, 2) + + assert.Equal(t, ruleOne.Id, allRules.Rules[0].Id) + assert.Equal(t, ruleTwo.Id, allRules.Rules[1].Id) + + t.Log(`Re-order rules.`) + + err = client.Flipt().OrderRules(ctx, &flipt.OrderRulesRequest{ + NamespaceKey: namespace, + FlagKey: "test", + RuleIds: []string{ruleTwo.Id, ruleOne.Id}, + }) + require.NoError(t, err) + + t.Log(`List rules again.`) + + allRules, err = client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + }) + require.NoError(t, err) + + assert.Len(t, allRules.Rules, 2) + + // ensure the order has switched + assert.Equal(t, ruleTwo.Id, allRules.Rules[0].Id) + assert.Equal(t, int32(1), allRules.Rules[0].Rank) + assert.Equal(t, ruleOne.Id, allRules.Rules[1].Id) + assert.Equal(t, int32(2), allRules.Rules[1].Rank) + + t.Log(`Create distribution "rollout 100".`) + + flag, err := client.Flipt().GetFlag(ctx, &flipt.GetFlagRequest{ + NamespaceKey: namespace, + Key: "test", + }) + require.NoError(t, err) + + distribution, err := client.Flipt().CreateDistribution(ctx, &flipt.CreateDistributionRequest{ + NamespaceKey: namespace, + FlagKey: "test", + RuleId: ruleTwo.Id, + VariantId: flag.Variants[0].Id, + Rollout: 100, + }) + require.NoError(t, err) + + if !namespaceIsDefault(namespace) { + t.Log(`Ensure that distributions and all entities associated with them are part of same namespace.`) + var ( + flagKey = "defaultflag" + ) + + defaultFlag, err := client.Flipt().CreateFlag(ctx, &flipt.CreateFlagRequest{ + Key: flagKey, + Name: "DefaultFlag", + Description: "default flag description", + Enabled: true, + }) + require.NoError(t, err) + + defaultVariant, err := client.Flipt().CreateVariant(ctx, &flipt.CreateVariantRequest{ + Key: "defaultvariant", + Name: "DefaultVariant", + FlagKey: flagKey, + Description: "default variant description", + }) + require.NoError(t, err) + + _, err = client.Flipt().CreateDistribution(ctx, &flipt.CreateDistributionRequest{ + FlagKey: "test", + RuleId: ruleTwo.Id, + VariantId: defaultVariant.Id, + Rollout: 100, + }) + + msg := fmt.Sprintf("rpc error: code = NotFound desc = variant %q, rule %q, flag %q in namespace %q not found", defaultVariant.Id, ruleTwo.Id, "test", "default") + require.EqualError(t, err, msg) + + _, err = client.Flipt().UpdateDistribution(ctx, &flipt.UpdateDistributionRequest{ + NamespaceKey: namespace, + Id: distribution.Id, + FlagKey: "test", + VariantId: defaultVariant.Id, + RuleId: ruleTwo.Id, + Rollout: 50, + }) + + msg = fmt.Sprintf("rpc error: code = NotFound desc = variant %q, rule %q, flag %q in namespace %q not found", defaultVariant.Id, ruleTwo.Id, "test", namespace) + require.EqualError(t, err, msg) + + err = client.Flipt().DeleteFlag(ctx, &flipt.DeleteFlagRequest{ + Key: defaultFlag.Key, + }) + require.NoError(t, err) + + err = client.Flipt().DeleteVariant(ctx, &flipt.DeleteVariantRequest{ + Id: defaultVariant.Id, + FlagKey: flagKey, + }) + require.NoError(t, err) + } + + assert.Equal(t, ruleTwo.Id, distribution.RuleId) + assert.Equal(t, float32(100), distribution.Rollout) + }) + + t.Run("Evaluation", func(t *testing.T) { + t.Log(`Successful match.`) + + result, err := client.Flipt().Evaluate(ctx, &flipt.EvaluationRequest{ + NamespaceKey: namespace, + FlagKey: "test", + EntityId: uuid.Must(uuid.NewV4()).String(), + Context: map[string]string{ + "foo": "baz", + "fizz": "bozz", + }, + }) + require.NoError(t, err) + + require.True(t, result.Match, "Evaluation should have matched.") + assert.Equal(t, "everyone", result.SegmentKey) + assert.Equal(t, "one", result.Value) + assert.Equal(t, flipt.EvaluationReason_MATCH_EVALUATION_REASON, result.Reason) + + t.Log(`Unsuccessful match.`) + + result, err = client.Flipt().Evaluate(ctx, &flipt.EvaluationRequest{ + NamespaceKey: namespace, + FlagKey: "test", + EntityId: uuid.Must(uuid.NewV4()).String(), + Context: map[string]string{ + "fizz": "buzz", + }, + }) + require.NoError(t, err) + + assert.False(t, result.Match, "Evaluation should not have matched.") + }) + + t.Run("Batch Evaluation", func(t *testing.T) { + t.Log(`Successful match.`) + + results, err := client.Flipt().BatchEvaluate(ctx, &flipt.BatchEvaluationRequest{ + NamespaceKey: namespace, + Requests: []*flipt.EvaluationRequest{ + { + NamespaceKey: namespace, + FlagKey: "test", + EntityId: uuid.Must(uuid.NewV4()).String(), + Context: map[string]string{ + "foo": "baz", + "fizz": "bozz", + }, + }, + }, + }) + require.NoError(t, err) + + require.Len(t, results.Responses, 1) + result := results.Responses[0] + + require.True(t, result.Match, "Evaluation should have matched.") + assert.Equal(t, "everyone", result.SegmentKey) + assert.Equal(t, "one", result.Value) + assert.Equal(t, flipt.EvaluationReason_MATCH_EVALUATION_REASON, result.Reason) + + t.Log(`Unsuccessful match.`) + + results, err = client.Flipt().BatchEvaluate(ctx, &flipt.BatchEvaluationRequest{ + NamespaceKey: namespace, + Requests: []*flipt.EvaluationRequest{ + { + NamespaceKey: namespace, + FlagKey: "test", + EntityId: uuid.Must(uuid.NewV4()).String(), + Context: map[string]string{ + "fizz": "buzz", + }, + }, + }, + }) + require.NoError(t, err) + + require.Len(t, results.Responses, 1) + result = results.Responses[0] + + assert.False(t, result.Match, "Evaluation should not have matched.") + }) + + t.Run("Delete", func(t *testing.T) { + if !namespaceIsDefault(namespace) { + t.Log(`Namespace with flags fails.`) + err := client.Flipt().DeleteNamespace(ctx, &flipt.DeleteNamespaceRequest{ + Key: namespace, + }) + + msg := fmt.Sprintf("rpc error: code = InvalidArgument desc = namespace %q cannot be deleted; flags must be deleted first", namespace) + require.EqualError(t, err, msg) + } + + t.Log(`Rules.`) + rules, err := client.Flipt().ListRules(ctx, &flipt.ListRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + }) + require.NoError(t, err) + + for _, rule := range rules.Rules { + client.Flipt().DeleteRule(ctx, &flipt.DeleteRuleRequest{ + NamespaceKey: namespace, + FlagKey: "test", + Id: rule.Id, + }) + } + + t.Log(`Flag.`) + err = client.Flipt().DeleteFlag(ctx, &flipt.DeleteFlagRequest{ + NamespaceKey: namespace, + Key: "test", + }) + require.NoError(t, err) + + t.Log(`Segment.`) + err = client.Flipt().DeleteSegment(ctx, &flipt.DeleteSegmentRequest{ + NamespaceKey: namespace, + Key: "everyone", + }) + require.NoError(t, err) + + if !namespaceIsDefault(namespace) { + t.Log(`Namespace.`) + err = client.Flipt().DeleteNamespace(ctx, &flipt.DeleteNamespaceRequest{ + Key: namespace, + }) + require.NoError(t, err) + } + }) + + t.Run("Meta", func(t *testing.T) { + t.Log(`Returns Flipt service information.`) + + info, err := client.Meta().GetInfo(ctx) + require.NoError(t, err) + + assert.Equal(t, "application/json", info.ContentType) + + var infoMap map[string]any + require.NoError(t, json.Unmarshal(info.Data, &infoMap)) + + version, ok := infoMap["version"] + assert.True(t, ok, "Missing version.") + assert.NotEmpty(t, version) + + goVersion, ok := infoMap["goVersion"] + assert.True(t, ok, "Missing Go version.") + assert.NotEmpty(t, goVersion) + + t.Log(`Returns expected configuration.`) + + config, err := client.Meta().GetConfiguration(ctx) + require.NoError(t, err) + + assert.Equal(t, "application/json", info.ContentType) + + var configMap map[string]any + require.NoError(t, json.Unmarshal(config.Data, &configMap)) + + for _, name := range []string{ + "log", + "ui", + "cache", + "server", + "db", + } { + field, ok := configMap[name] + assert.True(t, ok, "Missing %s.", name) + assert.NotEmpty(t, field) + } + }) +} + +func namespaceIsDefault(ns string) bool { + return ns == "" || ns == "default" +} diff --git a/hack/build/testing/integration/api/api_test.go b/hack/build/testing/integration/api/api_test.go new file mode 100644 index 0000000000..2a8b75fe66 --- /dev/null +++ b/hack/build/testing/integration/api/api_test.go @@ -0,0 +1,20 @@ +package api_test + +import ( + "testing" + + "go.flipt.io/flipt/build/testing/integration" + "go.flipt.io/flipt/build/testing/integration/api" + sdk "go.flipt.io/flipt/sdk/go" +) + +func TestAPI(t *testing.T) { + integration.Harness(t, func(t *testing.T, sdk sdk.SDK, namespace string, authentication bool) { + api.API(t, sdk, namespace) + + // run extra tests in authenticated context + if authentication { + api.Authenticated(t, sdk) + } + }) +} diff --git a/hack/build/testing/integration/api/authenticated.go b/hack/build/testing/integration/api/authenticated.go new file mode 100644 index 0000000000..d5c002d4a9 --- /dev/null +++ b/hack/build/testing/integration/api/authenticated.go @@ -0,0 +1,63 @@ +package api + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.flipt.io/flipt/rpc/flipt/auth" + sdk "go.flipt.io/flipt/sdk/go" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func Authenticated(t *testing.T, client sdk.SDK) { + t.Run("Authentication Methods", func(t *testing.T) { + ctx := context.Background() + + t.Log(`List methods (ensure at-least 1).`) + + methods, err := client.Auth().PublicAuthenticationService().ListAuthenticationMethods(ctx) + require.NoError(t, err) + + assert.NotEmpty(t, methods) + + t.Run("Get Self", func(t *testing.T) { + authn, err := client.Auth().AuthenticationService().GetAuthenticationSelf(ctx) + require.NoError(t, err) + + assert.NotEmpty(t, authn.Id) + }) + + t.Run("Static Token", func(t *testing.T) { + t.Log(`Create token.`) + + resp, err := client.Auth().AuthenticationMethodTokenService().CreateToken(ctx, &auth.CreateTokenRequest{ + Name: "Access Token", + Description: "Some kind of access token.", + }) + require.NoError(t, err) + + assert.NotEmpty(t, resp.ClientToken) + assert.Equal(t, "Access Token", resp.Authentication.Metadata["io.flipt.auth.token.name"]) + assert.Equal(t, "Some kind of access token.", resp.Authentication.Metadata["io.flipt.auth.token.description"]) + }) + + t.Run("Expire Self", func(t *testing.T) { + err := client.Auth().AuthenticationService().ExpireAuthenticationSelf(ctx, &auth.ExpireAuthenticationSelfRequest{ + ExpiresAt: timestamppb.Now(), + }) + require.NoError(t, err) + + t.Log(`Ensure token is no longer valid.`) + + _, err = client.Auth().AuthenticationService().GetAuthenticationSelf(ctx) + + status, ok := status.FromError(err) + require.True(t, ok) + assert.Equal(t, codes.Unauthenticated, status.Code()) + }) + }) +} diff --git a/hack/build/testing/integration/integration.go b/hack/build/testing/integration/integration.go new file mode 100644 index 0000000000..66d7389829 --- /dev/null +++ b/hack/build/testing/integration/integration.go @@ -0,0 +1,59 @@ +package integration + +import ( + "flag" + "fmt" + "strings" + "testing" + + "github.com/stretchr/testify/require" + sdk "go.flipt.io/flipt/sdk/go" + sdkgrpc "go.flipt.io/flipt/sdk/go/grpc" + sdkhttp "go.flipt.io/flipt/sdk/go/http" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +var ( + fliptAddr = flag.String("flipt-addr", "grpc://localhost:9000", "Address for running Flipt instance (gRPC only)") + fliptToken = flag.String("flipt-token", "", "Authentication token to be used during test suite") + fliptNamespace = flag.String("flipt-namespace", "", "Namespace used to scope API calls.") +) + +func Harness(t *testing.T, fn func(t *testing.T, sdk sdk.SDK, ns string, authenticated bool)) { + var transport sdk.Transport + + protocol, host, _ := strings.Cut(*fliptAddr, "://") + switch protocol { + case "grpc": + conn, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) + require.NoError(t, err) + + transport = sdkgrpc.NewTransport(conn) + case "http", "https": + transport = sdkhttp.NewTransport(fmt.Sprintf("%s://%s", protocol, host)) + default: + t.Fatalf("Unexpected flipt address protocol %s://%s", protocol, host) + } + + var ( + opts []sdk.Option + authentication = false + ) + + if authentication = *fliptToken != ""; authentication { + opts = append(opts, sdk.WithClientTokenProvider( + sdk.StaticClientTokenProvider(*fliptToken), + )) + } + + namespace := "default" + if *fliptNamespace != "" { + namespace = *fliptNamespace + } + + name := fmt.Sprintf("[Protocol %q; Namespace %q; Authentication %v]", protocol, namespace, authentication) + t.Run(name, func(t *testing.T) { + fn(t, sdk.New(transport, opts...), namespace, authentication) + }) +} diff --git a/hack/build/testing/integration/readonly/readonly_test.go b/hack/build/testing/integration/readonly/readonly_test.go new file mode 100644 index 0000000000..ce82dcd30a --- /dev/null +++ b/hack/build/testing/integration/readonly/readonly_test.go @@ -0,0 +1,62 @@ +package readonly_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.flipt.io/flipt/build/testing/integration" + "go.flipt.io/flipt/rpc/flipt" + sdk "go.flipt.io/flipt/sdk/go" +) + +// TestReadOnly is a suite of tests which presumes all the data found in the local testdata +// folder has been loaded into the target instance being tested. +// It then exercises a bunch of read operations via the provided SDK in the target namespace. +func TestReadOnly(t *testing.T) { + integration.Harness(t, func(t *testing.T, sdk sdk.SDK, namespace string, _ bool) { + ctx := context.Background() + ns, err := sdk.Flipt().GetNamespace(ctx, &flipt.GetNamespaceRequest{ + Key: namespace, + }) + require.NoError(t, err) + + assert.Equal(t, namespace, ns.Key) + + expected := "Default" + if namespace != "" && namespace != "default" { + expected = namespace + } + assert.Equal(t, expected, ns.Name) + + require.NoError(t, err) + flags, err := sdk.Flipt().ListFlags(ctx, &flipt.ListFlagRequest{ + NamespaceKey: namespace, + }) + require.NoError(t, err) + + require.Len(t, flags.Flags, 1) + + flag := flags.Flags[0] + assert.Equal(t, namespace, flag.NamespaceKey) + assert.Equal(t, "color", flag.Key) + assert.Equal(t, "Color", flag.Name) + assert.Equal(t, "This flag represents two colors.", flag.Description) + assert.True(t, flag.Enabled) + + require.Len(t, flag.Variants, 2) + + assert.Equal(t, "blue", flag.Variants[0].Key) + assert.Equal(t, "Blue", flag.Variants[0].Name) + + assert.Equal(t, "red", flag.Variants[1].Key) + assert.Equal(t, "Red", flag.Variants[1].Name) + + segments, err := sdk.Flipt().ListSegments(ctx, &flipt.ListSegmentRequest{ + NamespaceKey: namespace, + }) + + require.Len(t, segments.Segments, 2) + }) +} diff --git a/hack/build/testing/integration/readonly/testdata/seed.yaml b/hack/build/testing/integration/readonly/testdata/seed.yaml new file mode 100644 index 0000000000..0aacd817e1 --- /dev/null +++ b/hack/build/testing/integration/readonly/testdata/seed.yaml @@ -0,0 +1,46 @@ +flags: +- key: color + name: Color + description: This flag represents two colors. + enabled: true + variants: + - key: blue + name: Blue + - key: red + name: Red + rules: + - segment: team-red + rank: 1 + distributions: + - variant: red + rollout: 100 + - segment: team-blue + rank: 2 + distributions: + - variant: blue + rollout: 100 +segments: +- key: team-red + name: Red Team + constraints: + - type: STRING_COMPARISON_TYPE + property: favourite_color + operator: eq + value: red + - type: STRING_COMPARISON_TYPE + property: favourite_color + operator: neq + value: blue + match_type: ALL_MATCH_TYPE +- key: team-blue + name: Blue Team + constraints: + - type: STRING_COMPARISON_TYPE + property: favourite_color + operator: eq + value: blue + - type: STRING_COMPARISON_TYPE + property: favourite_color + operator: neq + value: red + match_type: ALL_MATCH_TYPE diff --git a/hack/build/internal/test/test.go b/hack/build/testing/test.go similarity index 96% rename from hack/build/internal/test/test.go rename to hack/build/testing/test.go index 54806fadd1..33927b721a 100644 --- a/hack/build/internal/test/test.go +++ b/hack/build/testing/test.go @@ -1,4 +1,4 @@ -package test +package testing import ( "context" @@ -6,7 +6,7 @@ import ( "dagger.io/dagger" ) -func Test(ctx context.Context, client *dagger.Client, flipt *dagger.Container) error { +func Unit(ctx context.Context, client *dagger.Client, flipt *dagger.Container) error { // create Redis service container redisSrv := client.Container(). From("redis"). diff --git a/internal/ext/exporter.go b/internal/ext/exporter.go index eb77529365..32577e4149 100644 --- a/internal/ext/exporter.go +++ b/internal/ext/exporter.go @@ -6,28 +6,29 @@ import ( "fmt" "io" - "go.flipt.io/flipt/internal/storage" "go.flipt.io/flipt/rpc/flipt" "gopkg.in/yaml.v2" ) const defaultBatchSize = 25 -type lister interface { - ListFlags(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) - ListSegments(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) - ListRules(ctx context.Context, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) +type Lister interface { + ListFlags(context.Context, *flipt.ListFlagRequest) (*flipt.FlagList, error) + ListSegments(context.Context, *flipt.ListSegmentRequest) (*flipt.SegmentList, error) + ListRules(context.Context, *flipt.ListRuleRequest) (*flipt.RuleList, error) } type Exporter struct { - store lister - batchSize uint64 + store Lister + batchSize int32 + namespace string } -func NewExporter(store lister) *Exporter { +func NewExporter(store Lister, namespace string) *Exporter { return &Exporter{ store: store, batchSize: defaultBatchSize, + namespace: namespace, } } @@ -46,13 +47,20 @@ func (e *Exporter) Export(ctx context.Context, w io.Writer) error { ) // export flags/variants in batches - for batch := uint64(0); remaining; batch++ { - resp, err := e.store.ListFlags(ctx, storage.WithPageToken(nextPage), storage.WithLimit(batchSize)) + for batch := int32(0); remaining; batch++ { + resp, err := e.store.ListFlags( + ctx, + &flipt.ListFlagRequest{ + NamespaceKey: e.namespace, + PageToken: nextPage, + Limit: batchSize, + }, + ) if err != nil { return fmt.Errorf("getting flags: %w", err) } - flags := resp.Results + flags := resp.Flags nextPage = resp.NextPageToken remaining = nextPage != "" @@ -87,12 +95,18 @@ func (e *Exporter) Export(ctx context.Context, w io.Writer) error { } // export rules for flag - resp, err := e.store.ListRules(ctx, flag.Key) + resp, err := e.store.ListRules( + ctx, + &flipt.ListRuleRequest{ + NamespaceKey: e.namespace, + FlagKey: flag.Key, + }, + ) if err != nil { return fmt.Errorf("getting rules for flag %q: %w", flag.Key, err) } - rules := resp.Results + rules := resp.Rules for _, r := range rules { rule := &Rule{ SegmentKey: r.SegmentKey, @@ -117,13 +131,20 @@ func (e *Exporter) Export(ctx context.Context, w io.Writer) error { nextPage = "" // export segments/constraints in batches - for batch := uint64(0); remaining; batch++ { - resp, err := e.store.ListSegments(ctx, storage.WithPageToken(nextPage), storage.WithLimit(batchSize)) + for batch := int32(0); remaining; batch++ { + resp, err := e.store.ListSegments( + ctx, + &flipt.ListSegmentRequest{ + NamespaceKey: e.namespace, + PageToken: nextPage, + Limit: batchSize, + }, + ) if err != nil { return fmt.Errorf("getting segments: %w", err) } - segments := resp.Results + segments := resp.Segments nextPage = resp.NextPageToken remaining = nextPage != "" diff --git a/internal/ext/exporter_test.go b/internal/ext/exporter_test.go index 0992e3a565..1dbbdf678e 100644 --- a/internal/ext/exporter_test.go +++ b/internal/ext/exporter_test.go @@ -22,22 +22,22 @@ type mockLister struct { ruleErr error } -func (m mockLister) ListFlags(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { - return storage.ResultSet[*flipt.Flag]{ - Results: m.flags, +func (m mockLister) ListFlags(_ context.Context, _ *flipt.ListFlagRequest) (*flipt.FlagList, error) { + return &flipt.FlagList{ + Flags: m.flags, }, m.flagErr } -func (m mockLister) ListSegments(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { - return storage.ResultSet[*flipt.Segment]{ - Results: m.segments, - }, m.segmentErr +func (m mockLister) ListRules(_ context.Context, _ *flipt.ListRuleRequest) (*flipt.RuleList, error) { + return &flipt.RuleList{ + Rules: m.rules, + }, m.ruleErr } -func (m mockLister) ListRules(ctx context.Context, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { - return storage.ResultSet[*flipt.Rule]{ - Results: m.rules, - }, m.ruleErr +func (m mockLister) ListSegments(_ context.Context, _ *flipt.ListSegmentRequest) (*flipt.SegmentList, error) { + return &flipt.SegmentList{ + Segments: m.segments, + }, m.segmentErr } func TestExport(t *testing.T) { @@ -117,7 +117,7 @@ func TestExport(t *testing.T) { } var ( - exporter = NewExporter(lister) + exporter = NewExporter(lister, storage.DefaultNamespace) b = new(bytes.Buffer) ) diff --git a/internal/ext/importer.go b/internal/ext/importer.go index d5e5c6ed50..d730a82a70 100644 --- a/internal/ext/importer.go +++ b/internal/ext/importer.go @@ -7,10 +7,14 @@ import ( "io" "go.flipt.io/flipt/rpc/flipt" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "gopkg.in/yaml.v2" ) -type creator interface { +type Creator interface { + GetNamespace(ctx context.Context, r *flipt.GetNamespaceRequest) (*flipt.Namespace, error) + CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest) (*flipt.Variant, error) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error) @@ -20,12 +24,16 @@ type creator interface { } type Importer struct { - store creator + creator Creator + namespace string + createNS bool } -func NewImporter(store creator) *Importer { +func NewImporter(store Creator, namespace string, createNS bool) *Importer { return &Importer{ - store: store, + creator: store, + namespace: namespace, + createNS: createNS, } } @@ -39,6 +47,24 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { return fmt.Errorf("unmarshalling document: %w", err) } + if i.createNS && i.namespace != "" && i.namespace != "default" { + _, err := i.creator.GetNamespace(ctx, &flipt.GetNamespaceRequest{ + Key: i.namespace, + }) + + if status.Code(err) != codes.NotFound { + return err + } + + _, err = i.creator.CreateNamespace(ctx, &flipt.CreateNamespaceRequest{ + Key: i.namespace, + Name: i.namespace, + }) + if err != nil { + return err + } + } + var ( // map flagKey => *flag createdFlags = make(map[string]*flipt.Flag) @@ -54,11 +80,12 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { continue } - flag, err := i.store.CreateFlag(ctx, &flipt.CreateFlagRequest{ - Key: f.Key, - Name: f.Name, - Description: f.Description, - Enabled: f.Enabled, + flag, err := i.creator.CreateFlag(ctx, &flipt.CreateFlagRequest{ + Key: f.Key, + Name: f.Name, + Description: f.Description, + Enabled: f.Enabled, + NamespaceKey: i.namespace, }) if err != nil { @@ -80,12 +107,13 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { } } - variant, err := i.store.CreateVariant(ctx, &flipt.CreateVariantRequest{ - FlagKey: f.Key, - Key: v.Key, - Name: v.Name, - Description: v.Description, - Attachment: string(out), + variant, err := i.creator.CreateVariant(ctx, &flipt.CreateVariantRequest{ + FlagKey: f.Key, + Key: v.Key, + Name: v.Name, + Description: v.Description, + Attachment: string(out), + NamespaceKey: i.namespace, }) if err != nil { @@ -104,11 +132,12 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { continue } - segment, err := i.store.CreateSegment(ctx, &flipt.CreateSegmentRequest{ - Key: s.Key, - Name: s.Name, - Description: s.Description, - MatchType: flipt.MatchType(flipt.MatchType_value[s.MatchType]), + segment, err := i.creator.CreateSegment(ctx, &flipt.CreateSegmentRequest{ + Key: s.Key, + Name: s.Name, + Description: s.Description, + MatchType: flipt.MatchType(flipt.MatchType_value[s.MatchType]), + NamespaceKey: i.namespace, }) if err != nil { @@ -120,12 +149,13 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { continue } - _, err := i.store.CreateConstraint(ctx, &flipt.CreateConstraintRequest{ - SegmentKey: s.Key, - Type: flipt.ComparisonType(flipt.ComparisonType_value[c.Type]), - Property: c.Property, - Operator: c.Operator, - Value: c.Value, + _, err := i.creator.CreateConstraint(ctx, &flipt.CreateConstraintRequest{ + SegmentKey: s.Key, + Type: flipt.ComparisonType(flipt.ComparisonType_value[c.Type]), + Property: c.Property, + Operator: c.Operator, + Value: c.Value, + NamespaceKey: i.namespace, }) if err != nil { @@ -148,10 +178,11 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { continue } - rule, err := i.store.CreateRule(ctx, &flipt.CreateRuleRequest{ - FlagKey: f.Key, - SegmentKey: r.SegmentKey, - Rank: int32(r.Rank), + rule, err := i.creator.CreateRule(ctx, &flipt.CreateRuleRequest{ + FlagKey: f.Key, + SegmentKey: r.SegmentKey, + Rank: int32(r.Rank), + NamespaceKey: i.namespace, }) if err != nil { @@ -168,11 +199,12 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error { return fmt.Errorf("finding variant: %s; flag: %s", d.VariantKey, f.Key) } - _, err := i.store.CreateDistribution(ctx, &flipt.CreateDistributionRequest{ - FlagKey: f.Key, - RuleId: rule.Id, - VariantId: variant.Id, - Rollout: d.Rollout, + _, err := i.creator.CreateDistribution(ctx, &flipt.CreateDistributionRequest{ + FlagKey: f.Key, + RuleId: rule.Id, + VariantId: variant.Id, + Rollout: d.Rollout, + NamespaceKey: i.namespace, }) if err != nil { diff --git a/internal/ext/importer_fuzz_test.go b/internal/ext/importer_fuzz_test.go index 5ac7cecc65..6ea612080e 100644 --- a/internal/ext/importer_fuzz_test.go +++ b/internal/ext/importer_fuzz_test.go @@ -8,6 +8,8 @@ import ( "context" "io/ioutil" "testing" + + "go.flipt.io/flipt/internal/storage" ) func FuzzImport(f *testing.F) { @@ -19,7 +21,7 @@ func FuzzImport(f *testing.F) { } f.Fuzz(func(t *testing.T, in []byte) { - importer := NewImporter(&mockCreator{}) + importer := NewImporter(&mockCreator{}, storage.DefaultNamespace, false) if err := importer.Import(context.Background(), bytes.NewReader(in)); err != nil { t.Skip() } diff --git a/internal/ext/importer_test.go b/internal/ext/importer_test.go index 28e3572ba1..90fe75d4f9 100644 --- a/internal/ext/importer_test.go +++ b/internal/ext/importer_test.go @@ -7,10 +7,17 @@ import ( "github.com/gofrs/uuid" "github.com/stretchr/testify/assert" + "go.flipt.io/flipt/internal/storage" "go.flipt.io/flipt/rpc/flipt" ) type mockCreator struct { + getNSReqs []*flipt.GetNamespaceRequest + getNSErr error + + createNSReqs []*flipt.CreateNamespaceRequest + createNSErr error + flagReqs []*flipt.CreateFlagRequest flagErr error @@ -30,6 +37,16 @@ type mockCreator struct { distributionErr error } +func (m *mockCreator) GetNamespace(ctx context.Context, r *flipt.GetNamespaceRequest) (*flipt.Namespace, error) { + m.getNSReqs = append(m.getNSReqs, r) + return &flipt.Namespace{Key: "default"}, m.getNSErr +} + +func (m *mockCreator) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + m.createNSReqs = append(m.createNSReqs, r) + return &flipt.Namespace{Key: "default"}, m.createNSErr +} + func (m *mockCreator) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { m.flagReqs = append(m.flagReqs, r) if m.flagErr != nil { @@ -135,7 +152,7 @@ func TestImport(t *testing.T) { t.Run(tc.name, func(t *testing.T) { var ( creator = &mockCreator{} - importer = NewImporter(creator) + importer = NewImporter(creator, storage.DefaultNamespace, false) ) in, err := os.Open(tc.path) diff --git a/internal/server/evaluator.go b/internal/server/evaluator.go index 601d77c2b2..b3d07b8b90 100644 --- a/internal/server/evaluator.go +++ b/internal/server/evaluator.go @@ -22,12 +22,18 @@ import ( // Evaluate evaluates a request for a given flag and entity func (s *Server) Evaluate(ctx context.Context, r *flipt.EvaluationRequest) (*flipt.EvaluationResponse, error) { s.logger.Debug("evaluate", zap.Stringer("request", r)) + + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + resp, err := s.evaluate(ctx, r) if err != nil { return resp, err } spanAttrs := []attribute.KeyValue{ + fliptotel.AttributeNamespace.String(r.NamespaceKey), fliptotel.AttributeFlag.String(r.FlagKey), fliptotel.AttributeEntityID.String(r.EntityId), fliptotel.AttributeRequestID.String(r.RequestId), @@ -53,6 +59,11 @@ func (s *Server) Evaluate(ctx context.Context, r *flipt.EvaluationRequest) (*fli // BatchEvaluate evaluates a request for multiple flags and entities func (s *Server) BatchEvaluate(ctx context.Context, r *flipt.BatchEvaluationRequest) (*flipt.BatchEvaluationResponse, error) { s.logger.Debug("batch-evaluate", zap.Stringer("request", r)) + + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + resp, err := s.batchEvaluate(ctx, r) if err != nil { return nil, err @@ -68,9 +79,16 @@ func (s *Server) batchEvaluate(ctx context.Context, r *flipt.BatchEvaluationRequ // TODO: we should change this to a native batch query instead of looping through // each request individually - for _, flag := range r.GetRequests() { + for _, req := range r.GetRequests() { + // ensure all requests have the same namespace + if req.NamespaceKey == "" { + req.NamespaceKey = r.NamespaceKey + } else if req.NamespaceKey != r.NamespaceKey { + return &res, errs.InvalidFieldError("namespace_key", "must be the same for all requests if specified") + } + // TODO: we also need to validate each request, we should likely do this in the validation middleware - f, err := s.evaluate(ctx, flag) + f, err := s.evaluate(ctx, req) if err != nil { var errnf errs.ErrNotFound if r.GetExcludeNotFound() && errors.As(err, &errnf) { @@ -87,13 +105,17 @@ func (s *Server) batchEvaluate(ctx context.Context, r *flipt.BatchEvaluationRequ func (s *Server) evaluate(ctx context.Context, r *flipt.EvaluationRequest) (resp *flipt.EvaluationResponse, err error) { var ( - startTime = time.Now().UTC() - flagAttr = metrics.AttributeFlag.String(r.FlagKey) + startTime = time.Now().UTC() + namespaceAttr = metrics.AttributeNamespace.String(r.NamespaceKey) + flagAttr = metrics.AttributeFlag.String(r.FlagKey) ) - metrics.EvaluationsTotal.Add(ctx, 1, flagAttr) + + metrics.EvaluationsTotal.Add(ctx, 1, namespaceAttr, flagAttr) + defer func() { if err == nil { metrics.EvaluationResultsTotal.Add(ctx, 1, + namespaceAttr, flagAttr, metrics.AttributeMatch.Bool(resp.Match), metrics.AttributeSegment.String(resp.SegmentKey), @@ -101,12 +123,13 @@ func (s *Server) evaluate(ctx context.Context, r *flipt.EvaluationRequest) (resp metrics.AttributeValue.String(resp.Value), ) } else { - metrics.EvaluationErrorsTotal.Add(ctx, 1, flagAttr) + metrics.EvaluationErrorsTotal.Add(ctx, 1, namespaceAttr, flagAttr) } metrics.EvaluationLatency.Record( ctx, float64(time.Since(startTime).Nanoseconds())/1e6, + namespaceAttr, flagAttr, ) }() @@ -116,9 +139,10 @@ func (s *Server) evaluate(ctx context.Context, r *flipt.EvaluationRequest) (resp EntityId: r.EntityId, RequestContext: r.Context, FlagKey: r.FlagKey, + NamespaceKey: r.NamespaceKey, } - flag, err := s.store.GetFlag(ctx, r.FlagKey) + flag, err := s.store.GetFlag(ctx, r.NamespaceKey, r.FlagKey) if err != nil { resp.Reason = flipt.EvaluationReason_ERROR_EVALUATION_REASON @@ -136,7 +160,7 @@ func (s *Server) evaluate(ctx context.Context, r *flipt.EvaluationRequest) (resp return resp, nil } - rules, err := s.store.GetEvaluationRules(ctx, r.FlagKey) + rules, err := s.store.GetEvaluationRules(ctx, r.NamespaceKey, r.FlagKey) if err != nil { resp.Reason = flipt.EvaluationReason_ERROR_EVALUATION_REASON return resp, err diff --git a/internal/server/evaluator_test.go b/internal/server/evaluator_test.go index 47d58578c4..474e83f458 100644 --- a/internal/server/evaluator_test.go +++ b/internal/server/evaluator_test.go @@ -40,10 +40,10 @@ func TestBatchEvaluate(t *testing.T) { Key: "bar", Enabled: false, } - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "bar").Return(disabled, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) resp, err := s.BatchEvaluate(context.TODO(), &flipt.BatchEvaluationRequest{ RequestId: "12345", @@ -68,6 +68,35 @@ func TestBatchEvaluate(t *testing.T) { assert.False(t, resp.Responses[0].Match) } +func TestBatchEvaluate_NamespaceMismatch(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + ) + + _, err := s.BatchEvaluate(context.TODO(), &flipt.BatchEvaluationRequest{ + NamespaceKey: "foo", + RequestId: "12345", + ExcludeNotFound: true, + Requests: []*flipt.EvaluationRequest{ + { + NamespaceKey: "bar", + EntityId: "1", + FlagKey: "foo", + Context: map[string]string{ + "bar": "boz", + }, + }, + }, + }) + + assert.EqualError(t, err, "invalid field namespace_key: must be the same for all requests if specified") +} + func TestBatchEvaluate_FlagNotFoundExcluded(t *testing.T) { var ( store = &storeMock{} @@ -82,11 +111,11 @@ func TestBatchEvaluate_FlagNotFoundExcluded(t *testing.T) { Key: "bar", Enabled: false, } - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil) - store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag")) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "bar").Return(disabled, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag")) - store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) resp, err := s.BatchEvaluate(context.TODO(), &flipt.BatchEvaluationRequest{ RequestId: "12345", @@ -130,11 +159,11 @@ func TestBatchEvaluate_FlagNotFound(t *testing.T) { Key: "bar", Enabled: false, } - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil) - store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag")) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "bar").Return(disabled, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag")) - store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) _, err := s.BatchEvaluate(context.TODO(), &flipt.BatchEvaluationRequest{ RequestId: "12345", @@ -172,7 +201,7 @@ func TestEvaluate_FlagNotFound(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "foo")) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "foo")) resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{ EntityId: "1", @@ -198,7 +227,7 @@ func TestEvaluate_FlagDisabled(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(disabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(disabledFlag, nil) resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{ EntityId: "1", @@ -223,9 +252,9 @@ func TestEvaluate_FlagNoRules(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil) resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{ EntityId: "1", @@ -250,9 +279,9 @@ func TestEvaluate_ErrorGettingRules(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, errors.New("error getting rules!")) + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return([]*storage.EvaluationRule{}, errors.New("error getting rules!")) resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{ EntityId: "1", @@ -277,9 +306,9 @@ func TestEvaluate_RulesOutOfOrder(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -339,9 +368,9 @@ func TestEvaluate_ErrorGettingDistributions(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -387,9 +416,9 @@ func TestEvaluate_MatchAll_NoVariants_NoDistributions(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -476,9 +505,9 @@ func TestEvaluate_MatchAll_SingleVariantDistribution(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -606,9 +635,9 @@ func TestEvaluate_MatchAll_RolloutDistribution(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -727,9 +756,9 @@ func TestEvaluate_MatchAll_RolloutDistribution_MultiRule(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -802,9 +831,9 @@ func TestEvaluate_MatchAll_NoConstraints(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -913,9 +942,9 @@ func TestEvaluate_MatchAny_NoVariants_NoDistributions(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1002,9 +1031,9 @@ func TestEvaluate_MatchAny_SingleVariantDistribution(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1164,9 +1193,9 @@ func TestEvaluate_MatchAny_RolloutDistribution(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1285,9 +1314,9 @@ func TestEvaluate_MatchAny_RolloutDistribution_MultiRule(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1360,9 +1389,9 @@ func TestEvaluate_MatchAny_NoConstraints(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1471,9 +1500,9 @@ func TestEvaluate_FirstRolloutRuleIsZero(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", @@ -1571,9 +1600,9 @@ func TestEvaluate_MultipleZeroRolloutDistributions(t *testing.T) { } ) - store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil) + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(enabledFlag, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", diff --git a/internal/server/flag.go b/internal/server/flag.go index 1415682274..af1fecc94c 100644 --- a/internal/server/flag.go +++ b/internal/server/flag.go @@ -17,9 +17,15 @@ import ( // GetFlag gets a flag func (s *Server) GetFlag(ctx context.Context, r *flipt.GetFlagRequest) (*flipt.Flag, error) { s.logger.Debug("get flag", zap.Stringer("request", r)) - flag, err := s.store.GetFlag(ctx, r.Key) + + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + + flag, err := s.store.GetFlag(ctx, r.NamespaceKey, r.Key) spanAttrs := []attribute.KeyValue{ + fliptotel.AttributeNamespace.String(r.NamespaceKey), fliptotel.AttributeFlag.String(r.Key), } @@ -57,16 +63,16 @@ func (s *Server) ListFlags(ctx context.Context, r *flipt.ListFlagRequest) (*flip opts = append(opts, storage.WithOffset(uint64(r.Offset))) } - results, err := s.store.ListFlags(ctx, opts...) + results, err := s.store.ListFlags(ctx, r.NamespaceKey, opts...) if err != nil { return nil, err } - var resp flipt.FlagList - - resp.Flags = append(resp.Flags, results.Results...) + resp := flipt.FlagList{ + Flags: results.Results, + } - total, err := s.store.CountFlags(ctx) + total, err := s.store.CountFlags(ctx, r.NamespaceKey) if err != nil { return nil, err } diff --git a/internal/server/flag_test.go b/internal/server/flag_test.go index 11c797db8f..c0d9141fb9 100644 --- a/internal/server/flag_test.go +++ b/internal/server/flag_test.go @@ -24,7 +24,7 @@ func TestGetFlag(t *testing.T) { req = &flipt.GetFlagRequest{Key: "foo"} ) - store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{ + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(&flipt.Flag{ Key: req.Key, Enabled: true, }, nil) @@ -50,7 +50,7 @@ func TestListFlags_PaginationOffset(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListFlags", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListFlags", mock.Anything, mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -67,7 +67,7 @@ func TestListFlags_PaginationOffset(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountFlags", mock.Anything).Return(uint64(1), nil) + store.On("CountFlags", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListFlags(context.TODO(), &flipt.ListFlagRequest{ Offset: 10, @@ -93,7 +93,7 @@ func TestListFlags_PaginationPageToken(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListFlags", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListFlags", mock.Anything, mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -110,7 +110,7 @@ func TestListFlags_PaginationPageToken(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountFlags", mock.Anything).Return(uint64(1), nil) + store.On("CountFlags", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListFlags(context.TODO(), &flipt.ListFlagRequest{ PageToken: "Zm9v", diff --git a/internal/server/metrics/metrics.go b/internal/server/metrics/metrics.go index fc449732d5..1eee2aa645 100644 --- a/internal/server/metrics/metrics.go +++ b/internal/server/metrics/metrics.go @@ -55,9 +55,10 @@ var ( // Attributes used in evaluation metrics //nolint - AttributeMatch = attribute.Key("match") - AttributeFlag = attribute.Key("flag") - AttributeSegment = attribute.Key("segment") - AttributeReason = attribute.Key("reason") - AttributeValue = attribute.Key("value") + AttributeMatch = attribute.Key("match") + AttributeFlag = attribute.Key("flag") + AttributeSegment = attribute.Key("segment") + AttributeReason = attribute.Key("reason") + AttributeValue = attribute.Key("value") + AttributeNamespace = attribute.Key("namespace") ) diff --git a/internal/server/middleware/grpc/middleware.go b/internal/server/middleware/grpc/middleware.go index 7cbff235ef..0c4f62bb3d 100644 --- a/internal/server/middleware/grpc/middleware.go +++ b/internal/server/middleware/grpc/middleware.go @@ -173,7 +173,7 @@ func CacheUnaryInterceptor(cache cache.Cacher, logger *zap.Logger) grpc.UnarySer return resp, err case *flipt.GetFlagRequest: - key := flagCacheKey(r.GetKey()) + key := flagCacheKey(r.GetNamespaceKey(), r.GetKey()) cached, ok, err := cache.Get(ctx, key) if err != nil { @@ -218,14 +218,14 @@ func CacheUnaryInterceptor(cache cache.Cacher, logger *zap.Logger) grpc.UnarySer // need to do this assertion because the request type is not known in this block keyer := r.(flagKeyer) // delete from cache - if err := cache.Delete(ctx, flagCacheKey(keyer.GetKey())); err != nil { + if err := cache.Delete(ctx, flagCacheKey(keyer.GetNamespaceKey(), keyer.GetKey())); err != nil { logger.Error("deleting from cache", zap.Error(err)) } case *flipt.CreateVariantRequest, *flipt.UpdateVariantRequest, *flipt.DeleteVariantRequest: // need to do this assertion because the request type is not known in this block keyer := r.(variantFlagKeyger) // delete from cache - if err := cache.Delete(ctx, flagCacheKey(keyer.GetFlagKey())); err != nil { + if err := cache.Delete(ctx, flagCacheKey(keyer.GetNamespaceKey(), keyer.GetFlagKey())); err != nil { logger.Error("deleting from cache", zap.Error(err)) } } @@ -234,16 +234,29 @@ func CacheUnaryInterceptor(cache cache.Cacher, logger *zap.Logger) grpc.UnarySer } } +type namespaceKeyer interface { + GetNamespaceKey() string +} + type flagKeyer interface { + namespaceKeyer GetKey() string } type variantFlagKeyger interface { + namespaceKeyer GetFlagKey() string } -func flagCacheKey(key string) string { - k := fmt.Sprintf("f:%s", key) +func flagCacheKey(namespaceKey, key string) string { + var k string + // for backward compatibility + if namespaceKey != "" { + k = fmt.Sprintf("f:%s:%s", namespaceKey, key) + } else { + k = fmt.Sprintf("f:%s", key) + } + return fmt.Sprintf("flipt:%x", md5.Sum([]byte(k))) } @@ -253,6 +266,13 @@ func evaluationCacheKey(r *flipt.EvaluationRequest) (string, error) { return "", fmt.Errorf("marshalling req to json: %w", err) } - k := fmt.Sprintf("e:%s:%s:%s", r.GetFlagKey(), r.GetEntityId(), out) + var k string + // for backward compatibility + if r.GetNamespaceKey() != "" { + k = fmt.Sprintf("e:%s:%s:%s:%s", r.GetNamespaceKey(), r.GetFlagKey(), r.GetEntityId(), out) + } else { + k = fmt.Sprintf("e:%s:%s:%s", r.GetFlagKey(), r.GetEntityId(), out) + } + return fmt.Sprintf("flipt:%x", md5.Sum([]byte(k))), nil } diff --git a/internal/server/middleware/grpc/middleware_test.go b/internal/server/middleware/grpc/middleware_test.go index 54045ecab1..8ff1ca0535 100644 --- a/internal/server/middleware/grpc/middleware_test.go +++ b/internal/server/middleware/grpc/middleware_test.go @@ -296,12 +296,12 @@ func TestCacheUnaryInterceptor_GetFlag(t *testing.T) { cacheSpy = newCacheSpy(cache) logger = zaptest.NewLogger(t) s = server.New(logger, store) - req = &flipt.GetFlagRequest{Key: "foo"} ) - store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{ - Key: req.Key, - Enabled: true, + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(&flipt.Flag{ + NamespaceKey: storage.DefaultNamespace, + Key: "foo", + Enabled: true, }, nil) unaryInterceptor := CacheUnaryInterceptor(cacheSpy, logger) @@ -315,6 +315,7 @@ func TestCacheUnaryInterceptor_GetFlag(t *testing.T) { } for i := 0; i < 10; i++ { + req := &flipt.GetFlagRequest{Key: "foo"} got, err := unaryInterceptor(context.Background(), req, info, handler) require.NoError(t, err) assert.NotNil(t, got) @@ -555,12 +556,12 @@ func TestCacheUnaryInterceptor_Evaluate(t *testing.T) { s = server.New(logger, store) ) - store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{ + store.On("GetFlag", mock.Anything, mock.Anything, "foo").Return(&flipt.Flag{ Key: "foo", Enabled: true, }, nil) - store.On("GetEvaluationRules", mock.Anything, "foo").Return( + store.On("GetEvaluationRules", mock.Anything, mock.Anything, "foo").Return( []*storage.EvaluationRule{ { ID: "1", diff --git a/internal/server/middleware/grpc/support_test.go b/internal/server/middleware/grpc/support_test.go index 5aad068f6c..7076feb2cb 100644 --- a/internal/server/middleware/grpc/support_test.go +++ b/internal/server/middleware/grpc/support_test.go @@ -19,21 +19,51 @@ func (m *storeMock) String() string { return "mock" } -func (m *storeMock) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { +func (m *storeMock) GetNamespace(ctx context.Context, key string) (*flipt.Namespace, error) { args := m.Called(ctx, key) - return args.Get(0).(*flipt.Flag), args.Error(1) + return args.Get(0).(*flipt.Namespace), args.Error(1) } -func (m *storeMock) ListFlags(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { +func (m *storeMock) ListNamespaces(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Namespace], error) { args := m.Called(ctx, opts) - return args.Get(0).(storage.ResultSet[*flipt.Flag]), args.Error(1) + return args.Get(0).(storage.ResultSet[*flipt.Namespace]), args.Error(1) } -func (m *storeMock) CountFlags(ctx context.Context) (uint64, error) { +func (m *storeMock) CountNamespaces(ctx context.Context) (uint64, error) { args := m.Called(ctx) return args.Get(0).(uint64), args.Error(1) } +func (m *storeMock) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + args := m.Called(ctx, r) + return args.Get(0).(*flipt.Namespace), args.Error(1) +} + +func (m *storeMock) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) { + args := m.Called(ctx, r) + return args.Get(0).(*flipt.Namespace), args.Error(1) +} + +func (m *storeMock) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error { + args := m.Called(ctx, r) + return args.Error(0) +} + +func (m *storeMock) GetFlag(ctx context.Context, namespaceKey string, key string) (*flipt.Flag, error) { + args := m.Called(ctx, namespaceKey, key) + return args.Get(0).(*flipt.Flag), args.Error(1) +} + +func (m *storeMock) ListFlags(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { + args := m.Called(ctx, namespaceKey, opts) + return args.Get(0).(storage.ResultSet[*flipt.Flag]), args.Error(1) +} + +func (m *storeMock) CountFlags(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) + return args.Get(0).(uint64), args.Error(1) +} + func (m *storeMock) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { args := m.Called(ctx, r) return args.Get(0).(*flipt.Flag), args.Error(1) @@ -64,18 +94,18 @@ func (m *storeMock) DeleteVariant(ctx context.Context, r *flipt.DeleteVariantReq return args.Error(0) } -func (m *storeMock) GetSegment(ctx context.Context, key string) (*flipt.Segment, error) { - args := m.Called(ctx, key) +func (m *storeMock) GetSegment(ctx context.Context, namespaceKey string, key string) (*flipt.Segment, error) { + args := m.Called(ctx, namespaceKey, key) return args.Get(0).(*flipt.Segment), args.Error(1) } -func (m *storeMock) ListSegments(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { - args := m.Called(ctx, opts) +func (m *storeMock) ListSegments(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { + args := m.Called(ctx, namespaceKey, opts) return args.Get(0).(storage.ResultSet[*flipt.Segment]), args.Error(1) } -func (m *storeMock) CountSegments(ctx context.Context) (uint64, error) { - args := m.Called(ctx) +func (m *storeMock) CountSegments(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) return args.Get(0).(uint64), args.Error(1) } @@ -109,18 +139,18 @@ func (m *storeMock) DeleteConstraint(ctx context.Context, r *flipt.DeleteConstra return args.Error(0) } -func (m *storeMock) GetRule(ctx context.Context, id string) (*flipt.Rule, error) { - args := m.Called(ctx, id) +func (m *storeMock) GetRule(ctx context.Context, namespaceKey string, id string) (*flipt.Rule, error) { + args := m.Called(ctx, namespaceKey, id) return args.Get(0).(*flipt.Rule), args.Error(1) } -func (m *storeMock) ListRules(ctx context.Context, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { - args := m.Called(ctx, flagKey, opts) +func (m *storeMock) ListRules(ctx context.Context, namespaceKey string, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { + args := m.Called(ctx, namespaceKey, flagKey, opts) return args.Get(0).(storage.ResultSet[*flipt.Rule]), args.Error(1) } -func (m *storeMock) CountRules(ctx context.Context) (uint64, error) { - args := m.Called(ctx) +func (m *storeMock) CountRules(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) return args.Get(0).(uint64), args.Error(1) } @@ -159,8 +189,8 @@ func (m *storeMock) DeleteDistribution(ctx context.Context, r *flipt.DeleteDistr return args.Error(0) } -func (m *storeMock) GetEvaluationRules(ctx context.Context, flagKey string) ([]*storage.EvaluationRule, error) { - args := m.Called(ctx, flagKey) +func (m *storeMock) GetEvaluationRules(ctx context.Context, namespaceKey string, flagKey string) ([]*storage.EvaluationRule, error) { + args := m.Called(ctx, namespaceKey, flagKey) return args.Get(0).([]*storage.EvaluationRule), args.Error(1) } diff --git a/internal/server/namespace.go b/internal/server/namespace.go new file mode 100644 index 0000000000..c34b448440 --- /dev/null +++ b/internal/server/namespace.go @@ -0,0 +1,113 @@ +package server + +import ( + "context" + "encoding/base64" + + "go.flipt.io/flipt/errors" + "go.flipt.io/flipt/internal/storage" + flipt "go.flipt.io/flipt/rpc/flipt" + "go.uber.org/zap" + empty "google.golang.org/protobuf/types/known/emptypb" +) + +// GetNamespace gets a namespace +func (s *Server) GetNamespace(ctx context.Context, r *flipt.GetNamespaceRequest) (*flipt.Namespace, error) { + s.logger.Debug("get namespace", zap.Stringer("request", r)) + namespace, err := s.store.GetNamespace(ctx, r.Key) + s.logger.Debug("get namespace", zap.Stringer("response", namespace)) + return namespace, err +} + +// ListNamespaces lists all namespaces +func (s *Server) ListNamespaces(ctx context.Context, r *flipt.ListNamespaceRequest) (*flipt.NamespaceList, error) { + s.logger.Debug("list namespaces", zap.Stringer("request", r)) + + if r.Offset < 0 { + r.Offset = 0 + } + + opts := []storage.QueryOption{storage.WithLimit(uint64(r.Limit))} + + if r.PageToken != "" { + tok, err := base64.StdEncoding.DecodeString(r.PageToken) + if err != nil { + return nil, errors.ErrInvalidf("pageToken is not valid: %q", r.PageToken) + } + + opts = append(opts, storage.WithPageToken(string(tok))) + } else if r.Offset >= 0 { + // TODO: deprecate + opts = append(opts, storage.WithOffset(uint64(r.Offset))) + } + + results, err := s.store.ListNamespaces(ctx, opts...) + if err != nil { + return nil, err + } + + resp := flipt.NamespaceList{ + Namespaces: results.Results, + } + + total, err := s.store.CountNamespaces(ctx) + if err != nil { + return nil, err + } + + resp.TotalCount = int32(total) + resp.NextPageToken = base64.StdEncoding.EncodeToString([]byte(results.NextPageToken)) + + s.logger.Debug("list namespaces", zap.Stringer("response", &resp)) + return &resp, nil +} + +// CreateNamespace creates a namespace +func (s *Server) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + s.logger.Debug("create namespace", zap.Stringer("request", r)) + namespace, err := s.store.CreateNamespace(ctx, r) + s.logger.Debug("create namespace", zap.Stringer("response", namespace)) + return namespace, err +} + +// UpdateNamespace updates an existing namespace +func (s *Server) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) { + s.logger.Debug("update namespace", zap.Stringer("request", r)) + namespace, err := s.store.UpdateNamespace(ctx, r) + s.logger.Debug("update namespace", zap.Stringer("response", namespace)) + return namespace, err +} + +// DeleteNamespace deletes a namespace +func (s *Server) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) (*empty.Empty, error) { + s.logger.Debug("delete namespace", zap.Stringer("request", r)) + namespace, err := s.store.GetNamespace(ctx, r.Key) + if err != nil { + return nil, err + } + + // if namespace is not found then nothing to do + if namespace == nil { + return &empty.Empty{}, nil + } + + if namespace.Protected { + return nil, errors.ErrInvalidf("namespace %q is protected", r.Key) + } + + // if any flags exist under the namespace then it cannot be deleted + count, err := s.store.CountFlags(ctx, r.Key) + if err != nil { + return nil, err + } + + if count > 0 { + return nil, errors.ErrInvalidf("namespace %q cannot be deleted; flags must be deleted first", r.Key) + } + + if err := s.store.DeleteNamespace(ctx, r); err != nil { + return nil, err + } + + return &empty.Empty{}, nil +} diff --git a/internal/server/namespace_test.go b/internal/server/namespace_test.go new file mode 100644 index 0000000000..7be8c0d5ff --- /dev/null +++ b/internal/server/namespace_test.go @@ -0,0 +1,304 @@ +//nolint:goconst +package server + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "go.flipt.io/flipt/internal/storage" + flipt "go.flipt.io/flipt/rpc/flipt" + "go.uber.org/zap/zaptest" +) + +func TestGetNamespace(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.GetNamespaceRequest{Key: "foo"} + ) + + store.On("GetNamespace", mock.Anything, "foo").Return(&flipt.Namespace{ + Key: req.Key, + }, nil) + + got, err := s.GetNamespace(context.TODO(), req) + require.NoError(t, err) + + assert.NotNil(t, got) + assert.Equal(t, "foo", got.Key) +} + +func TestListNamespaces_PaginationOffset(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + ) + + defer store.AssertExpectations(t) + + params := storage.QueryParams{} + store.On("ListNamespaces", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + for _, opt := range opts { + opt(¶ms) + } + + // assert offset is provided + return params.PageToken == "" && params.Offset > 0 + })).Return( + storage.ResultSet[*flipt.Namespace]{ + Results: []*flipt.Namespace{ + { + Key: "foo", + }, + }, + NextPageToken: "bar", + }, nil) + + store.On("CountNamespaces", mock.Anything).Return(uint64(1), nil) + + got, err := s.ListNamespaces(context.TODO(), &flipt.ListNamespaceRequest{ + Offset: 10, + }) + + require.NoError(t, err) + + assert.NotEmpty(t, got.Namespaces) + assert.Equal(t, "YmFy", got.NextPageToken) + assert.Equal(t, int32(1), got.TotalCount) +} + +func TestListNamespaces_PaginationPageToken(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + ) + + defer store.AssertExpectations(t) + + params := storage.QueryParams{} + store.On("ListNamespaces", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + for _, opt := range opts { + opt(¶ms) + } + + // assert page token is preferred over offset + return params.PageToken == "foo" && params.Offset == 0 + })).Return( + storage.ResultSet[*flipt.Namespace]{ + Results: []*flipt.Namespace{ + { + Key: "foo", + }, + }, + NextPageToken: "bar", + }, nil) + + store.On("CountNamespaces", mock.Anything).Return(uint64(1), nil) + + got, err := s.ListNamespaces(context.TODO(), &flipt.ListNamespaceRequest{ + PageToken: "Zm9v", + Offset: 10, + }) + + require.NoError(t, err) + + assert.NotEmpty(t, got.Namespaces) + assert.Equal(t, "YmFy", got.NextPageToken) + assert.Equal(t, int32(1), got.TotalCount) +} + +func TestListNamespaces_PaginationInvalidPageToken(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + ) + + defer store.AssertExpectations(t) + + store.AssertNotCalled(t, "ListNamespaces") + + _, err := s.ListNamespaces(context.TODO(), &flipt.ListNamespaceRequest{ + PageToken: "Invalid string", + Offset: 10, + }) + + assert.EqualError(t, err, `pageToken is not valid: "Invalid string"`) +} + +func TestCreateNamespace(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.CreateNamespaceRequest{ + Key: "foo", + Name: "name", + Description: "desc", + } + ) + + store.On("CreateNamespace", mock.Anything, req).Return(&flipt.Namespace{ + Key: req.Key, + Name: req.Name, + Description: req.Description, + }, nil) + + got, err := s.CreateNamespace(context.TODO(), req) + require.NoError(t, err) + + assert.NotNil(t, got) +} + +func TestUpdateNamespace(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.UpdateNamespaceRequest{ + Key: "foo", + Name: "name", + Description: "desc", + } + ) + + store.On("UpdateNamespace", mock.Anything, req).Return(&flipt.Namespace{ + Key: req.Key, + Name: req.Name, + Description: req.Description, + }, nil) + + got, err := s.UpdateNamespace(context.TODO(), req) + require.NoError(t, err) + + assert.NotNil(t, got) +} + +func TestDeleteNamespace(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.DeleteNamespaceRequest{ + Key: "foo", + } + ) + + store.On("GetNamespace", mock.Anything, "foo").Return(&flipt.Namespace{ + Key: req.Key, + }, nil) + + store.On("CountFlags", mock.Anything, "foo").Return(uint64(0), nil) + + store.On("DeleteNamespace", mock.Anything, req).Return(nil) + + got, err := s.DeleteNamespace(context.TODO(), req) + require.NoError(t, err) + + assert.NotNil(t, got) +} + +func TestDeleteNamespace_NonExistent(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.DeleteNamespaceRequest{ + Key: "foo", + } + ) + + var ns *flipt.Namespace + store.On("GetNamespace", mock.Anything, "foo").Return(ns, nil) // mock library does not like nil + + store.AssertNotCalled(t, "CountFlags") + store.AssertNotCalled(t, "DeleteNamespace") + + got, err := s.DeleteNamespace(context.TODO(), req) + require.NoError(t, err) + + assert.NotNil(t, got) +} + +func TestDeleteNamespace_Protected(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.DeleteNamespaceRequest{ + Key: "foo", + } + ) + + store.On("GetNamespace", mock.Anything, "foo").Return(&flipt.Namespace{ + Key: req.Key, + Protected: true, + }, nil) + + store.On("CountFlags", mock.Anything, "foo").Return(uint64(0), nil) + + store.AssertNotCalled(t, "DeleteNamespace") + + got, err := s.DeleteNamespace(context.TODO(), req) + assert.EqualError(t, err, "namespace \"foo\" is protected") + assert.Nil(t, got) +} + +func TestDeleteNamespace_HasFlags(t *testing.T) { + var ( + store = &storeMock{} + logger = zaptest.NewLogger(t) + s = &Server{ + logger: logger, + store: store, + } + req = &flipt.DeleteNamespaceRequest{ + Key: "foo", + } + ) + + store.On("GetNamespace", mock.Anything, "foo").Return(&flipt.Namespace{ + Key: req.Key, + }, nil) + + store.On("CountFlags", mock.Anything, "foo").Return(uint64(1), nil) + + store.AssertNotCalled(t, "DeleteNamespace") + + got, err := s.DeleteNamespace(context.TODO(), req) + assert.EqualError(t, err, "namespace \"foo\" cannot be deleted; flags must be deleted first") + assert.Nil(t, got) +} diff --git a/internal/server/otel/attributes.go b/internal/server/otel/attributes.go index 4a5785947e..7e3ffd8934 100644 --- a/internal/server/otel/attributes.go +++ b/internal/server/otel/attributes.go @@ -5,6 +5,7 @@ import "go.opentelemetry.io/otel/attribute" var ( AttributeMatch = attribute.Key("flipt.match") AttributeFlag = attribute.Key("flipt.flag") + AttributeNamespace = attribute.Key("flipt.namespace") AttributeFlagEnabled = attribute.Key("flipt.flag_enabled") AttributeSegment = attribute.Key("flipt.segment") AttributeReason = attribute.Key("flipt.reason") diff --git a/internal/server/rule.go b/internal/server/rule.go index fde63a3fba..9ac3cee09e 100644 --- a/internal/server/rule.go +++ b/internal/server/rule.go @@ -14,7 +14,7 @@ import ( // GetRule gets a rule func (s *Server) GetRule(ctx context.Context, r *flipt.GetRuleRequest) (*flipt.Rule, error) { s.logger.Debug("get rule", zap.Stringer("request", r)) - rule, err := s.store.GetRule(ctx, r.Id) + rule, err := s.store.GetRule(ctx, r.NamespaceKey, r.Id) s.logger.Debug("get rule", zap.Stringer("response", rule)) return rule, err } @@ -41,16 +41,16 @@ func (s *Server) ListRules(ctx context.Context, r *flipt.ListRuleRequest) (*flip opts = append(opts, storage.WithOffset(uint64(r.Offset))) } - results, err := s.store.ListRules(ctx, r.FlagKey, opts...) + results, err := s.store.ListRules(ctx, r.NamespaceKey, r.FlagKey, opts...) if err != nil { return nil, err } - var resp flipt.RuleList - - resp.Rules = append(resp.Rules, results.Results...) + resp := flipt.RuleList{ + Rules: results.Results, + } - total, err := s.store.CountRules(ctx) + total, err := s.store.CountRules(ctx, r.NamespaceKey) if err != nil { return nil, err } diff --git a/internal/server/rule_test.go b/internal/server/rule_test.go index 8a4372bb1e..9c150f27f4 100644 --- a/internal/server/rule_test.go +++ b/internal/server/rule_test.go @@ -24,7 +24,7 @@ func TestGetRule(t *testing.T) { req = &flipt.GetRuleRequest{Id: "id", FlagKey: "flagKey"} ) - store.On("GetRule", mock.Anything, "id").Return(&flipt.Rule{ + store.On("GetRule", mock.Anything, mock.Anything, "id").Return(&flipt.Rule{ Id: "1", }, nil) @@ -47,7 +47,7 @@ func TestListRules_PaginationOffset(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListRules", mock.Anything, "flagKey", mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListRules", mock.Anything, mock.Anything, "flagKey", mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -64,7 +64,7 @@ func TestListRules_PaginationOffset(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountRules", mock.Anything).Return(uint64(1), nil) + store.On("CountRules", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListRules(context.TODO(), &flipt.ListRuleRequest{FlagKey: "flagKey", Offset: 10, @@ -90,7 +90,7 @@ func TestListRules_PaginationPageToken(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListRules", mock.Anything, "flagKey", mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListRules", mock.Anything, mock.Anything, "flagKey", mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -107,7 +107,7 @@ func TestListRules_PaginationPageToken(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountRules", mock.Anything).Return(uint64(1), nil) + store.On("CountRules", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListRules(context.TODO(), &flipt.ListRuleRequest{FlagKey: "flagKey", PageToken: "Zm9v", diff --git a/internal/server/segment.go b/internal/server/segment.go index 9fcae0249c..aed17196eb 100644 --- a/internal/server/segment.go +++ b/internal/server/segment.go @@ -14,7 +14,7 @@ import ( // GetSegment gets a segment func (s *Server) GetSegment(ctx context.Context, r *flipt.GetSegmentRequest) (*flipt.Segment, error) { s.logger.Debug("get segment", zap.Stringer("request", r)) - segment, err := s.store.GetSegment(ctx, r.Key) + segment, err := s.store.GetSegment(ctx, r.NamespaceKey, r.Key) s.logger.Debug("get segment", zap.Stringer("response", segment)) return segment, err } @@ -41,16 +41,16 @@ func (s *Server) ListSegments(ctx context.Context, r *flipt.ListSegmentRequest) opts = append(opts, storage.WithOffset(uint64(r.Offset))) } - results, err := s.store.ListSegments(ctx, opts...) + results, err := s.store.ListSegments(ctx, r.NamespaceKey, opts...) if err != nil { return nil, err } - var resp flipt.SegmentList - - resp.Segments = append(resp.Segments, results.Results...) + resp := flipt.SegmentList{ + Segments: results.Results, + } - total, err := s.store.CountSegments(ctx) + total, err := s.store.CountSegments(ctx, r.NamespaceKey) if err != nil { return nil, err } diff --git a/internal/server/segment_test.go b/internal/server/segment_test.go index 756c4aceba..5ba773a2d5 100644 --- a/internal/server/segment_test.go +++ b/internal/server/segment_test.go @@ -24,7 +24,7 @@ func TestGetSegment(t *testing.T) { req = &flipt.GetSegmentRequest{Key: "foo"} ) - store.On("GetSegment", mock.Anything, "foo").Return(&flipt.Segment{ + store.On("GetSegment", mock.Anything, mock.Anything, "foo").Return(&flipt.Segment{ Key: req.Key, }, nil) @@ -47,7 +47,7 @@ func TestListSegments_PaginationOffset(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListSegments", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListSegments", mock.Anything, mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -64,7 +64,7 @@ func TestListSegments_PaginationOffset(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountSegments", mock.Anything).Return(uint64(1), nil) + store.On("CountSegments", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListSegments(context.TODO(), &flipt.ListSegmentRequest{ Offset: 10, @@ -90,7 +90,7 @@ func TestListSegments_PaginationPageToken(t *testing.T) { defer store.AssertExpectations(t) params := storage.QueryParams{} - store.On("ListSegments", mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { + store.On("ListSegments", mock.Anything, mock.Anything, mock.MatchedBy(func(opts []storage.QueryOption) bool { for _, opt := range opts { opt(¶ms) } @@ -107,7 +107,7 @@ func TestListSegments_PaginationPageToken(t *testing.T) { NextPageToken: "bar", }, nil) - store.On("CountSegments", mock.Anything).Return(uint64(1), nil) + store.On("CountSegments", mock.Anything, mock.Anything).Return(uint64(1), nil) got, err := s.ListSegments(context.TODO(), &flipt.ListSegmentRequest{ PageToken: "Zm9v", diff --git a/internal/server/support_test.go b/internal/server/support_test.go index 7f2fde348d..9895d8f178 100644 --- a/internal/server/support_test.go +++ b/internal/server/support_test.go @@ -18,21 +18,51 @@ func (m *storeMock) String() string { return "mock" } -func (m *storeMock) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { +func (m *storeMock) GetNamespace(ctx context.Context, key string) (*flipt.Namespace, error) { args := m.Called(ctx, key) - return args.Get(0).(*flipt.Flag), args.Error(1) + return args.Get(0).(*flipt.Namespace), args.Error(1) } -func (m *storeMock) ListFlags(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { +func (m *storeMock) ListNamespaces(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Namespace], error) { args := m.Called(ctx, opts) - return args.Get(0).(storage.ResultSet[*flipt.Flag]), args.Error(1) + return args.Get(0).(storage.ResultSet[*flipt.Namespace]), args.Error(1) } -func (m *storeMock) CountFlags(ctx context.Context) (uint64, error) { +func (m *storeMock) CountNamespaces(ctx context.Context) (uint64, error) { args := m.Called(ctx) return args.Get(0).(uint64), args.Error(1) } +func (m *storeMock) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + args := m.Called(ctx, r) + return args.Get(0).(*flipt.Namespace), args.Error(1) +} + +func (m *storeMock) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) { + args := m.Called(ctx, r) + return args.Get(0).(*flipt.Namespace), args.Error(1) +} + +func (m *storeMock) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error { + args := m.Called(ctx, r) + return args.Error(0) +} + +func (m *storeMock) GetFlag(ctx context.Context, namespaceKey, key string) (*flipt.Flag, error) { + args := m.Called(ctx, namespaceKey, key) + return args.Get(0).(*flipt.Flag), args.Error(1) +} + +func (m *storeMock) ListFlags(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { + args := m.Called(ctx, namespaceKey, opts) + return args.Get(0).(storage.ResultSet[*flipt.Flag]), args.Error(1) +} + +func (m *storeMock) CountFlags(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) + return args.Get(0).(uint64), args.Error(1) +} + func (m *storeMock) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { args := m.Called(ctx, r) return args.Get(0).(*flipt.Flag), args.Error(1) @@ -63,18 +93,18 @@ func (m *storeMock) DeleteVariant(ctx context.Context, r *flipt.DeleteVariantReq return args.Error(0) } -func (m *storeMock) GetSegment(ctx context.Context, key string) (*flipt.Segment, error) { - args := m.Called(ctx, key) +func (m *storeMock) GetSegment(ctx context.Context, namespaceKey string, key string) (*flipt.Segment, error) { + args := m.Called(ctx, namespaceKey, key) return args.Get(0).(*flipt.Segment), args.Error(1) } -func (m *storeMock) ListSegments(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { - args := m.Called(ctx, opts) +func (m *storeMock) ListSegments(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { + args := m.Called(ctx, namespaceKey, opts) return args.Get(0).(storage.ResultSet[*flipt.Segment]), args.Error(1) } -func (m *storeMock) CountSegments(ctx context.Context) (uint64, error) { - args := m.Called(ctx) +func (m *storeMock) CountSegments(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) return args.Get(0).(uint64), args.Error(1) } @@ -108,18 +138,18 @@ func (m *storeMock) DeleteConstraint(ctx context.Context, r *flipt.DeleteConstra return args.Error(0) } -func (m *storeMock) GetRule(ctx context.Context, id string) (*flipt.Rule, error) { - args := m.Called(ctx, id) +func (m *storeMock) GetRule(ctx context.Context, namespaceKey string, id string) (*flipt.Rule, error) { + args := m.Called(ctx, namespaceKey, id) return args.Get(0).(*flipt.Rule), args.Error(1) } -func (m *storeMock) ListRules(ctx context.Context, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { - args := m.Called(ctx, flagKey, opts) +func (m *storeMock) ListRules(ctx context.Context, namespaceKey string, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { + args := m.Called(ctx, namespaceKey, flagKey, opts) return args.Get(0).(storage.ResultSet[*flipt.Rule]), args.Error(1) } -func (m *storeMock) CountRules(ctx context.Context) (uint64, error) { - args := m.Called(ctx) +func (m *storeMock) CountRules(ctx context.Context, namespaceKey string) (uint64, error) { + args := m.Called(ctx, namespaceKey) return args.Get(0).(uint64), args.Error(1) } @@ -158,8 +188,8 @@ func (m *storeMock) DeleteDistribution(ctx context.Context, r *flipt.DeleteDistr return args.Error(0) } -func (m *storeMock) GetEvaluationRules(ctx context.Context, flagKey string) ([]*storage.EvaluationRule, error) { - args := m.Called(ctx, flagKey) +func (m *storeMock) GetEvaluationRules(ctx context.Context, namespaceKey string, flagKey string) ([]*storage.EvaluationRule, error) { + args := m.Called(ctx, namespaceKey, flagKey) return args.Get(0).([]*storage.EvaluationRule), args.Error(1) } diff --git a/internal/storage/sql/common/evaluation.go b/internal/storage/sql/common/evaluation.go index dc864ed0fe..91877f8794 100644 --- a/internal/storage/sql/common/evaluation.go +++ b/internal/storage/sql/common/evaluation.go @@ -9,13 +9,16 @@ import ( flipt "go.flipt.io/flipt/rpc/flipt" ) -func (s *Store) GetEvaluationRules(ctx context.Context, flagKey string) ([]*storage.EvaluationRule, error) { +func (s *Store) GetEvaluationRules(ctx context.Context, namespaceKey, flagKey string) ([]*storage.EvaluationRule, error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } // get all rules for flag with their constraints if any - rows, err := s.builder.Select("r.id, r.flag_key, r.segment_key, s.match_type, r.\"rank\", c.id, c.type, c.property, c.operator, c.value"). + rows, err := s.builder.Select("r.id, r.namespace_key, r.flag_key, r.segment_key, s.match_type, r.\"rank\", c.id, c.type, c.property, c.operator, c.value"). From("rules r"). - Join("segments s on (r.segment_key = s.\"key\")"). - LeftJoin("constraints c ON (s.\"key\" = c.segment_key)"). - Where(sq.Eq{"r.flag_key": flagKey}). + Join("segments s ON (r.segment_key = s.\"key\" AND r.namespace_key = s.namespace_key)"). + LeftJoin("constraints c ON (s.\"key\" = c.segment_key AND s.namespace_key = c.namespace_key)"). + Where(sq.And{sq.Eq{"r.flag_key": flagKey}, sq.Eq{"r.namespace_key": namespaceKey}}). OrderBy("r.\"rank\" ASC"). GroupBy("r.id, c.id, s.match_type"). QueryContext(ctx) @@ -42,6 +45,7 @@ func (s *Store) GetEvaluationRules(ctx context.Context, flagKey string) ([]*stor if err := rows.Scan( &tempRule.ID, + &tempRule.NamespaceKey, &tempRule.FlagKey, &tempRule.SegmentKey, &tempRule.SegmentMatchType, @@ -70,6 +74,7 @@ func (s *Store) GetEvaluationRules(ctx context.Context, flagKey string) ([]*stor // haven't seen this rule before newRule := &storage.EvaluationRule{ ID: tempRule.ID, + NamespaceKey: tempRule.NamespaceKey, FlagKey: tempRule.FlagKey, SegmentKey: tempRule.SegmentKey, SegmentMatchType: tempRule.SegmentMatchType, diff --git a/internal/storage/sql/common/flag.go b/internal/storage/sql/common/flag.go index 354ed26f06..13151c208b 100644 --- a/internal/storage/sql/common/flag.go +++ b/internal/storage/sql/common/flag.go @@ -34,27 +34,34 @@ func emptyAsNil(str string) *string { } // GetFlag gets a flag with variants by key -func (s *Store) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { +func (s *Store) GetFlag(ctx context.Context, namespaceKey, key string) (*flipt.Flag, error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + var ( createdAt fliptsql.Timestamp updatedAt fliptsql.Timestamp flag = &flipt.Flag{} - err = s.builder.Select("\"key\", name, description, enabled, created_at, updated_at"). + err = s.builder.Select("namespace_key, \"key\", name, description, enabled, created_at, updated_at"). From("flags"). - Where(sq.Eq{"\"key\"": key}).QueryRowContext(ctx).Scan( - &flag.Key, - &flag.Name, - &flag.Description, - &flag.Enabled, - &createdAt, - &updatedAt) + Where(sq.And{sq.Eq{"namespace_key": namespaceKey}, sq.Eq{"\"key\"": key}}). + QueryRowContext(ctx). + Scan( + &flag.NamespaceKey, + &flag.Key, + &flag.Name, + &flag.Description, + &flag.Enabled, + &createdAt, + &updatedAt) ) if err != nil { if errors.Is(err, sql.ErrNoRows) { - return nil, errs.ErrNotFoundf("flag %q", key) + return nil, errs.ErrNotFoundf(`flag "%s/%s"`, namespaceKey, key) } return nil, err @@ -63,9 +70,9 @@ func (s *Store) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { flag.CreatedAt = createdAt.Timestamp flag.UpdatedAt = updatedAt.Timestamp - query := s.builder.Select("id, flag_key, \"key\", name, description, attachment, created_at, updated_at"). + query := s.builder.Select("id, namespace_key, flag_key, \"key\", name, description, attachment, created_at, updated_at"). From("variants"). - Where(sq.Eq{"flag_key": flag.Key}). + Where(sq.And{sq.Eq{"namespace_key": flag.NamespaceKey}, sq.Eq{"flag_key": flag.Key}}). OrderBy("created_at ASC") rows, err := query.QueryContext(ctx) @@ -88,6 +95,7 @@ func (s *Store) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { if err := rows.Scan( &variant.Id, + &variant.NamespaceKey, &variant.FlagKey, &variant.Key, &variant.Name, @@ -115,18 +123,23 @@ func (s *Store) GetFlag(ctx context.Context, key string) (*flipt.Flag, error) { } type optionalVariant struct { - Id sql.NullString - Key sql.NullString - FlagKey sql.NullString - Name sql.NullString - Description sql.NullString - Attachment sql.NullString - CreatedAt fliptsql.NullableTimestamp - UpdatedAt fliptsql.NullableTimestamp + Id sql.NullString + NamespaceKey sql.NullString + Key sql.NullString + FlagKey sql.NullString + Name sql.NullString + Description sql.NullString + Attachment sql.NullString + CreatedAt fliptsql.NullableTimestamp + UpdatedAt fliptsql.NullableTimestamp } // ListFlags lists all flags with variants -func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { +func (s *Store) ListFlags(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Flag], error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + params := &storage.QueryParams{} for _, opt := range opts { @@ -137,9 +150,10 @@ func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (sto flags []*flipt.Flag results = storage.ResultSet[*flipt.Flag]{} - query = s.builder.Select("f.key, f.name, f.description, f.enabled, f.created_at, f.updated_at, v.id, v.key, v.flag_key, v.name, v.description, v.attachment, v.created_at, v.updated_at"). + query = s.builder.Select("f.namespace_key, f.key, f.name, f.description, f.enabled, f.created_at, f.updated_at, v.id, v.namespace_key, v.key, v.flag_key, v.name, v.description, v.attachment, v.created_at, v.updated_at"). From("flags f"). - LeftJoin("variants v ON v.flag_key = f.key"). + Where(sq.Eq{"f.namespace_key": namespaceKey}). + LeftJoin("variants v ON v.flag_key = f.key AND v.namespace_key = f.namespace_key"). OrderBy(fmt.Sprintf("f.created_at %s", params.Order)) ) @@ -187,6 +201,7 @@ func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (sto ) if err := rows.Scan( + &flag.NamespaceKey, &flag.Key, &flag.Name, &flag.Description, @@ -194,6 +209,7 @@ func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (sto &fCreatedAt, &fUpdatedAt, &v.Id, + &v.NamespaceKey, &v.Key, &v.FlagKey, &v.Name, @@ -217,6 +233,9 @@ func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (sto variant := &flipt.Variant{ Id: v.Id.String, } + if v.NamespaceKey.Valid { + variant.NamespaceKey = v.NamespaceKey.String + } if v.Key.Valid { variant.Key = v.Key.String } @@ -281,10 +300,18 @@ func (s *Store) ListFlags(ctx context.Context, opts ...storage.QueryOption) (sto } // CountFlags counts all flags -func (s *Store) CountFlags(ctx context.Context) (uint64, error) { +func (s *Store) CountFlags(ctx context.Context, namespaceKey string) (uint64, error) { var count uint64 - if err := s.builder.Select("COUNT(*)").From("flags").QueryRowContext(ctx).Scan(&count); err != nil { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + + if err := s.builder.Select("COUNT(*)"). + From("flags"). + Where(sq.Eq{"namespace_key": namespaceKey}). + QueryRowContext(ctx). + Scan(&count); err != nil { return 0, err } @@ -293,21 +320,27 @@ func (s *Store) CountFlags(ctx context.Context) (uint64, error) { // CreateFlag creates a flag func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( now = timestamppb.Now() flag = &flipt.Flag{ - Key: r.Key, - Name: r.Name, - Description: r.Description, - Enabled: r.Enabled, - CreatedAt: now, - UpdatedAt: now, + NamespaceKey: r.NamespaceKey, + Key: r.Key, + Name: r.Name, + Description: r.Description, + Enabled: r.Enabled, + CreatedAt: now, + UpdatedAt: now, } ) if _, err := s.builder.Insert("flags"). - Columns("\"key\"", "name", "description", "enabled", "created_at", "updated_at"). + Columns("namespace_key", "\"key\"", "name", "description", "enabled", "created_at", "updated_at"). Values( + flag.NamespaceKey, flag.Key, flag.Name, flag.Description, @@ -324,12 +357,16 @@ func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*fl // UpdateFlag updates an existing flag func (s *Store) UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*flipt.Flag, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + query := s.builder.Update("flags"). Set("name", r.Name). Set("description", r.Description). Set("enabled", r.Enabled). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). - Where(sq.Eq{"\"key\"": r.Key}) + Where(sq.And{sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"\"key\"": r.Key}}) res, err := query.ExecContext(ctx) if err != nil { @@ -342,16 +379,20 @@ func (s *Store) UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*fl } if count != 1 { - return nil, errs.ErrNotFoundf("flag %q", r.Key) + return nil, errs.ErrNotFoundf(`flag "%s/%s"`, r.NamespaceKey, r.Key) } - return s.GetFlag(ctx, r.Key) + return s.GetFlag(ctx, r.NamespaceKey, r.Key) } // DeleteFlag deletes a flag func (s *Store) DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + _, err := s.builder.Delete("flags"). - Where(sq.Eq{"\"key\"": r.Key}). + Where(sq.And{sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"\"key\"": r.Key}}). ExecContext(ctx) return err @@ -359,25 +400,31 @@ func (s *Store) DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) erro // CreateVariant creates a variant func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest) (*flipt.Variant, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( now = timestamppb.Now() v = &flipt.Variant{ - Id: uuid.Must(uuid.NewV4()).String(), - FlagKey: r.FlagKey, - Key: r.Key, - Name: r.Name, - Description: r.Description, - Attachment: r.Attachment, - CreatedAt: now, - UpdatedAt: now, + Id: uuid.Must(uuid.NewV4()).String(), + NamespaceKey: r.NamespaceKey, + FlagKey: r.FlagKey, + Key: r.Key, + Name: r.Name, + Description: r.Description, + Attachment: r.Attachment, + CreatedAt: now, + UpdatedAt: now, } ) attachment := emptyAsNil(r.Attachment) if _, err := s.builder.Insert("variants"). - Columns("id", "flag_key", "\"key\"", "name", "description", "attachment", "created_at", "updated_at"). + Columns("id", "namespace_key", "flag_key", "\"key\"", "name", "description", "attachment", "created_at", "updated_at"). Values( v.Id, + v.NamespaceKey, v.FlagKey, v.Key, v.Name, @@ -403,13 +450,19 @@ func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest // UpdateVariant updates an existing variant func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest) (*flipt.Variant, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + + whereClause := sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}, sq.Eq{"namespace_key": r.NamespaceKey}} + query := s.builder.Update("variants"). Set("\"key\"", r.Key). Set("name", r.Name). Set("description", r.Description). Set("attachment", emptyAsNil(r.Attachment)). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}}) + Where(whereClause) res, err := query.ExecContext(ctx) if err != nil { @@ -433,11 +486,11 @@ func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest v = &flipt.Variant{} ) - if err := s.builder.Select("id, \"key\", flag_key, name, description, attachment, created_at, updated_at"). + if err := s.builder.Select("id, namespace_key, \"key\", flag_key, name, description, attachment, created_at, updated_at"). From("variants"). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}}). + Where(whereClause). QueryRowContext(ctx). - Scan(&v.Id, &v.Key, &v.FlagKey, &v.Name, &v.Description, &attachment, &createdAt, &updatedAt); err != nil { + Scan(&v.Id, &v.NamespaceKey, &v.Key, &v.FlagKey, &v.Name, &v.Description, &attachment, &createdAt, &updatedAt); err != nil { return nil, err } @@ -456,8 +509,12 @@ func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest // DeleteVariant deletes a variant func (s *Store) DeleteVariant(ctx context.Context, r *flipt.DeleteVariantRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + _, err := s.builder.Delete("variants"). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}}). + Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}, sq.Eq{"namespace_key": r.NamespaceKey}}). ExecContext(ctx) return err diff --git a/internal/storage/sql/common/namespace.go b/internal/storage/sql/common/namespace.go new file mode 100644 index 0000000000..9786a4acb0 --- /dev/null +++ b/internal/storage/sql/common/namespace.go @@ -0,0 +1,223 @@ +package common + +import ( + "context" + "database/sql" + "encoding/json" + "errors" + "fmt" + + sq "github.com/Masterminds/squirrel" + errs "go.flipt.io/flipt/errors" + "go.flipt.io/flipt/internal/storage" + fliptsql "go.flipt.io/flipt/internal/storage/sql" + flipt "go.flipt.io/flipt/rpc/flipt" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func (s *Store) GetNamespace(ctx context.Context, key string) (*flipt.Namespace, error) { + var ( + createdAt fliptsql.Timestamp + updatedAt fliptsql.Timestamp + + namespace = &flipt.Namespace{} + + err = s.builder.Select("\"key\", name, description, protected, created_at, updated_at"). + From("namespaces"). + Where(sq.Eq{"\"key\"": key}). + QueryRowContext(ctx). + Scan( + &namespace.Key, + &namespace.Name, + &namespace.Description, + &namespace.Protected, + &createdAt, + &updatedAt) + ) + + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, errs.ErrNotFoundf(`namespace "%s"`, key) + } + + return nil, err + } + + namespace.CreatedAt = createdAt.Timestamp + namespace.UpdatedAt = updatedAt.Timestamp + + return namespace, nil +} + +func (s *Store) ListNamespaces(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Namespace], error) { + params := &storage.QueryParams{} + + for _, opt := range opts { + opt(params) + } + + var ( + namespaces []*flipt.Namespace + results = storage.ResultSet[*flipt.Namespace]{} + + query = s.builder.Select("\"key\", name, description, protected, created_at, updated_at"). + From("namespaces"). + OrderBy(fmt.Sprintf("created_at %s", params.Order)) + ) + + if params.Limit > 0 { + query = query.Limit(params.Limit + 1) + } + + var offset uint64 + + if params.PageToken != "" { + var token PageToken + + if err := json.Unmarshal([]byte(params.PageToken), &token); err != nil { + return results, fmt.Errorf("decoding page token %w", err) + } + + offset = token.Offset + query = query.Offset(offset) + } else if params.Offset > 0 { + offset = params.Offset + query = query.Offset(offset) + } + + rows, err := query.QueryContext(ctx) + if err != nil { + return results, err + } + + defer func() { + if cerr := rows.Close(); cerr != nil && err == nil { + err = cerr + } + }() + + for rows.Next() { + var ( + namespace = &flipt.Namespace{} + + createdAt fliptsql.Timestamp + updatedAt fliptsql.Timestamp + ) + + if err := rows.Scan( + &namespace.Key, + &namespace.Name, + &namespace.Description, + &namespace.Protected, + &createdAt, + &updatedAt, + ); err != nil { + return results, err + } + + namespace.CreatedAt = createdAt.Timestamp + namespace.UpdatedAt = updatedAt.Timestamp + + namespaces = append(namespaces, namespace) + } + + if err := rows.Err(); err != nil { + return results, err + } + + if err := rows.Close(); err != nil { + return results, err + } + + var next *flipt.Namespace + + if len(namespaces) > int(params.Limit) && params.Limit > 0 { + next = namespaces[len(namespaces)-1] + namespaces = namespaces[:params.Limit] + } + + results.Results = namespaces + + if next != nil { + out, err := json.Marshal(PageToken{Key: next.Key, Offset: offset + uint64(len(namespaces))}) + if err != nil { + return results, fmt.Errorf("encoding page token %w", err) + } + results.NextPageToken = string(out) + } + + return results, nil +} + +func (s *Store) CountNamespaces(ctx context.Context) (uint64, error) { + var count uint64 + + if err := s.builder.Select("COUNT(*)"). + From("namespaces"). + QueryRowContext(ctx). + Scan(&count); err != nil { + return 0, err + } + + return count, nil +} + +func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + var ( + now = timestamppb.Now() + namespace = &flipt.Namespace{ + Key: r.Key, + Name: r.Name, + Description: r.Description, + CreatedAt: now, + UpdatedAt: now, + } + ) + + if _, err := s.builder.Insert("namespaces"). + Columns("\"key\"", "name", "description", "created_at", "updated_at"). + Values( + namespace.Key, + namespace.Name, + namespace.Description, + &fliptsql.Timestamp{Timestamp: namespace.CreatedAt}, + &fliptsql.Timestamp{Timestamp: namespace.UpdatedAt}, + ). + ExecContext(ctx); err != nil { + return nil, err + } + + return namespace, nil +} + +func (s *Store) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) { + query := s.builder.Update("namespaces"). + Set("name", r.Name). + Set("description", r.Description). + Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). + Where(sq.Eq{"\"key\"": r.Key}) + + res, err := query.ExecContext(ctx) + if err != nil { + return nil, err + } + + count, err := res.RowsAffected() + if err != nil { + return nil, err + } + + if count != 1 { + return nil, errs.ErrNotFoundf(`namespace "%s"`, r.Key) + } + + return s.GetNamespace(ctx, r.Key) +} + +func (s *Store) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error { + _, err := s.builder.Delete("namespaces"). + Where(sq.Eq{"\"key\"": r.Key}). + ExecContext(ctx) + + return err +} diff --git a/internal/storage/sql/common/rule.go b/internal/storage/sql/common/rule.go index 35b0144b20..2b0e1ddf0e 100644 --- a/internal/storage/sql/common/rule.go +++ b/internal/storage/sql/common/rule.go @@ -18,23 +18,27 @@ import ( ) // GetRule gets an individual rule with distributions by ID -func (s *Store) GetRule(ctx context.Context, id string) (*flipt.Rule, error) { +func (s *Store) GetRule(ctx context.Context, namespaceKey, id string) (*flipt.Rule, error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + var ( createdAt fliptsql.Timestamp updatedAt fliptsql.Timestamp rule = &flipt.Rule{} - err = s.builder.Select("id, flag_key, segment_key, \"rank\", created_at, updated_at"). + err = s.builder.Select("id, namespace_key, flag_key, segment_key, \"rank\", created_at, updated_at"). From("rules"). - Where(sq.And{sq.Eq{"id": id}}). + Where(sq.And{sq.Eq{"id": id}, sq.Eq{"namespace_key": namespaceKey}}). QueryRowContext(ctx). - Scan(&rule.Id, &rule.FlagKey, &rule.SegmentKey, &rule.Rank, &createdAt, &updatedAt) + Scan(&rule.Id, &rule.NamespaceKey, &rule.FlagKey, &rule.SegmentKey, &rule.Rank, &createdAt, &updatedAt) ) if err != nil { if errors.Is(err, sql.ErrNoRows) { - return nil, errs.ErrNotFoundf("rule %q", id) + return nil, errs.ErrNotFoundf(`rule "%s/%s"`, namespaceKey, id) } return nil, err @@ -94,7 +98,11 @@ type optionalDistribution struct { } // ListRules gets all rules for a flag with distributions -func (s *Store) ListRules(ctx context.Context, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { +func (s *Store) ListRules(ctx context.Context, namespaceKey, flagKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Rule], error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + params := &storage.QueryParams{} for _, opt := range opts { @@ -105,10 +113,10 @@ func (s *Store) ListRules(ctx context.Context, flagKey string, opts ...storage.Q rules []*flipt.Rule results = storage.ResultSet[*flipt.Rule]{} - query = s.builder.Select("r.id, r.flag_key, r.segment_key, r.rank, r.created_at, r.updated_at, d.id, d.rule_id, d.variant_id, d.rollout, d.created_at, d.updated_at"). + query = s.builder.Select("r.id, r.namespace_key, r.flag_key, r.segment_key, r.rank, r.created_at, r.updated_at, d.id, d.rule_id, d.variant_id, d.rollout, d.created_at, d.updated_at"). From("rules r"). LeftJoin("distributions d ON d.rule_id = r.id"). - Where(sq.Eq{"r.flag_key": flagKey}). + Where(sq.And{sq.Eq{"r.flag_key": flagKey}, sq.Eq{"r.namespace_key": namespaceKey}}). OrderBy(fmt.Sprintf("r.rank %s", params.Order)) ) @@ -157,6 +165,7 @@ func (s *Store) ListRules(ctx context.Context, flagKey string, opts ...storage.Q if err := rows.Scan( &rule.Id, + &rule.NamespaceKey, &rule.FlagKey, &rule.SegmentKey, &rule.Rank, @@ -238,10 +247,18 @@ func (s *Store) ListRules(ctx context.Context, flagKey string, opts ...storage.Q } // CountRules counts all rules -func (s *Store) CountRules(ctx context.Context) (uint64, error) { +func (s *Store) CountRules(ctx context.Context, namespaceKey string) (uint64, error) { var count uint64 - if err := s.builder.Select("COUNT(*)").From("rules").QueryRowContext(ctx).Scan(&count); err != nil { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + + if err := s.builder.Select("COUNT(*)"). + From("rules"). + Where(sq.Eq{"namespace_key": namespaceKey}). + QueryRowContext(ctx). + Scan(&count); err != nil { return 0, err } @@ -250,23 +267,29 @@ func (s *Store) CountRules(ctx context.Context) (uint64, error) { // CreateRule creates a rule func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*flipt.Rule, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( now = timestamppb.Now() rule = &flipt.Rule{ - Id: uuid.Must(uuid.NewV4()).String(), - FlagKey: r.FlagKey, - SegmentKey: r.SegmentKey, - Rank: r.Rank, - CreatedAt: now, - UpdatedAt: now, + Id: uuid.Must(uuid.NewV4()).String(), + NamespaceKey: r.NamespaceKey, + FlagKey: r.FlagKey, + SegmentKey: r.SegmentKey, + Rank: r.Rank, + CreatedAt: now, + UpdatedAt: now, } ) if _, err := s.builder. Insert("rules"). - Columns("id", "flag_key", "segment_key", "\"rank\"", "created_at", "updated_at"). + Columns("id", "namespace_key", "flag_key", "segment_key", "\"rank\"", "created_at", "updated_at"). Values( rule.Id, + rule.NamespaceKey, rule.FlagKey, rule.SegmentKey, rule.Rank, @@ -281,10 +304,14 @@ func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*fl // UpdateRule updates an existing rule func (s *Store) UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*flipt.Rule, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + query := s.builder.Update("rules"). Set("segment_key", r.SegmentKey). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}}) + Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"flag_key": r.FlagKey}}) res, err := query.ExecContext(ctx) if err != nil { @@ -297,14 +324,18 @@ func (s *Store) UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*fl } if count != 1 { - return nil, errs.ErrNotFoundf("rule %q", r.Id) + return nil, errs.ErrNotFoundf(`rule "%s/%s"`, r.NamespaceKey, r.Id) } - return s.GetRule(ctx, r.Id) + return s.GetRule(ctx, r.NamespaceKey, r.Id) } // DeleteRule deletes a rule func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + tx, err := s.db.Begin() if err != nil { return err @@ -314,14 +345,14 @@ func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) erro //nolint _, err = s.builder.Delete("rules"). RunWith(tx). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"flag_key": r.FlagKey}}). + Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"flag_key": r.FlagKey}}). ExecContext(ctx) // reorder existing rules after deletion rows, err := s.builder.Select("id"). RunWith(tx). From("rules"). - Where(sq.Eq{"flag_key": r.FlagKey}). + Where(sq.And{sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"flag_key": r.FlagKey}}). OrderBy("\"rank\" ASC"). QueryContext(ctx) if err != nil { @@ -354,7 +385,7 @@ func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) erro return err } - if err := s.orderRules(ctx, tx, r.FlagKey, ruleIDs); err != nil { + if err := s.orderRules(ctx, tx, r.NamespaceKey, r.FlagKey, ruleIDs); err != nil { _ = tx.Rollback() return err } @@ -364,12 +395,16 @@ func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) erro // OrderRules orders rules func (s *Store) OrderRules(ctx context.Context, r *flipt.OrderRulesRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + tx, err := s.db.Begin() if err != nil { return err } - if err := s.orderRules(ctx, tx, r.FlagKey, r.RuleIds); err != nil { + if err := s.orderRules(ctx, tx, r.NamespaceKey, r.FlagKey, r.RuleIds); err != nil { _ = tx.Rollback() return err } @@ -377,7 +412,7 @@ func (s *Store) OrderRules(ctx context.Context, r *flipt.OrderRulesRequest) erro return tx.Commit() } -func (s *Store) orderRules(ctx context.Context, runner sq.BaseRunner, flagKey string, ruleIDs []string) error { +func (s *Store) orderRules(ctx context.Context, runner sq.BaseRunner, namespaceKey, flagKey string, ruleIDs []string) error { updatedAt := timestamppb.Now() for i, id := range ruleIDs { @@ -385,7 +420,7 @@ func (s *Store) orderRules(ctx context.Context, runner sq.BaseRunner, flagKey st RunWith(runner). Set("\"rank\"", i+1). Set("updated_at", &fliptsql.Timestamp{Timestamp: updatedAt}). - Where(sq.And{sq.Eq{"id": id}, sq.Eq{"flag_key": flagKey}}). + Where(sq.And{sq.Eq{"id": id}, sq.Eq{"namespace_key": namespaceKey}, sq.Eq{"flag_key": flagKey}}). ExecContext(ctx) if err != nil { return err @@ -395,8 +430,41 @@ func (s *Store) orderRules(ctx context.Context, runner sq.BaseRunner, flagKey st return nil } +func (s *Store) distributionValidationHelper(ctx context.Context, distributionRequest interface { + GetFlagKey() string + GetNamespaceKey() string + GetVariantId() string + GetRuleId() string +}) error { + var count int + if err := s.builder.Select("COUNT(*)"). + From("rules"). + Join("variants USING (namespace_key)"). + Join("flags USING (namespace_key)"). + Where(sq.Eq{ + "namespace_key": distributionRequest.GetNamespaceKey(), + "rules.id": distributionRequest.GetRuleId(), + "variants.id": distributionRequest.GetVariantId(), + "flags.\"key\"": distributionRequest.GetFlagKey(), + }). + QueryRowContext(ctx). + Scan(&count); err != nil { + return err + } + + if count < 1 { + return sql.ErrNoRows + } + + return nil +} + // CreateDistribution creates a distribution func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistributionRequest) (*flipt.Distribution, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( now = timestamppb.Now() d = &flipt.Distribution{ @@ -409,6 +477,14 @@ func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistribut } ) + err := s.distributionValidationHelper(ctx, r) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, errs.ErrNotFoundf("variant %q, rule %q, flag %q in namespace %q", r.VariantId, r.RuleId, r.FlagKey, r.NamespaceKey) + } + return nil, err + } + if _, err := s.builder. Insert("distributions"). Columns("id", "rule_id", "variant_id", "rollout", "created_at", "updated_at"). @@ -428,6 +504,18 @@ func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistribut // UpdateDistribution updates an existing distribution func (s *Store) UpdateDistribution(ctx context.Context, r *flipt.UpdateDistributionRequest) (*flipt.Distribution, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + + err := s.distributionValidationHelper(ctx, r) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, errs.ErrNotFoundf("variant %q, rule %q, flag %q in namespace %q", r.VariantId, r.RuleId, r.FlagKey, r.NamespaceKey) + } + return nil, err + } + query := s.builder.Update("distributions"). Set("rollout", r.Rollout). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). diff --git a/internal/storage/sql/common/segment.go b/internal/storage/sql/common/segment.go index 84fe01e46e..a06708401a 100644 --- a/internal/storage/sql/common/segment.go +++ b/internal/storage/sql/common/segment.go @@ -19,28 +19,34 @@ import ( ) // GetSegment gets a segment -func (s *Store) GetSegment(ctx context.Context, key string) (*flipt.Segment, error) { +func (s *Store) GetSegment(ctx context.Context, namespaceKey, key string) (*flipt.Segment, error) { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + var ( createdAt fliptsql.Timestamp updatedAt fliptsql.Timestamp segment = &flipt.Segment{} - err = s.builder.Select("\"key\", name, description, match_type, created_at, updated_at"). + err = s.builder.Select("namespace_key, \"key\", name, description, match_type, created_at, updated_at"). From("segments"). - Where(sq.Eq{"\"key\"": key}). - QueryRowContext(ctx).Scan( - &segment.Key, - &segment.Name, - &segment.Description, - &segment.MatchType, - &createdAt, - &updatedAt) + Where(sq.And{sq.Eq{"namespace_key": namespaceKey}, sq.Eq{"\"key\"": key}}). + QueryRowContext(ctx). + Scan( + &segment.NamespaceKey, + &segment.Key, + &segment.Name, + &segment.Description, + &segment.MatchType, + &createdAt, + &updatedAt) ) if err != nil { if errors.Is(err, sql.ErrNoRows) { - return nil, errs.ErrNotFoundf("segment %q", key) + return nil, errs.ErrNotFoundf(`segment "%s/%s"`, namespaceKey, key) } return nil, err @@ -49,7 +55,7 @@ func (s *Store) GetSegment(ctx context.Context, key string) (*flipt.Segment, err segment.CreatedAt = createdAt.Timestamp segment.UpdatedAt = updatedAt.Timestamp - query := s.builder.Select("id, segment_key, type, property, operator, value, created_at, updated_at"). + query := s.builder.Select("id, namespace_key, segment_key, type, property, operator, value, created_at, updated_at"). From("constraints"). Where(sq.Eq{"segment_key": segment.Key}). OrderBy("created_at ASC") @@ -73,6 +79,7 @@ func (s *Store) GetSegment(ctx context.Context, key string) (*flipt.Segment, err if err := rows.Scan( &constraint.Id, + &constraint.NamespaceKey, &constraint.SegmentKey, &constraint.Type, &constraint.Property, @@ -92,20 +99,25 @@ func (s *Store) GetSegment(ctx context.Context, key string) (*flipt.Segment, err } type optionalConstraint struct { - Id sql.NullString - SegmentKey sql.NullString - Type sql.NullInt32 - Property sql.NullString - Operator sql.NullString - Value sql.NullString - CreatedAt fliptsql.NullableTimestamp - UpdatedAt fliptsql.NullableTimestamp + Id sql.NullString + NamespaceKey sql.NullString + SegmentKey sql.NullString + Type sql.NullInt32 + Property sql.NullString + Operator sql.NullString + Value sql.NullString + CreatedAt fliptsql.NullableTimestamp + UpdatedAt fliptsql.NullableTimestamp } // ListSegments lists all segments -func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { +func (s *Store) ListSegments(ctx context.Context, namespaceKey string, opts ...storage.QueryOption) (storage.ResultSet[*flipt.Segment], error) { params := &storage.QueryParams{} + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + for _, opt := range opts { opt(params) } @@ -114,9 +126,10 @@ func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) ( segments []*flipt.Segment results = storage.ResultSet[*flipt.Segment]{} - query = s.builder.Select("s.key, s.name, s.description, s.match_type, s.created_at, s.updated_at, c.id, c.segment_key, c.type, c.property, c.operator, c.value, c.created_at, c.updated_at"). + query = s.builder.Select("s.namespace_key, s.key, s.name, s.description, s.match_type, s.created_at, s.updated_at, c.id, c.namespace_key, c.segment_key, c.type, c.property, c.operator, c.value, c.created_at, c.updated_at"). From("segments s"). - LeftJoin("constraints c ON s.key = c.segment_key"). + Where(sq.Eq{"s.namespace_key": namespaceKey}). + LeftJoin("constraints c ON s.key = c.segment_key AND c.namespace_key = s.namespace_key"). OrderBy(fmt.Sprintf("s.created_at %s", params.Order)) ) @@ -164,6 +177,7 @@ func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) ( ) if err := rows.Scan( + &segment.NamespaceKey, &segment.Key, &segment.Name, &segment.Description, @@ -171,6 +185,7 @@ func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) ( &sCreatedAt, &sUpdatedAt, &c.Id, + &c.NamespaceKey, &c.SegmentKey, &c.Type, &c.Property, @@ -194,6 +209,9 @@ func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) ( constraint := &flipt.Constraint{ Id: c.Id.String, } + if c.NamespaceKey.Valid { + constraint.NamespaceKey = c.NamespaceKey.String + } if c.SegmentKey.Valid { constraint.SegmentKey = c.SegmentKey.String } @@ -254,10 +272,18 @@ func (s *Store) ListSegments(ctx context.Context, opts ...storage.QueryOption) ( } // CountSegments counts all segments -func (s *Store) CountSegments(ctx context.Context) (uint64, error) { +func (s *Store) CountSegments(ctx context.Context, namespaceKey string) (uint64, error) { var count uint64 - if err := s.builder.Select("COUNT(*)").From("segments").QueryRowContext(ctx).Scan(&count); err != nil { + if namespaceKey == "" { + namespaceKey = storage.DefaultNamespace + } + + if err := s.builder.Select("COUNT(*)"). + From("segments"). + Where(sq.Eq{"namespace_key": namespaceKey}). + QueryRowContext(ctx). + Scan(&count); err != nil { return 0, err } @@ -266,21 +292,27 @@ func (s *Store) CountSegments(ctx context.Context) (uint64, error) { // CreateSegment creates a segment func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( now = timestamppb.Now() segment = &flipt.Segment{ - Key: r.Key, - Name: r.Name, - Description: r.Description, - MatchType: r.MatchType, - CreatedAt: now, - UpdatedAt: now, + NamespaceKey: r.NamespaceKey, + Key: r.Key, + Name: r.Name, + Description: r.Description, + MatchType: r.MatchType, + CreatedAt: now, + UpdatedAt: now, } ) if _, err := s.builder.Insert("segments"). - Columns("\"key\"", "name", "description", "match_type", "created_at", "updated_at"). + Columns("namespace_key", "\"key\"", "name", "description", "match_type", "created_at", "updated_at"). Values( + segment.NamespaceKey, segment.Key, segment.Name, segment.Description, @@ -296,12 +328,16 @@ func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest // UpdateSegment updates an existing segment func (s *Store) UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest) (*flipt.Segment, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + query := s.builder.Update("segments"). Set("name", r.Name). Set("description", r.Description). Set("match_type", r.MatchType). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). - Where(sq.Eq{"\"key\"": r.Key}) + Where(sq.And{sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"\"key\"": r.Key}}) res, err := query.ExecContext(ctx) if err != nil { @@ -314,16 +350,20 @@ func (s *Store) UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest } if count != 1 { - return nil, errs.ErrNotFoundf("segment %q", r.Key) + return nil, errs.ErrNotFoundf(`segment "%s/%s"`, r.NamespaceKey, r.Key) } - return s.GetSegment(ctx, r.Key) + return s.GetSegment(ctx, r.NamespaceKey, r.Key) } // DeleteSegment deletes a segment func (s *Store) DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + _, err := s.builder.Delete("segments"). - Where(sq.Eq{"\"key\"": r.Key}). + Where(sq.And{sq.Eq{"namespace_key": r.NamespaceKey}, sq.Eq{"\"key\"": r.Key}}). ExecContext(ctx) return err @@ -331,18 +371,23 @@ func (s *Store) DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest // CreateConstraint creates a constraint func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintRequest) (*flipt.Constraint, error) { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + var ( operator = strings.ToLower(r.Operator) now = timestamppb.Now() c = &flipt.Constraint{ - Id: uuid.Must(uuid.NewV4()).String(), - SegmentKey: r.SegmentKey, - Type: r.Type, - Property: r.Property, - Operator: operator, - Value: r.Value, - CreatedAt: now, - UpdatedAt: now, + Id: uuid.Must(uuid.NewV4()).String(), + NamespaceKey: r.NamespaceKey, + SegmentKey: r.SegmentKey, + Type: r.Type, + Property: r.Property, + Operator: operator, + Value: r.Value, + CreatedAt: now, + UpdatedAt: now, } ) @@ -352,9 +397,10 @@ func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintR } if _, err := s.builder.Insert("constraints"). - Columns("id", "segment_key", "type", "property", "operator", "value", "created_at", "updated_at"). + Columns("id", "namespace_key", "segment_key", "type", "property", "operator", "value", "created_at", "updated_at"). Values( c.Id, + c.NamespaceKey, c.SegmentKey, c.Type, c.Property, @@ -371,7 +417,14 @@ func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintR // UpdateConstraint updates an existing constraint func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintRequest) (*flipt.Constraint, error) { - operator := strings.ToLower(r.Operator) + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + + var ( + whereClause = sq.And{sq.Eq{"id": r.Id}, sq.Eq{"segment_key": r.SegmentKey}, sq.Eq{"namespace_key": r.NamespaceKey}} + operator = strings.ToLower(r.Operator) + ) // unset value if operator does not require it if _, ok := flipt.NoValueOperators[operator]; ok { @@ -384,7 +437,7 @@ func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintR Set("operator", operator). Set("value", r.Value). Set("updated_at", &fliptsql.Timestamp{Timestamp: timestamppb.Now()}). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"segment_key": r.SegmentKey}}). + Where(whereClause). ExecContext(ctx) if err != nil { return nil, err @@ -406,11 +459,11 @@ func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintR c = &flipt.Constraint{} ) - if err := s.builder.Select("id, segment_key, type, property, operator, value, created_at, updated_at"). + if err := s.builder.Select("id, namespace_key, segment_key, type, property, operator, value, created_at, updated_at"). From("constraints"). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"segment_key": r.SegmentKey}}). + Where(whereClause). QueryRowContext(ctx). - Scan(&c.Id, &c.SegmentKey, &c.Type, &c.Property, &c.Operator, &c.Value, &createdAt, &updatedAt); err != nil { + Scan(&c.Id, &c.NamespaceKey, &c.SegmentKey, &c.Type, &c.Property, &c.Operator, &c.Value, &createdAt, &updatedAt); err != nil { return nil, err } @@ -422,8 +475,12 @@ func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintR // DeleteConstraint deletes a constraint func (s *Store) DeleteConstraint(ctx context.Context, r *flipt.DeleteConstraintRequest) error { + if r.NamespaceKey == "" { + r.NamespaceKey = storage.DefaultNamespace + } + _, err := s.builder.Delete("constraints"). - Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"segment_key": r.SegmentKey}}). + Where(sq.And{sq.Eq{"id": r.Id}, sq.Eq{"segment_key": r.SegmentKey}, sq.Eq{"namespace_key": r.NamespaceKey}}). ExecContext(ctx) return err diff --git a/internal/storage/sql/common/storage.go b/internal/storage/sql/common/storage.go index cb783411d9..b7bf37745c 100644 --- a/internal/storage/sql/common/storage.go +++ b/internal/storage/sql/common/storage.go @@ -4,9 +4,12 @@ import ( "database/sql" sq "github.com/Masterminds/squirrel" + "go.flipt.io/flipt/internal/storage" "go.uber.org/zap" ) +var _ storage.Store = &Store{} + type Store struct { builder sq.StatementBuilderType db *sql.DB @@ -25,3 +28,7 @@ type PageToken struct { Key string `json:"key,omitempty"` Offset uint64 `json:"offset,omitempty"` } + +func (s *Store) String() string { + return "" +} diff --git a/internal/storage/sql/db.go b/internal/storage/sql/db.go index a5cda7d931..a716e8a253 100644 --- a/internal/storage/sql/db.go +++ b/internal/storage/sql/db.go @@ -29,25 +29,6 @@ func Open(cfg config.Config, opts ...Option) (*sql.DB, Driver, error) { return nil, 0, err } - sql.SetMaxIdleConns(cfg.Database.MaxIdleConn) - - var maxOpenConn int - if cfg.Database.MaxOpenConn > 0 { - maxOpenConn = cfg.Database.MaxOpenConn - } - - // if we're using sqlite, we need to set always set the max open connections to 1 - // see: https://github.com/mattn/go-sqlite3/issues/274 - if driver == SQLite { - maxOpenConn = 1 - } - - sql.SetMaxOpenConns(maxOpenConn) - - if cfg.Database.ConnMaxLifetime > 0 { - sql.SetConnMaxLifetime(cfg.Database.ConnMaxLifetime) - } - err = otelsql.RegisterDBStatsMetrics(sql, otelsql.WithAttributes( attribute.Key("driver").String(driver.String()), @@ -128,6 +109,25 @@ func open(cfg config.Config, opts Options) (*sql.DB, Driver, error) { return nil, 0, fmt.Errorf("opening db for driver: %s %w", d, err) } + db.SetMaxIdleConns(cfg.Database.MaxIdleConn) + + var maxOpenConn int + if cfg.Database.MaxOpenConn > 0 { + maxOpenConn = cfg.Database.MaxOpenConn + } + + // if we're using sqlite, we need to set always set the max open connections to 1 + // see: https://github.com/mattn/go-sqlite3/issues/274 + if d == SQLite { + maxOpenConn = 1 + } + + db.SetMaxOpenConns(maxOpenConn) + + if cfg.Database.ConnMaxLifetime > 0 { + db.SetConnMaxLifetime(cfg.Database.ConnMaxLifetime) + } + return db, d, nil } diff --git a/internal/storage/sql/db_test.go b/internal/storage/sql/db_test.go index d45a35a78c..943be09786 100644 --- a/internal/storage/sql/db_test.go +++ b/internal/storage/sql/db_test.go @@ -1,7 +1,10 @@ +//nolint:gosec package sql_test import ( "context" + "fmt" + "math/rand" "os" "testing" "time" @@ -16,6 +19,7 @@ import ( "go.flipt.io/flipt/internal/storage/sql/postgres" "go.flipt.io/flipt/internal/storage/sql/sqlite" fliptsqltesting "go.flipt.io/flipt/internal/storage/sql/testing" + "go.flipt.io/flipt/rpc/flipt" "go.uber.org/zap/zaptest" _ "github.com/golang-migrate/migrate/v4/source/file" @@ -107,8 +111,9 @@ func TestDBTestSuite(t *testing.T) { type DBTestSuite struct { suite.Suite - db *fliptsqltesting.Database - store storage.Store + db *fliptsqltesting.Database + store storage.Store + namespace string } var dd string @@ -140,6 +145,15 @@ func (s *DBTestSuite) SetupSuite() { store = mysql.NewStore(db.DB, logger) } + namespace := randomString(6) + + if _, err := store.CreateNamespace(context.Background(), &flipt.CreateNamespaceRequest{ + Key: namespace, + }); err != nil { + return fmt.Errorf("failed to create namespace: %w", err) + } + + s.namespace = namespace s.store = store return nil } @@ -147,6 +161,17 @@ func (s *DBTestSuite) SetupSuite() { s.Require().NoError(setup()) } +func randomString(n int) string { + var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + + b := make([]rune, n) + for i := range b { + b[i] = letters[rand.Intn(len(letters))] + } + + return string(b) +} + func (s *DBTestSuite) TearDownSuite() { shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() diff --git a/internal/storage/sql/evaluation_test.go b/internal/storage/sql/evaluation_test.go index 34b30e6e49..ba6b604d2c 100644 --- a/internal/storage/sql/evaluation_test.go +++ b/internal/storage/sql/evaluation_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.flipt.io/flipt/internal/storage" flipt "go.flipt.io/flipt/rpc/flipt" ) @@ -70,13 +71,14 @@ func (s *DBTestSuite) TestGetEvaluationRules() { require.NoError(t, err) - evaluationRules, err := s.store.GetEvaluationRules(context.TODO(), flag.Key) + evaluationRules, err := s.store.GetEvaluationRules(context.TODO(), storage.DefaultNamespace, flag.Key) require.NoError(t, err) assert.NotEmpty(t, evaluationRules) assert.Equal(t, 2, len(evaluationRules)) assert.Equal(t, rule1.Id, evaluationRules[0].ID) + assert.Equal(t, storage.DefaultNamespace, evaluationRules[0].NamespaceKey) assert.Equal(t, rule1.FlagKey, evaluationRules[0].FlagKey) assert.Equal(t, rule1.SegmentKey, evaluationRules[0].SegmentKey) assert.Equal(t, segment.MatchType, evaluationRules[0].SegmentMatchType) @@ -84,6 +86,97 @@ func (s *DBTestSuite) TestGetEvaluationRules() { assert.Equal(t, 2, len(evaluationRules[0].Constraints)) assert.Equal(t, rule2.Id, evaluationRules[1].ID) + assert.Equal(t, storage.DefaultNamespace, evaluationRules[1].NamespaceKey) + assert.Equal(t, rule2.FlagKey, evaluationRules[1].FlagKey) + assert.Equal(t, rule2.SegmentKey, evaluationRules[1].SegmentKey) + assert.Equal(t, segment.MatchType, evaluationRules[1].SegmentMatchType) + assert.Equal(t, rule2.Rank, evaluationRules[1].Rank) + assert.Equal(t, 2, len(evaluationRules[1].Constraints)) +} + +func (s *DBTestSuite) TestGetEvaluationRulesNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + MatchType: flipt.MatchType_ANY_MATCH_TYPE, + }) + + require.NoError(t, err) + + // constraint 1 + _, err = s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EQ", + Value: "bar", + }) + + require.NoError(t, err) + + // constraint 2 + _, err = s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foz", + Operator: "EQ", + Value: "baz", + }) + + require.NoError(t, err) + + // rule rank 1 + rule1, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 1, + }) + + require.NoError(t, err) + + // rule rank 2 + rule2, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 2, + }) + + require.NoError(t, err) + + evaluationRules, err := s.store.GetEvaluationRules(context.TODO(), s.namespace, flag.Key) + require.NoError(t, err) + + assert.NotEmpty(t, evaluationRules) + assert.Equal(t, 2, len(evaluationRules)) + + assert.Equal(t, rule1.Id, evaluationRules[0].ID) + assert.Equal(t, s.namespace, evaluationRules[0].NamespaceKey) + assert.Equal(t, rule1.FlagKey, evaluationRules[0].FlagKey) + assert.Equal(t, rule1.SegmentKey, evaluationRules[0].SegmentKey) + assert.Equal(t, segment.MatchType, evaluationRules[0].SegmentMatchType) + assert.Equal(t, rule1.Rank, evaluationRules[0].Rank) + assert.Equal(t, 2, len(evaluationRules[0].Constraints)) + + assert.Equal(t, rule2.Id, evaluationRules[1].ID) + assert.Equal(t, s.namespace, evaluationRules[1].NamespaceKey) assert.Equal(t, rule2.FlagKey, evaluationRules[1].FlagKey) assert.Equal(t, rule2.SegmentKey, evaluationRules[1].SegmentKey) assert.Equal(t, segment.MatchType, evaluationRules[1].SegmentMatchType) @@ -188,6 +281,111 @@ func (s *DBTestSuite) TestGetEvaluationDistributions() { assert.Equal(t, float32(50.00), evaluationDistributions[1].Rollout) } +func (s *DBTestSuite) TestGetEvaluationDistributionsNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + + // variant 1 + variant1, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + }) + + require.NoError(t, err) + + // variant 2 + variant2, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "bar", + Attachment: `{"key2": "value2"}`, + }) + + require.NoError(t, err) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + MatchType: flipt.MatchType_ANY_MATCH_TYPE, + }) + + require.NoError(t, err) + + _, err = s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EQ", + Value: "bar", + }) + + require.NoError(t, err) + + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 1, + }) + + require.NoError(t, err) + + // 50/50 distribution + _, err = s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + RuleId: rule.Id, + VariantId: variant1.Id, + Rollout: 50.00, + }) + + // required for MySQL since it only s.stores timestamps to the second and not millisecond granularity + time.Sleep(1 * time.Second) + + require.NoError(t, err) + + _, err = s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + RuleId: rule.Id, + VariantId: variant2.Id, + Rollout: 50.00, + }) + + require.NoError(t, err) + + evaluationDistributions, err := s.store.GetEvaluationDistributions(context.TODO(), rule.Id) + require.NoError(t, err) + + assert.Equal(t, 2, len(evaluationDistributions)) + + assert.NotEmpty(t, evaluationDistributions[0].ID) + assert.Equal(t, rule.Id, evaluationDistributions[0].RuleID) + assert.Equal(t, variant1.Id, evaluationDistributions[0].VariantID) + assert.Equal(t, variant1.Key, evaluationDistributions[0].VariantKey) + assert.Equal(t, float32(50.00), evaluationDistributions[0].Rollout) + + assert.NotEmpty(t, evaluationDistributions[1].ID) + assert.Equal(t, rule.Id, evaluationDistributions[1].RuleID) + assert.Equal(t, variant2.Id, evaluationDistributions[1].VariantID) + assert.Equal(t, variant2.Key, evaluationDistributions[1].VariantKey) + assert.Equal(t, `{"key2":"value2"}`, evaluationDistributions[1].VariantAttachment) + assert.Equal(t, float32(50.00), evaluationDistributions[1].Rollout) +} + // https://github.com/flipt-io/flipt/issues/229 func (s *DBTestSuite) TestGetEvaluationDistributions_MaintainOrder() { t := s.T() diff --git a/internal/storage/sql/flag_test.go b/internal/storage/sql/flag_test.go index 443344cc15..37c228160a 100644 --- a/internal/storage/sql/flag_test.go +++ b/internal/storage/sql/flag_test.go @@ -30,11 +30,12 @@ func (s *DBTestSuite) TestGetFlag() { require.NoError(t, err) assert.NotNil(t, flag) - got, err := s.store.GetFlag(context.TODO(), flag.Key) + got, err := s.store.GetFlag(context.TODO(), storage.DefaultNamespace, flag.Key) require.NoError(t, err) assert.NotNil(t, got) + assert.Equal(t, storage.DefaultNamespace, got.NamespaceKey) assert.Equal(t, flag.Key, got.Key) assert.Equal(t, flag.Name, got.Name) assert.Equal(t, flag.Description, got.Description) @@ -43,11 +44,46 @@ func (s *DBTestSuite) TestGetFlag() { assert.NotZero(t, flag.UpdatedAt) } -func (s *DBTestSuite) TestGetFlagNotFound() { +func (s *DBTestSuite) TestGetFlagNamespace() { t := s.T() - _, err := s.store.GetFlag(context.TODO(), "foo") - assert.EqualError(t, err, "flag \"foo\" not found") + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + got, err := s.store.GetFlag(context.TODO(), s.namespace, flag.Key) + + require.NoError(t, err) + assert.NotNil(t, got) + + assert.Equal(t, s.namespace, got.NamespaceKey) + assert.Equal(t, flag.Key, got.Key) + assert.Equal(t, flag.Name, got.Name) + assert.Equal(t, flag.Description, got.Description) + assert.Equal(t, flag.Enabled, got.Enabled) + assert.NotZero(t, flag.CreatedAt) + assert.NotZero(t, flag.UpdatedAt) +} + +func (s *DBTestSuite) TestGetFlag_NotFound() { + t := s.T() + + _, err := s.store.GetFlag(context.TODO(), storage.DefaultNamespace, "foo") + assert.EqualError(t, err, "flag \"default/foo\" not found") +} + +func (s *DBTestSuite) TestGetFlagNamespace_NotFound() { + t := s.T() + + _, err := s.store.GetFlag(context.TODO(), s.namespace, "foo") + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestListFlags() { @@ -72,10 +108,54 @@ func (s *DBTestSuite) TestListFlags() { require.NoError(t, err) } - res, err := s.store.ListFlags(context.TODO()) + res, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace) + require.NoError(t, err) + + got := res.Results + assert.NotZero(t, len(got)) + + for _, flag := range got { + assert.Equal(t, storage.DefaultNamespace, flag.NamespaceKey) + assert.NotZero(t, flag.CreatedAt) + assert.NotZero(t, flag.UpdatedAt) + } +} + +func (s *DBTestSuite) TestListFlagsNamespace() { + t := s.T() + + reqs := []*flipt.CreateFlagRequest{ + { + NamespaceKey: s.namespace, + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + Enabled: true, + }, + { + NamespaceKey: s.namespace, + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + } + + for _, req := range reqs { + _, err := s.store.CreateFlag(context.TODO(), req) + require.NoError(t, err) + } + + res, err := s.store.ListFlags(context.TODO(), s.namespace) require.NoError(t, err) + got := res.Results assert.NotZero(t, len(got)) + + for _, flag := range got { + assert.Equal(t, s.namespace, flag.NamespaceKey) + assert.NotZero(t, flag.CreatedAt) + assert.NotZero(t, flag.UpdatedAt) + } } func (s *DBTestSuite) TestListFlagsPagination_LimitOffset() { @@ -114,7 +194,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitOffset() { // TODO: the ordering (DESC) is required because the default ordering is ASC and we are not clearing the DB between tests // get middle flag - res, err := s.store.ListFlags(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(1)) + res, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(1)) require.NoError(t, err) got := res.Results @@ -123,7 +203,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitOffset() { assert.Equal(t, middle.Key, got[0].Key) // get first (newest) flag - res, err = s.store.ListFlags(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)) require.NoError(t, err) got = res.Results @@ -132,7 +212,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitOffset() { assert.Equal(t, newest.Key, got[0].Key) // get last (oldest) flag - res, err = s.store.ListFlags(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(2)) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(2)) require.NoError(t, err) got = res.Results @@ -141,7 +221,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitOffset() { assert.Equal(t, oldest.Key, got[0].Key) // get all flags - res, err = s.store.ListFlags(context.TODO(), storage.WithOrder(storage.OrderDesc)) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc)) require.NoError(t, err) got = res.Results @@ -189,7 +269,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitWithNextPage() { // get newest flag opts := []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)} - res, err := s.store.ListFlags(context.TODO(), opts...) + res, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got := res.Results @@ -207,7 +287,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitWithNextPage() { opts = append(opts, storage.WithPageToken(res.NextPageToken)) // get middle flag - res, err = s.store.ListFlags(context.TODO(), opts...) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -223,7 +303,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitWithNextPage() { opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithPageToken(res.NextPageToken)} // get oldest flag - res, err = s.store.ListFlags(context.TODO(), opts...) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -232,7 +312,7 @@ func (s *DBTestSuite) TestListFlagsPagination_LimitWithNextPage() { opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(3)} // get all flags - res, err = s.store.ListFlags(context.TODO(), opts...) + res, err = s.store.ListFlags(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -254,6 +334,29 @@ func (s *DBTestSuite) TestCreateFlag() { require.NoError(t, err) + assert.Equal(t, storage.DefaultNamespace, flag.NamespaceKey) + assert.Equal(t, t.Name(), flag.Key) + assert.Equal(t, "foo", flag.Name) + assert.Equal(t, "bar", flag.Description) + assert.True(t, flag.Enabled) + assert.NotZero(t, flag.CreatedAt) + assert.Equal(t, flag.CreatedAt.Seconds, flag.UpdatedAt.Seconds) +} + +func (s *DBTestSuite) TestCreateFlagNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, flag.NamespaceKey) assert.Equal(t, t.Name(), flag.Key) assert.Equal(t, "foo", flag.Name) assert.Equal(t, "bar", flag.Description) @@ -281,7 +384,31 @@ func (s *DBTestSuite) TestCreateFlag_DuplicateKey() { Enabled: true, }) - assert.EqualError(t, err, "flag \"TestDBTestSuite/TestCreateFlag_DuplicateKey\" is not unique") + assert.EqualError(t, err, "flag \"default/TestDBTestSuite/TestCreateFlag_DuplicateKey\" is not unique") +} + +func (s *DBTestSuite) TestCreateFlagNamespace_DuplicateKey() { + t := s.T() + + _, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + + _, err = s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/%s\" is not unique", s.namespace, t.Name())) } func (s *DBTestSuite) TestUpdateFlag() { @@ -296,6 +423,7 @@ func (s *DBTestSuite) TestUpdateFlag() { require.NoError(t, err) + assert.Equal(t, storage.DefaultNamespace, flag.NamespaceKey) assert.Equal(t, t.Name(), flag.Key) assert.Equal(t, "foo", flag.Name) assert.Equal(t, "bar", flag.Description) @@ -312,6 +440,47 @@ func (s *DBTestSuite) TestUpdateFlag() { require.NoError(t, err) + assert.Equal(t, storage.DefaultNamespace, updated.NamespaceKey) + assert.Equal(t, flag.Key, updated.Key) + assert.Equal(t, flag.Name, updated.Name) + assert.Equal(t, "foobar", updated.Description) + assert.True(t, flag.Enabled) + assert.NotZero(t, updated.CreatedAt) + assert.NotZero(t, updated.UpdatedAt) +} + +func (s *DBTestSuite) TestUpdateFlagNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, flag.NamespaceKey) + assert.Equal(t, t.Name(), flag.Key) + assert.Equal(t, "foo", flag.Name) + assert.Equal(t, "bar", flag.Description) + assert.True(t, flag.Enabled) + assert.NotZero(t, flag.CreatedAt) + assert.Equal(t, flag.CreatedAt.Seconds, flag.UpdatedAt.Seconds) + + updated, err := s.store.UpdateFlag(context.TODO(), &flipt.UpdateFlagRequest{ + NamespaceKey: s.namespace, + Key: flag.Key, + Name: flag.Name, + Description: "foobar", + Enabled: true, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, updated.NamespaceKey) assert.Equal(t, flag.Key, updated.Key) assert.Equal(t, flag.Name, updated.Name) assert.Equal(t, "foobar", updated.Description) @@ -330,7 +499,21 @@ func (s *DBTestSuite) TestUpdateFlag_NotFound() { Enabled: true, }) - assert.EqualError(t, err, "flag \"foo\" not found") + assert.EqualError(t, err, "flag \"default/foo\" not found") +} + +func (s *DBTestSuite) TestUpdateFlagNamespace_NotFound() { + t := s.T() + + _, err := s.store.UpdateFlag(context.TODO(), &flipt.UpdateFlagRequest{ + NamespaceKey: s.namespace, + Key: "foo", + Name: "foo", + Description: "bar", + Enabled: true, + }) + + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestDeleteFlag() { @@ -350,6 +533,28 @@ func (s *DBTestSuite) TestDeleteFlag() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteFlagNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + err = s.store.DeleteFlag(context.TODO(), &flipt.DeleteFlagRequest{ + NamespaceKey: s.namespace, + Key: flag.Key, + }) + + require.NoError(t, err) +} + func (s *DBTestSuite) TestDeleteFlag_NotFound() { t := s.T() @@ -357,6 +562,17 @@ func (s *DBTestSuite) TestDeleteFlag_NotFound() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteFlagNamespace_NotFound() { + t := s.T() + + err := s.store.DeleteFlag(context.TODO(), &flipt.DeleteFlagRequest{ + NamespaceKey: s.namespace, + Key: "foo", + }) + + require.NoError(t, err) +} + func (s *DBTestSuite) TestCreateVariant() { t := s.T() @@ -383,6 +599,7 @@ func (s *DBTestSuite) TestCreateVariant() { assert.NotNil(t, variant) assert.NotZero(t, variant.Id) + assert.Equal(t, storage.DefaultNamespace, variant.NamespaceKey) assert.Equal(t, flag.Key, variant.FlagKey) assert.Equal(t, t.Name(), variant.Key) assert.Equal(t, "foo", variant.Name) @@ -392,7 +609,53 @@ func (s *DBTestSuite) TestCreateVariant() { assert.Equal(t, variant.CreatedAt.Seconds, variant.UpdatedAt.Seconds) // get the flag again - flag, err = s.store.GetFlag(context.TODO(), flag.Key) + flag, err = s.store.GetFlag(context.TODO(), storage.DefaultNamespace, flag.Key) + + require.NoError(t, err) + assert.NotNil(t, flag) + + assert.Len(t, flag.Variants, 1) +} + +func (s *DBTestSuite) TestCreateVariantNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + attachment := `{"key":"value"}` + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + Attachment: attachment, + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + assert.NotZero(t, variant.Id) + assert.Equal(t, s.namespace, variant.NamespaceKey) + assert.Equal(t, flag.Key, variant.FlagKey) + assert.Equal(t, t.Name(), variant.Key) + assert.Equal(t, "foo", variant.Name) + assert.Equal(t, "bar", variant.Description) + assert.Equal(t, attachment, variant.Attachment) + assert.NotZero(t, variant.CreatedAt) + assert.Equal(t, variant.CreatedAt.Seconds, variant.UpdatedAt.Seconds) + + // get the flag again + flag, err = s.store.GetFlag(context.TODO(), s.namespace, flag.Key) require.NoError(t, err) assert.NotNil(t, flag) @@ -410,10 +673,24 @@ func (s *DBTestSuite) TestCreateVariant_FlagNotFound() { Description: "bar", }) - assert.EqualError(t, err, "flag \"foo\" not found") + assert.EqualError(t, err, "flag \"default/foo\" not found") +} + +func (s *DBTestSuite) TestCreateVariantNamespace_FlagNotFound() { + t := s.T() + + _, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: "foo", + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/foo\" not found", s.namespace)) } -func (s *DBTestSuite) TestCreateVariant_DuplicateName() { +func (s *DBTestSuite) TestCreateVariant_DuplicateKey() { t := s.T() flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ @@ -444,10 +721,47 @@ func (s *DBTestSuite) TestCreateVariant_DuplicateName() { Description: "bar", }) - assert.EqualError(t, err, "variant \"foo\" is not unique") + assert.EqualError(t, err, "variant \"foo\" is not unique for flag \"default/TestDBTestSuite/TestCreateVariant_DuplicateKey\"") } -func (s *DBTestSuite) TestCreateVariant_DuplicateName_DifferentFlag() { +func (s *DBTestSuite) TestCreateVariantNamespace_DuplicateKey() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + // try to create another variant with the same name for this flag + _, err = s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, fmt.Sprintf("variant \"foo\" is not unique for flag \"%s/%s\"", s.namespace, t.Name())) +} + +func (s *DBTestSuite) TestCreateVariant_DuplicateKey_DifferentFlag() { t := s.T() flag1, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ @@ -499,6 +813,62 @@ func (s *DBTestSuite) TestCreateVariant_DuplicateName_DifferentFlag() { assert.Equal(t, "foo", variant2.Key) } +func (s *DBTestSuite) TestCreateVariantNamespace_DuplicateFlag_DuplicateKey() { + t := s.T() + + flag1, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag1) + + variant1, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag1.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant1) + + assert.NotZero(t, variant1.Id) + assert.Equal(t, s.namespace, variant1.NamespaceKey) + assert.Equal(t, flag1.Key, variant1.FlagKey) + assert.Equal(t, "foo", variant1.Key) + + flag2, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag2) + + variant2, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + FlagKey: flag2.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant2) + + assert.NotZero(t, variant2.Id) + assert.Equal(t, storage.DefaultNamespace, variant2.NamespaceKey) + assert.Equal(t, flag2.Key, variant2.FlagKey) + assert.Equal(t, "foo", variant2.Key) +} + func (s *DBTestSuite) TestUpdateVariant() { t := s.T() @@ -525,6 +895,7 @@ func (s *DBTestSuite) TestUpdateVariant() { assert.NotNil(t, variant) assert.NotZero(t, variant.Id) + assert.Equal(t, storage.DefaultNamespace, variant.NamespaceKey) assert.Equal(t, flag.Key, variant.FlagKey) assert.Equal(t, "foo", variant.Key) assert.Equal(t, "foo", variant.Name) @@ -545,6 +916,75 @@ func (s *DBTestSuite) TestUpdateVariant() { require.NoError(t, err) assert.Equal(t, variant.Id, updated.Id) + assert.Equal(t, storage.DefaultNamespace, updated.NamespaceKey) + assert.Equal(t, variant.FlagKey, updated.FlagKey) + assert.Equal(t, variant.Key, updated.Key) + assert.Equal(t, variant.Name, updated.Name) + assert.Equal(t, "foobar", updated.Description) + assert.Equal(t, `{"key":"value2"}`, updated.Attachment) + assert.NotZero(t, updated.CreatedAt) + assert.NotZero(t, updated.UpdatedAt) + + // get the flag again + flag, err = s.store.GetFlag(context.TODO(), storage.DefaultNamespace, flag.Key) + + require.NoError(t, err) + assert.NotNil(t, flag) + + assert.Len(t, flag.Variants, 1) +} + +func (s *DBTestSuite) TestUpdateVariantNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + attachment1 := `{"key":"value1"}` + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + Attachment: attachment1, + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + assert.NotZero(t, variant.Id) + assert.Equal(t, s.namespace, variant.NamespaceKey) + assert.Equal(t, flag.Key, variant.FlagKey) + assert.Equal(t, "foo", variant.Key) + assert.Equal(t, "foo", variant.Name) + assert.Equal(t, "bar", variant.Description) + assert.Equal(t, attachment1, variant.Attachment) + assert.NotZero(t, variant.CreatedAt) + assert.Equal(t, variant.CreatedAt.Seconds, variant.UpdatedAt.Seconds) + + updated, err := s.store.UpdateVariant(context.TODO(), &flipt.UpdateVariantRequest{ + NamespaceKey: s.namespace, + Id: variant.Id, + FlagKey: variant.FlagKey, + Key: variant.Key, + Name: variant.Name, + Description: "foobar", + Attachment: `{"key": "value2"}`, + }) + + require.NoError(t, err) + + assert.Equal(t, variant.Id, updated.Id) + assert.Equal(t, s.namespace, updated.NamespaceKey) assert.Equal(t, variant.FlagKey, updated.FlagKey) assert.Equal(t, variant.Key, updated.Key) assert.Equal(t, variant.Name, updated.Name) @@ -554,7 +994,7 @@ func (s *DBTestSuite) TestUpdateVariant() { assert.NotZero(t, updated.UpdatedAt) // get the flag again - flag, err = s.store.GetFlag(context.TODO(), flag.Key) + flag, err = s.store.GetFlag(context.TODO(), s.namespace, flag.Key) require.NoError(t, err) assert.NotNil(t, flag) @@ -586,7 +1026,33 @@ func (s *DBTestSuite) TestUpdateVariant_NotFound() { assert.EqualError(t, err, "variant \"foo\" not found") } -func (s *DBTestSuite) TestUpdateVariant_DuplicateName() { +func (s *DBTestSuite) TestUpdateVariantNamespace_NotFound() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + _, err = s.store.UpdateVariant(context.TODO(), &flipt.UpdateVariantRequest{ + NamespaceKey: s.namespace, + Id: "foo", + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, "variant \"foo\" not found") +} + +func (s *DBTestSuite) TestUpdateVariant_DuplicateKey() { t := s.T() flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ @@ -627,7 +1093,55 @@ func (s *DBTestSuite) TestUpdateVariant_DuplicateName() { Description: "foobar", }) - assert.EqualError(t, err, "variant \"foo\" is not unique") + assert.EqualError(t, err, "variant \"foo\" is not unique for flag \"default/TestDBTestSuite/TestUpdateVariant_DuplicateKey\"") +} + +func (s *DBTestSuite) TestUpdateVariantNamespace_DuplicateKey() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant1, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant1) + + variant2, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "bar", + Name: "bar", + Description: "baz", + }) + + require.NoError(t, err) + assert.NotNil(t, variant2) + + _, err = s.store.UpdateVariant(context.TODO(), &flipt.UpdateVariantRequest{ + NamespaceKey: s.namespace, + Id: variant2.Id, + FlagKey: variant2.FlagKey, + Key: variant1.Key, + Name: variant2.Name, + Description: "foobar", + }) + + assert.EqualError(t, err, fmt.Sprintf("variant \"foo\" is not unique for flag \"%s/%s\"", s.namespace, t.Name())) } func (s *DBTestSuite) TestDeleteVariant() { @@ -657,7 +1171,48 @@ func (s *DBTestSuite) TestDeleteVariant() { require.NoError(t, err) // get the flag again - flag, err = s.store.GetFlag(context.TODO(), flag.Key) + flag, err = s.store.GetFlag(context.TODO(), storage.DefaultNamespace, flag.Key) + + require.NoError(t, err) + assert.NotNil(t, flag) + + assert.Empty(t, flag.Variants) +} + +func (s *DBTestSuite) TestDeleteVariantNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + err = s.store.DeleteVariant(context.TODO(), &flipt.DeleteVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: variant.FlagKey, + Id: variant.Id, + }) + require.NoError(t, err) + + // get the flag again + flag, err = s.store.GetFlag(context.TODO(), s.namespace, flag.Key) require.NoError(t, err) assert.NotNil(t, flag) @@ -754,6 +1309,29 @@ func (s *DBTestSuite) TestDeleteVariant_NotFound() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteVariantNamespace_NotFound() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + err = s.store.DeleteVariant(context.TODO(), &flipt.DeleteVariantRequest{ + NamespaceKey: s.namespace, + Id: "foo", + FlagKey: flag.Key, + }) + + require.NoError(t, err) +} + func BenchmarkListFlags(b *testing.B) { s := new(DBTestSuite) t := &testing.T{} @@ -791,7 +1369,7 @@ func BenchmarkListFlags(b *testing.B) { b.Run("no-pagination", func(b *testing.B) { for i := 0; i < b.N; i++ { - flags, err := s.store.ListFlags(context.TODO()) + flags, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace) require.NoError(t, err) assert.NotEmpty(t, flags) } @@ -801,7 +1379,7 @@ func BenchmarkListFlags(b *testing.B) { pageSize := pageSize b.Run(fmt.Sprintf("pagination-limit-%d", pageSize), func(b *testing.B) { for i := 0; i < b.N; i++ { - flags, err := s.store.ListFlags(context.TODO(), storage.WithLimit(pageSize)) + flags, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithLimit(pageSize)) require.NoError(t, err) assert.NotEmpty(t, flags) } @@ -810,7 +1388,7 @@ func BenchmarkListFlags(b *testing.B) { b.Run("pagination", func(b *testing.B) { for i := 0; i < b.N; i++ { - flags, err := s.store.ListFlags(context.TODO(), storage.WithLimit(500), storage.WithOffset(50), storage.WithOrder(storage.OrderDesc)) + flags, err := s.store.ListFlags(context.TODO(), storage.DefaultNamespace, storage.WithLimit(500), storage.WithOffset(50), storage.WithOrder(storage.OrderDesc)) require.NoError(t, err) assert.NotEmpty(t, flags) } diff --git a/internal/storage/sql/migrator.go b/internal/storage/sql/migrator.go index 4245687b85..40ec64d423 100644 --- a/internal/storage/sql/migrator.go +++ b/internal/storage/sql/migrator.go @@ -1,6 +1,7 @@ package sql import ( + "database/sql" "errors" "fmt" @@ -17,14 +18,15 @@ import ( ) var expectedVersions = map[Driver]uint{ - SQLite: 5, - Postgres: 5, - MySQL: 3, - CockroachDB: 2, + SQLite: 7, + Postgres: 7, + MySQL: 5, + CockroachDB: 4, } // Migrator is responsible for migrating the database schema type Migrator struct { + db *sql.DB driver Driver logger *zap.Logger migrator *migrate.Migrate @@ -69,6 +71,7 @@ func NewMigrator(cfg config.Config, logger *zap.Logger) (*Migrator, error) { } return &Migrator{ + db: sql, migrator: mm, logger: logger, driver: driver, @@ -100,7 +103,6 @@ func (m *Migrator) Up(force bool) error { } m.logger.Debug("migrations complete") - return nil } @@ -127,15 +129,26 @@ func (m *Migrator) Up(force bool) error { return nil } -// Down returns the down migrations (drops the database) -func (m *Migrator) Down() error { - m.logger.Debug("running down migrations...") +// Drop drops the database +func (m *Migrator) Drop() error { + m.logger.Debug("running drop ...") - if err := m.migrator.Down(); err != nil { - return fmt.Errorf("reverting migrations: %w", err) + switch m.driver { + case SQLite: + // disable foreign keys for sqlite to avoid errors when dropping tables + // https://www.sqlite.org/foreignkeys.html#fk_enable + // we dont need to worry about re-enabling them since we're dropping the db + // and the connection will be closed + _, _ = m.db.Exec("PRAGMA foreign_keys = OFF") + case MySQL: + // https://stackoverflow.com/questions/5452760/how-to-truncate-a-foreign-key-constrained-table + _, _ = m.db.Exec("SET FOREIGN_KEY_CHECKS = 0;") } - m.logger.Debug("down migrations complete") + if err := m.migrator.Drop(); err != nil { + return fmt.Errorf("dropping: %w", err) + } + m.logger.Debug("drop complete") return nil } diff --git a/internal/storage/sql/migrator_test.go b/internal/storage/sql/migrator_test.go index 3cc0e7aac5..03dc5dfdb4 100644 --- a/internal/storage/sql/migrator_test.go +++ b/internal/storage/sql/migrator_test.go @@ -89,10 +89,8 @@ func TestMigratorExpectedVersions(t *testing.T) { count := len(migrations) require.True(t, count > 0, "no migrations found for %s", db) - // 1 is the up migration and 1 is the down migration - // so we should have count/2 migrations - // and they start at 0 - actual := uint((count / 2) - 1) + // migrations start at 0 + actual := uint(count - 1) assert.Equal(t, actual, expectedVersions[driver], "expectedVersions for %s should be set to %d. you need to increment expectedVersions after adding a new migration", db, actual) } } diff --git a/internal/storage/sql/mysql/mysql.go b/internal/storage/sql/mysql/mysql.go index a85bb580b8..bce01fb581 100644 --- a/internal/storage/sql/mysql/mysql.go +++ b/internal/storage/sql/mysql/mysql.go @@ -38,14 +38,35 @@ func (s *Store) String() string { return "mysql" } +func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + namespace, err := s.Store.CreateNamespace(ctx, r) + + if err != nil { + var merr *mysql.MySQLError + + if errors.As(err, &merr) && merr.Number == constraintUniqueErrCode { + return nil, errs.ErrInvalidf("namespace %q is not unique", r.Key) + } + + return nil, err + } + + return namespace, nil +} + func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { flag, err := s.Store.CreateFlag(ctx, r) if err != nil { var merr *mysql.MySQLError - if errors.As(err, &merr) && merr.Number == constraintUniqueErrCode { - return nil, errs.ErrInvalidf("flag %q is not unique", r.Key) + if errors.As(err, &merr) { + switch merr.Number { + case constraintForeignKeyErrCode: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case constraintUniqueErrCode: + return nil, errs.ErrInvalidf(`flag "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -63,9 +84,9 @@ func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest if errors.As(err, &merr) { switch merr.Number { case constraintForeignKeyErrCode: - return nil, errs.ErrNotFoundf("flag %q", r.FlagKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s"`, r.NamespaceKey, r.FlagKey) case constraintUniqueErrCode: - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } } @@ -82,7 +103,7 @@ func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest var merr *mysql.MySQLError if errors.As(err, &merr) && merr.Number == constraintUniqueErrCode { - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } return nil, err @@ -97,8 +118,13 @@ func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest if err != nil { var merr *mysql.MySQLError - if errors.As(err, &merr) && merr.Number == constraintUniqueErrCode { - return nil, errs.ErrInvalidf("segment %q is not unique", r.Key) + if errors.As(err, &merr) { + switch merr.Number { + case constraintForeignKeyErrCode: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case constraintUniqueErrCode: + return nil, errs.ErrInvalidf(`segment "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -114,7 +140,7 @@ func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintR var merr *mysql.MySQLError if errors.As(err, &merr) && merr.Number == constraintForeignKeyErrCode { - return nil, errs.ErrNotFoundf("segment %q", r.SegmentKey) + return nil, errs.ErrNotFoundf(`segment "%s/%s"`, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -130,7 +156,7 @@ func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*fl var merr *mysql.MySQLError if errors.As(err, &merr) && merr.Number == constraintForeignKeyErrCode { - return nil, errs.ErrNotFoundf("flag %q or segment %q", r.FlagKey, r.SegmentKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s" or segment "%s/%s"`, r.NamespaceKey, r.FlagKey, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -146,7 +172,7 @@ func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistribut var merr *mysql.MySQLError if errors.As(err, &merr) && merr.Number == constraintForeignKeyErrCode { - return nil, errs.ErrNotFoundf("rule %q", r.RuleId) + return nil, errs.ErrNotFoundf("variant %q, rule %q, flag %q in namespace %q", r.VariantId, r.RuleId, r.FlagKey, r.NamespaceKey) } return nil, err diff --git a/internal/storage/sql/namespaces_test.go b/internal/storage/sql/namespaces_test.go new file mode 100644 index 0000000000..bab8fbe495 --- /dev/null +++ b/internal/storage/sql/namespaces_test.go @@ -0,0 +1,334 @@ +package sql_test + +import ( + "context" + "encoding/json" + + "github.com/gofrs/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.flipt.io/flipt/internal/storage" + "go.flipt.io/flipt/internal/storage/sql/common" + flipt "go.flipt.io/flipt/rpc/flipt" +) + +func (s *DBTestSuite) TestGetNamespace() { + t := s.T() + + ns, err := s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, ns) + + got, err := s.store.GetNamespace(context.TODO(), ns.Key) + + require.NoError(t, err) + assert.NotNil(t, got) + + assert.Equal(t, ns.Key, got.Key) + assert.Equal(t, ns.Name, got.Name) + assert.Equal(t, ns.Description, got.Description) + assert.NotZero(t, ns.CreatedAt) + assert.NotZero(t, ns.UpdatedAt) +} + +func (s *DBTestSuite) TestGetNamespaceNotFound() { + t := s.T() + + _, err := s.store.GetNamespace(context.TODO(), "foo") + assert.EqualError(t, err, "namespace \"foo\" not found") +} + +func (s *DBTestSuite) TestListNamespaces() { + t := s.T() + + reqs := []*flipt.CreateNamespaceRequest{ + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + } + + for _, req := range reqs { + _, err := s.store.CreateNamespace(context.TODO(), req) + require.NoError(t, err) + } + + res, err := s.store.ListNamespaces(context.TODO()) + require.NoError(t, err) + + got := res.Results + assert.NotZero(t, len(got)) + + for _, ns := range got { + assert.NotZero(t, ns.CreatedAt) + assert.NotZero(t, ns.UpdatedAt) + } +} + +func (s *DBTestSuite) TestListNamespacesPagination_LimitOffset() { + t := s.T() + + reqs := []*flipt.CreateNamespaceRequest{ + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + } + + for _, req := range reqs { + _, err := s.store.CreateNamespace(context.TODO(), req) + require.NoError(t, err) + } + + oldest, middle, newest := reqs[0], reqs[1], reqs[2] + + // TODO: the ordering (DESC) is required because the default ordering is ASC and we are not clearing the DB between tests + // get middle namespace + res, err := s.store.ListNamespaces(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(1)) + require.NoError(t, err) + + got := res.Results + assert.Len(t, got, 1) + + assert.Equal(t, middle.Key, got[0].Key) + + // get first (newest) namespace + res, err = s.store.ListNamespaces(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)) + require.NoError(t, err) + + got = res.Results + assert.Len(t, got, 1) + + assert.Equal(t, newest.Key, got[0].Key) + + // get last (oldest) namespace + res, err = s.store.ListNamespaces(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(2)) + require.NoError(t, err) + + got = res.Results + assert.Len(t, got, 1) + + assert.Equal(t, oldest.Key, got[0].Key) + + // get all namespaces + res, err = s.store.ListNamespaces(context.TODO(), storage.WithOrder(storage.OrderDesc)) + require.NoError(t, err) + + got = res.Results + + assert.Equal(t, newest.Key, got[0].Key) + assert.Equal(t, middle.Key, got[1].Key) + assert.Equal(t, oldest.Key, got[2].Key) +} + +func (s *DBTestSuite) TestListNamespacesPagination_LimitWithNextPage() { + t := s.T() + + reqs := []*flipt.CreateNamespaceRequest{ + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + } + + for _, req := range reqs { + _, err := s.store.CreateNamespace(context.TODO(), req) + require.NoError(t, err) + } + + oldest, middle, newest := reqs[0], reqs[1], reqs[2] + + // TODO: the ordering (DESC) is required because the default ordering is ASC and we are not clearing the DB between tests + // get newest namespace + opts := []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)} + + res, err := s.store.ListNamespaces(context.TODO(), opts...) + require.NoError(t, err) + + got := res.Results + assert.Len(t, got, 1) + assert.Equal(t, newest.Key, got[0].Key) + assert.NotEmpty(t, res.NextPageToken) + + pageToken := &common.PageToken{} + err = json.Unmarshal([]byte(res.NextPageToken), pageToken) + require.NoError(t, err) + // next page should be the middle namespace + assert.Equal(t, middle.Key, pageToken.Key) + assert.NotZero(t, pageToken.Offset) + + opts = append(opts, storage.WithPageToken(res.NextPageToken)) + + // get middle namespace + res, err = s.store.ListNamespaces(context.TODO(), opts...) + require.NoError(t, err) + + got = res.Results + assert.Len(t, got, 1) + assert.Equal(t, middle.Key, got[0].Key) + + err = json.Unmarshal([]byte(res.NextPageToken), pageToken) + require.NoError(t, err) + // next page should be the oldest namespace + assert.Equal(t, oldest.Key, pageToken.Key) + assert.NotZero(t, pageToken.Offset) + + opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithPageToken(res.NextPageToken)} + + // get oldest namespace + res, err = s.store.ListNamespaces(context.TODO(), opts...) + require.NoError(t, err) + + got = res.Results + assert.Len(t, got, 1) + assert.Equal(t, oldest.Key, got[0].Key) + + opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(3)} + // get all namespaces + res, err = s.store.ListNamespaces(context.TODO(), opts...) + require.NoError(t, err) + + got = res.Results + assert.Len(t, got, 3) + assert.Equal(t, newest.Key, got[0].Key) + assert.Equal(t, middle.Key, got[1].Key) + assert.Equal(t, oldest.Key, got[2].Key) +} + +func (s *DBTestSuite) TestCreateNamespace() { + t := s.T() + + ns, err := s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + + assert.Equal(t, t.Name(), ns.Key) + assert.Equal(t, "foo", ns.Name) + assert.Equal(t, "bar", ns.Description) + assert.NotZero(t, ns.CreatedAt) + assert.Equal(t, ns.CreatedAt.Seconds, ns.UpdatedAt.Seconds) +} + +func (s *DBTestSuite) TestCreateNamespace_DuplicateKey() { + t := s.T() + + _, err := s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + + _, err = s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, "namespace \"TestDBTestSuite/TestCreateNamespace_DuplicateKey\" is not unique") +} + +func (s *DBTestSuite) TestUpdateNamespace() { + t := s.T() + + ns, err := s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + + assert.Equal(t, t.Name(), ns.Key) + assert.Equal(t, "foo", ns.Name) + assert.Equal(t, "bar", ns.Description) + assert.NotZero(t, ns.CreatedAt) + assert.Equal(t, ns.CreatedAt.Seconds, ns.UpdatedAt.Seconds) + + updated, err := s.store.UpdateNamespace(context.TODO(), &flipt.UpdateNamespaceRequest{ + Key: ns.Key, + Name: ns.Name, + Description: "foobar", + }) + + require.NoError(t, err) + + assert.Equal(t, ns.Key, updated.Key) + assert.Equal(t, ns.Name, updated.Name) + assert.Equal(t, "foobar", updated.Description) + assert.NotZero(t, updated.CreatedAt) + assert.NotZero(t, updated.UpdatedAt) +} + +func (s *DBTestSuite) TestUpdateNamespace_NotFound() { + t := s.T() + + _, err := s.store.UpdateNamespace(context.TODO(), &flipt.UpdateNamespaceRequest{ + Key: "foo", + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, "namespace \"foo\" not found") +} + +func (s *DBTestSuite) TestDeleteNamespace() { + t := s.T() + + ns, err := s.store.CreateNamespace(context.TODO(), &flipt.CreateNamespaceRequest{ + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, ns) + + err = s.store.DeleteNamespace(context.TODO(), &flipt.DeleteNamespaceRequest{Key: ns.Key}) + require.NoError(t, err) +} + +func (s *DBTestSuite) TestDeleteNamespace_NotFound() { + t := s.T() + + err := s.store.DeleteNamespace(context.TODO(), &flipt.DeleteNamespaceRequest{Key: "foo"}) + require.NoError(t, err) +} diff --git a/internal/storage/sql/postgres/postgres.go b/internal/storage/sql/postgres/postgres.go index 200863ac0a..c2a0b28cfd 100644 --- a/internal/storage/sql/postgres/postgres.go +++ b/internal/storage/sql/postgres/postgres.go @@ -38,14 +38,35 @@ func (s *Store) String() string { return "postgres" } +func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + namespace, err := s.Store.CreateNamespace(ctx, r) + + if err != nil { + var perr *pq.Error + + if errors.As(err, &perr) && perr.Code.Name() == constraintUniqueErr { + return nil, errs.ErrInvalidf(`namespace %q is not unique`, r.Key) + } + + return nil, err + } + + return namespace, nil +} + func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { flag, err := s.Store.CreateFlag(ctx, r) if err != nil { var perr *pq.Error - if errors.As(err, &perr) && perr.Code.Name() == constraintUniqueErr { - return nil, errs.ErrInvalidf("flag %q is not unique", r.Key) + if errors.As(err, &perr) { + switch perr.Code.Name() { + case constraintForeignKeyErr: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case constraintUniqueErr: + return nil, errs.ErrInvalidf(`flag "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -63,9 +84,9 @@ func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest if errors.As(err, &perr) { switch perr.Code.Name() { case constraintForeignKeyErr: - return nil, errs.ErrNotFoundf("flag %q", r.FlagKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s"`, r.NamespaceKey, r.FlagKey) case constraintUniqueErr: - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } } @@ -82,7 +103,7 @@ func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest var perr *pq.Error if errors.As(err, &perr) && perr.Code.Name() == constraintUniqueErr { - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } return nil, err @@ -97,8 +118,13 @@ func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest if err != nil { var perr *pq.Error - if errors.As(err, &perr) && perr.Code.Name() == constraintUniqueErr { - return nil, errs.ErrInvalidf("segment %q is not unique", r.Key) + if errors.As(err, &perr) { + switch perr.Code.Name() { + case constraintForeignKeyErr: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case constraintUniqueErr: + return nil, errs.ErrInvalidf(`segment "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -114,7 +140,7 @@ func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintR var perr *pq.Error if errors.As(err, &perr) && perr.Code.Name() == constraintForeignKeyErr { - return nil, errs.ErrNotFoundf("segment %q", r.SegmentKey) + return nil, errs.ErrNotFoundf(`segment "%s/%s"`, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -130,7 +156,7 @@ func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*fl var perr *pq.Error if errors.As(err, &perr) && perr.Code.Name() == constraintForeignKeyErr { - return nil, errs.ErrNotFoundf("flag %q or segment %q", r.FlagKey, r.SegmentKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s" or segment "%s/%s"`, r.NamespaceKey, r.FlagKey, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -146,7 +172,7 @@ func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistribut var perr *pq.Error if errors.As(err, &perr) && perr.Code.Name() == constraintForeignKeyErr { - return nil, errs.ErrNotFoundf("rule %q", r.RuleId) + return nil, errs.ErrNotFoundf("variant %q, rule %q, flag %q in namespace %q", r.VariantId, r.RuleId, r.FlagKey, r.NamespaceKey) } return nil, err diff --git a/internal/storage/sql/rule_test.go b/internal/storage/sql/rule_test.go index 55820e1c77..ef4b0b70c0 100644 --- a/internal/storage/sql/rule_test.go +++ b/internal/storage/sql/rule_test.go @@ -54,12 +54,72 @@ func (s *DBTestSuite) TestGetRule() { require.NoError(t, err) assert.NotNil(t, rule) - got, err := s.store.GetRule(context.TODO(), rule.Id) + got, err := s.store.GetRule(context.TODO(), storage.DefaultNamespace, rule.Id) require.NoError(t, err) assert.NotNil(t, got) assert.Equal(t, rule.Id, got.Id) + assert.Equal(t, storage.DefaultNamespace, got.NamespaceKey) + assert.Equal(t, rule.FlagKey, got.FlagKey) + assert.Equal(t, rule.SegmentKey, got.SegmentKey) + assert.Equal(t, rule.Rank, got.Rank) + assert.NotZero(t, got.CreatedAt) + assert.NotZero(t, got.UpdatedAt) +} + +func (s *DBTestSuite) TestGetRuleNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 1, + }) + + require.NoError(t, err) + assert.NotNil(t, rule) + + got, err := s.store.GetRule(context.TODO(), s.namespace, rule.Id) + + require.NoError(t, err) + assert.NotNil(t, got) + + assert.Equal(t, rule.Id, got.Id) + assert.Equal(t, s.namespace, got.NamespaceKey) assert.Equal(t, rule.FlagKey, got.FlagKey) assert.Equal(t, rule.SegmentKey, got.SegmentKey) assert.Equal(t, rule.Rank, got.Rank) @@ -70,8 +130,15 @@ func (s *DBTestSuite) TestGetRule() { func (s *DBTestSuite) TestGetRule_NotFound() { t := s.T() - _, err := s.store.GetRule(context.TODO(), "0") - assert.EqualError(t, err, "rule \"0\" not found") + _, err := s.store.GetRule(context.TODO(), storage.DefaultNamespace, "0") + assert.EqualError(t, err, "rule \"default/0\" not found") +} + +func (s *DBTestSuite) TestGetRuleNamespace_NotFound() { + t := s.T() + + _, err := s.store.GetRule(context.TODO(), s.namespace, "0") + assert.EqualError(t, err, fmt.Sprintf("rule \"%s/0\" not found", s.namespace)) } func (s *DBTestSuite) TestListRules() { @@ -124,10 +191,85 @@ func (s *DBTestSuite) TestListRules() { require.NoError(t, err) } - got, err := s.store.ListRules(context.TODO(), flag.Key) + res, err := s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key) + require.NoError(t, err) + + got := res.Results + assert.NotZero(t, len(got)) + + for _, rule := range got { + assert.Equal(t, storage.DefaultNamespace, rule.NamespaceKey) + assert.NotZero(t, rule.CreatedAt) + assert.NotZero(t, rule.UpdatedAt) + } +} + +func (s *DBTestSuite) TestListRulesNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) require.NoError(t, err) - assert.NotZero(t, len(got.Results)) + assert.NotNil(t, segment) + + reqs := []*flipt.CreateRuleRequest{ + { + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 1, + }, + { + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 2, + }, + } + + for _, req := range reqs { + _, err := s.store.CreateRule(context.TODO(), req) + require.NoError(t, err) + } + + res, err := s.store.ListRules(context.TODO(), s.namespace, flag.Key) + require.NoError(t, err) + + got := res.Results + assert.NotZero(t, len(got)) + + for _, rule := range got { + assert.Equal(t, s.namespace, rule.NamespaceKey) + assert.NotZero(t, rule.CreatedAt) + assert.NotZero(t, rule.UpdatedAt) + } } func (s *DBTestSuite) TestListRulesPagination_LimitOffset() { @@ -180,7 +322,7 @@ func (s *DBTestSuite) TestListRulesPagination_LimitOffset() { require.NoError(t, err) } - res, err := s.store.ListRules(context.TODO(), flag.Key, storage.WithLimit(1), storage.WithOffset(1)) + res, err := s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key, storage.WithLimit(1), storage.WithOffset(1)) require.NoError(t, err) got := res.Results @@ -240,7 +382,7 @@ func (s *DBTestSuite) TestListRulesPagination_LimitWithNextPage() { // TODO: the ordering (DESC) is required because the default ordering is ASC and we are not clearing the DB between tests opts := []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)} - res, err := s.store.ListRules(context.TODO(), flag.Key, opts...) + res, err := s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key, opts...) require.NoError(t, err) got := res.Results @@ -256,7 +398,7 @@ func (s *DBTestSuite) TestListRulesPagination_LimitWithNextPage() { opts = append(opts, storage.WithPageToken(res.NextPageToken)) - res, err = s.store.ListRules(context.TODO(), flag.Key, opts...) + res, err = s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key, opts...) require.NoError(t, err) got = res.Results @@ -313,6 +455,7 @@ func (s *DBTestSuite) TestCreateRuleAndDistribution() { assert.Equal(t, rule.CreatedAt.Seconds, rule.UpdatedAt.Seconds) distribution, err := s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + FlagKey: flag.Key, RuleId: rule.Id, VariantId: variant.Id, Rollout: 100, @@ -327,6 +470,76 @@ func (s *DBTestSuite) TestCreateRuleAndDistribution() { assert.Equal(t, distribution.CreatedAt.Seconds, distribution.UpdatedAt.Seconds) } +func (s *DBTestSuite) TestCreateRuleAndDistributionNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: 1, + }) + + require.NoError(t, err) + assert.NotNil(t, rule) + + assert.Equal(t, s.namespace, rule.NamespaceKey) + assert.NotZero(t, rule.Id) + assert.Equal(t, flag.Key, rule.FlagKey) + assert.Equal(t, segment.Key, rule.SegmentKey) + assert.Equal(t, int32(1), rule.Rank) + assert.NotZero(t, rule.CreatedAt) + assert.Equal(t, rule.CreatedAt.Seconds, rule.UpdatedAt.Seconds) + + distribution, err := s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + RuleId: rule.Id, + VariantId: variant.Id, + Rollout: 100, + }) + + require.NoError(t, err) + assert.NotZero(t, distribution.Id) + assert.Equal(t, rule.Id, distribution.RuleId) + assert.Equal(t, variant.Id, distribution.VariantId) + assert.Equal(t, float32(100), distribution.Rollout) + assert.NotZero(t, distribution.CreatedAt) + assert.Equal(t, distribution.CreatedAt.Seconds, distribution.UpdatedAt.Seconds) +} + func (s *DBTestSuite) TestCreateDistribution_NoRule() { t := s.T() @@ -351,12 +564,13 @@ func (s *DBTestSuite) TestCreateDistribution_NoRule() { assert.NotNil(t, variant) _, err = s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + FlagKey: flag.Key, RuleId: "foo", VariantId: variant.Id, Rollout: 100, }) - assert.EqualError(t, err, "rule \"foo\" not found") + assert.EqualError(t, err, fmt.Sprintf("variant %q, rule %q, flag %q in namespace %q not found", variant.Id, "foo", flag.Key, "default")) } func (s *DBTestSuite) TestCreateRule_FlagNotFound() { @@ -368,7 +582,20 @@ func (s *DBTestSuite) TestCreateRule_FlagNotFound() { Rank: 1, }) - assert.EqualError(t, err, "flag \"foo\" or segment \"bar\" not found") + assert.EqualError(t, err, "flag \"default/foo\" or segment \"default/bar\" not found") +} + +func (s *DBTestSuite) TestCreateRuleNamespace_FlagNotFound() { + t := s.T() + + _, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: "foo", + SegmentKey: "bar", + Rank: 1, + }) + + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/foo\" or segment \"%s/bar\" not found", s.namespace, s.namespace)) } func (s *DBTestSuite) TestCreateRule_SegmentNotFound() { @@ -390,7 +617,31 @@ func (s *DBTestSuite) TestCreateRule_SegmentNotFound() { Rank: 1, }) - assert.EqualError(t, err, "flag \"TestDBTestSuite/TestCreateRule_SegmentNotFound\" or segment \"foo\" not found") + assert.EqualError(t, err, "flag \"default/TestDBTestSuite/TestCreateRule_SegmentNotFound\" or segment \"default/foo\" not found") +} + +func (s *DBTestSuite) TestCreateRuleNamespace_SegmentNotFound() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + _, err = s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: "foo", + Rank: 1, + }) + + assert.EqualError(t, err, fmt.Sprintf("flag \"%s/%s\" or segment \"%s/foo\" not found", s.namespace, t.Name(), s.namespace)) } func (s *DBTestSuite) TestUpdateRuleAndDistribution() { @@ -442,6 +693,7 @@ func (s *DBTestSuite) TestUpdateRuleAndDistribution() { assert.Equal(t, rule.CreatedAt.Seconds, rule.UpdatedAt.Seconds) distribution, err := s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + FlagKey: flag.Key, RuleId: rule.Id, VariantId: variant.Id, Rollout: 100, @@ -481,6 +733,7 @@ func (s *DBTestSuite) TestUpdateRuleAndDistribution() { assert.NotZero(t, rule.UpdatedAt) updatedDistribution, err := s.store.UpdateDistribution(context.TODO(), &flipt.UpdateDistributionRequest{ + FlagKey: flag.Key, Id: distribution.Id, RuleId: rule.Id, VariantId: variant.Id, @@ -503,6 +756,128 @@ func (s *DBTestSuite) TestUpdateRuleAndDistribution() { require.NoError(t, err) } +func (s *DBTestSuite) TestUpdateRuleAndDistributionNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segmentOne, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: fmt.Sprintf("%s_one", t.Name()), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segmentOne) + + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segmentOne.Key, + Rank: 1, + }) + + require.NoError(t, err) + assert.NotNil(t, rule) + + assert.Equal(t, s.namespace, rule.NamespaceKey) + assert.NotZero(t, rule.Id) + assert.Equal(t, flag.Key, rule.FlagKey) + assert.Equal(t, segmentOne.Key, rule.SegmentKey) + assert.Equal(t, int32(1), rule.Rank) + assert.NotZero(t, rule.CreatedAt) + assert.Equal(t, rule.CreatedAt.Seconds, rule.UpdatedAt.Seconds) + + distribution, err := s.store.CreateDistribution(context.TODO(), &flipt.CreateDistributionRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + RuleId: rule.Id, + VariantId: variant.Id, + Rollout: 100, + }) + + require.NoError(t, err) + assert.NotZero(t, distribution.Id) + assert.Equal(t, rule.Id, distribution.RuleId) + assert.Equal(t, variant.Id, distribution.VariantId) + assert.Equal(t, float32(100), distribution.Rollout) + assert.NotZero(t, distribution.CreatedAt) + assert.Equal(t, distribution.CreatedAt.Seconds, distribution.UpdatedAt.Seconds) + + segmentTwo, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: fmt.Sprintf("%s_two", t.Name()), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segmentTwo) + + updatedRule, err := s.store.UpdateRule(context.TODO(), &flipt.UpdateRuleRequest{ + NamespaceKey: s.namespace, + Id: rule.Id, + FlagKey: flag.Key, + SegmentKey: segmentTwo.Key, + }) + + require.NoError(t, err) + assert.NotNil(t, updatedRule) + + assert.Equal(t, s.namespace, rule.NamespaceKey) + assert.Equal(t, rule.Id, updatedRule.Id) + assert.Equal(t, rule.FlagKey, updatedRule.FlagKey) + assert.Equal(t, segmentTwo.Key, updatedRule.SegmentKey) + assert.Equal(t, int32(1), updatedRule.Rank) + // assert.Equal(t, rule.CreatedAt.Seconds, updatedRule.CreatedAt.Seconds) + assert.NotZero(t, rule.UpdatedAt) + + updatedDistribution, err := s.store.UpdateDistribution(context.TODO(), &flipt.UpdateDistributionRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Id: distribution.Id, + RuleId: rule.Id, + VariantId: variant.Id, + Rollout: 10, + }) + + require.NoError(t, err) + assert.Equal(t, distribution.Id, updatedDistribution.Id) + assert.Equal(t, rule.Id, updatedDistribution.RuleId) + assert.Equal(t, variant.Id, updatedDistribution.VariantId) + assert.Equal(t, float32(10), updatedDistribution.Rollout) + // assert.Equal(t, distribution.CreatedAt.Seconds, updatedDistribution.CreatedAt.Seconds) + assert.NotZero(t, rule.UpdatedAt) + + err = s.store.DeleteDistribution(context.TODO(), &flipt.DeleteDistributionRequest{ + Id: distribution.Id, + RuleId: rule.Id, + VariantId: variant.Id, + }) + require.NoError(t, err) +} + func (s *DBTestSuite) TestUpdateRule_NotFound() { t := s.T() @@ -531,7 +906,41 @@ func (s *DBTestSuite) TestUpdateRule_NotFound() { SegmentKey: segment.Key, }) - assert.EqualError(t, err, "rule \"foo\" not found") + assert.EqualError(t, err, "rule \"default/foo\" not found") +} + +func (s *DBTestSuite) TestUpdateRuleNamespace_NotFound() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + _, err = s.store.UpdateRule(context.TODO(), &flipt.UpdateRuleRequest{ + NamespaceKey: s.namespace, + Id: "foo", + FlagKey: flag.Key, + SegmentKey: segment.Key, + }) + + assert.EqualError(t, err, fmt.Sprintf("rule \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestDeleteRule() { @@ -589,17 +998,94 @@ func (s *DBTestSuite) TestDeleteRule() { require.NoError(t, err) - res, err := s.store.ListRules(context.TODO(), flag.Key) + res, err := s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key) + // ensure rules are in correct order + require.NoError(t, err) + + got := res.Results + assert.NotNil(t, got) + assert.Equal(t, 2, len(got)) + assert.Equal(t, rules[0].Id, got[0].Id) + assert.Equal(t, int32(1), got[0].Rank) + assert.Equal(t, storage.DefaultNamespace, got[0].NamespaceKey) + assert.Equal(t, rules[2].Id, got[1].Id) + assert.Equal(t, int32(2), got[1].Rank) + assert.Equal(t, storage.DefaultNamespace, got[1].NamespaceKey) +} + +func (s *DBTestSuite) TestDeleteRuleNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + var rules []*flipt.Rule + + // create 3 rules + for i := 0; i < 3; i++ { + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: int32(i + 1), + }) + + require.NoError(t, err) + assert.NotNil(t, rule) + rules = append(rules, rule) + } + + // delete second rule + err = s.store.DeleteRule(context.TODO(), &flipt.DeleteRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Id: rules[1].Id, + }) + + require.NoError(t, err) + res, err := s.store.ListRules(context.TODO(), s.namespace, flag.Key) // ensure rules are in correct order require.NoError(t, err) + got := res.Results assert.NotNil(t, got) assert.Equal(t, 2, len(got)) assert.Equal(t, rules[0].Id, got[0].Id) assert.Equal(t, int32(1), got[0].Rank) + assert.Equal(t, s.namespace, got[0].NamespaceKey) assert.Equal(t, rules[2].Id, got[1].Id) assert.Equal(t, int32(2), got[1].Rank) + assert.Equal(t, s.namespace, got[1].NamespaceKey) } func (s *DBTestSuite) TestDeleteRule_NotFound() { @@ -623,6 +1109,29 @@ func (s *DBTestSuite) TestDeleteRule_NotFound() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteRuleNamespace_NotFound() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + err = s.store.DeleteRule(context.TODO(), &flipt.DeleteRuleRequest{ + NamespaceKey: s.namespace, + Id: "foo", + FlagKey: flag.Key, + }) + + require.NoError(t, err) +} + func (s *DBTestSuite) TestOrderRules() { t := s.T() @@ -686,17 +1195,112 @@ func (s *DBTestSuite) TestOrderRules() { require.NoError(t, err) - res, err := s.store.ListRules(context.TODO(), flag.Key) + res, err := s.store.ListRules(context.TODO(), storage.DefaultNamespace, flag.Key) // ensure rules are in correct order require.NoError(t, err) got := res.Results assert.NotNil(t, got) assert.Equal(t, 3, len(got)) + assert.Equal(t, rules[0].Id, got[0].Id) assert.Equal(t, int32(1), got[0].Rank) + assert.Equal(t, storage.DefaultNamespace, got[0].NamespaceKey) + assert.Equal(t, rules[1].Id, got[1].Id) assert.Equal(t, int32(2), got[1].Rank) + assert.Equal(t, storage.DefaultNamespace, got[1].NamespaceKey) + + assert.Equal(t, rules[2].Id, got[2].Id) + assert.Equal(t, int32(3), got[2].Rank) + assert.Equal(t, storage.DefaultNamespace, got[2].NamespaceKey) +} + +func (s *DBTestSuite) TestOrderRulesNamespace() { + t := s.T() + + flag, err := s.store.CreateFlag(context.TODO(), &flipt.CreateFlagRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + Enabled: true, + }) + + require.NoError(t, err) + assert.NotNil(t, flag) + + variant, err := s.store.CreateVariant(context.TODO(), &flipt.CreateVariantRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, variant) + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + var rules []*flipt.Rule + + // create 3 rules + for i := 0; i < 3; i++ { + rule, err := s.store.CreateRule(context.TODO(), &flipt.CreateRuleRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + SegmentKey: segment.Key, + Rank: int32(i + 1), + }) + + require.NoError(t, err) + assert.NotNil(t, rule) + rules = append(rules, rule) + } + + // order rules in reverse order + sort.Slice(rules, func(i, j int) bool { return rules[i].Rank > rules[j].Rank }) + + var ruleIds []string + for _, rule := range rules { + ruleIds = append(ruleIds, rule.Id) + } + + // re-order rules + err = s.store.OrderRules(context.TODO(), &flipt.OrderRulesRequest{ + NamespaceKey: s.namespace, + FlagKey: flag.Key, + RuleIds: ruleIds, + }) + + require.NoError(t, err) + + res, err := s.store.ListRules(context.TODO(), s.namespace, flag.Key) + + // ensure rules are in correct order + require.NoError(t, err) + got := res.Results + assert.NotNil(t, got) + assert.Equal(t, 3, len(got)) + + assert.Equal(t, rules[0].Id, got[0].Id) + assert.Equal(t, int32(1), got[0].Rank) + assert.Equal(t, s.namespace, got[0].NamespaceKey) + + assert.Equal(t, rules[1].Id, got[1].Id) + assert.Equal(t, int32(2), got[1].Rank) + assert.Equal(t, s.namespace, got[1].NamespaceKey) + assert.Equal(t, rules[2].Id, got[2].Id) assert.Equal(t, int32(3), got[2].Rank) + assert.Equal(t, s.namespace, got[2].NamespaceKey) } diff --git a/internal/storage/sql/segment_test.go b/internal/storage/sql/segment_test.go index 7da04fe3f4..82a15bd0ce 100644 --- a/internal/storage/sql/segment_test.go +++ b/internal/storage/sql/segment_test.go @@ -30,11 +30,12 @@ func (s *DBTestSuite) TestGetSegment() { require.NoError(t, err) assert.NotNil(t, segment) - got, err := s.store.GetSegment(context.TODO(), segment.Key) + got, err := s.store.GetSegment(context.TODO(), storage.DefaultNamespace, segment.Key) require.NoError(t, err) assert.NotNil(t, got) + assert.Equal(t, storage.DefaultNamespace, got.NamespaceKey) assert.Equal(t, segment.Key, got.Key) assert.Equal(t, segment.Name, got.Name) assert.Equal(t, segment.Description, got.Description) @@ -43,11 +44,46 @@ func (s *DBTestSuite) TestGetSegment() { assert.Equal(t, segment.MatchType, got.MatchType) } -func (s *DBTestSuite) TestGetSegmentNotFound() { +func (s *DBTestSuite) TestGetSegmentNamespace() { t := s.T() - _, err := s.store.GetSegment(context.TODO(), "foo") - assert.EqualError(t, err, "segment \"foo\" not found") + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + MatchType: flipt.MatchType_ALL_MATCH_TYPE, + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + got, err := s.store.GetSegment(context.TODO(), s.namespace, segment.Key) + + require.NoError(t, err) + assert.NotNil(t, got) + + assert.Equal(t, s.namespace, got.NamespaceKey) + assert.Equal(t, segment.Key, got.Key) + assert.Equal(t, segment.Name, got.Name) + assert.Equal(t, segment.Description, got.Description) + assert.NotZero(t, segment.CreatedAt) + assert.NotZero(t, segment.UpdatedAt) + assert.Equal(t, segment.MatchType, got.MatchType) +} + +func (s *DBTestSuite) TestGetSegment_NotFound() { + t := s.T() + + _, err := s.store.GetSegment(context.TODO(), storage.DefaultNamespace, "foo") + assert.EqualError(t, err, "segment \"default/foo\" not found") +} + +func (s *DBTestSuite) TestGetSegmentNamespace_NotFound() { + t := s.T() + + _, err := s.store.GetSegment(context.TODO(), s.namespace, "foo") + assert.EqualError(t, err, fmt.Sprintf("segment \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestListSegments() { @@ -71,10 +107,51 @@ func (s *DBTestSuite) TestListSegments() { require.NoError(t, err) } - res, err := s.store.ListSegments(context.TODO()) + res, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace) + require.NoError(t, err) + got := res.Results + assert.NotZero(t, len(got)) + + for _, segment := range got { + assert.Equal(t, storage.DefaultNamespace, segment.NamespaceKey) + assert.NotZero(t, segment.CreatedAt) + assert.NotZero(t, segment.UpdatedAt) + } +} + +func (s *DBTestSuite) TestListSegmentsNamespace() { + t := s.T() + + reqs := []*flipt.CreateSegmentRequest{ + { + NamespaceKey: s.namespace, + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + { + NamespaceKey: s.namespace, + Key: uuid.Must(uuid.NewV4()).String(), + Name: "foo", + Description: "bar", + }, + } + + for _, req := range reqs { + _, err := s.store.CreateSegment(context.TODO(), req) + require.NoError(t, err) + } + + res, err := s.store.ListSegments(context.TODO(), s.namespace) require.NoError(t, err) got := res.Results assert.NotZero(t, len(got)) + + for _, segment := range got { + assert.Equal(t, s.namespace, segment.NamespaceKey) + assert.NotZero(t, segment.CreatedAt) + assert.NotZero(t, segment.UpdatedAt) + } } func (s *DBTestSuite) TestListSegmentsPagination_LimitOffset() { @@ -111,7 +188,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitOffset() { // TODO: the ordering (DESC) is required because the default ordering is ASC and we are not clearing the DB between tests // get middle segment - res, err := s.store.ListSegments(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(1)) + res, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(1)) require.NoError(t, err) got := res.Results @@ -120,7 +197,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitOffset() { assert.Equal(t, middle.Key, got[0].Key) // get first (newest) segment - res, err = s.store.ListSegments(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)) require.NoError(t, err) got = res.Results @@ -129,7 +206,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitOffset() { assert.Equal(t, newest.Key, got[0].Key) // get last (oldest) segment - res, err = s.store.ListSegments(context.TODO(), storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(2)) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithOffset(2)) require.NoError(t, err) got = res.Results @@ -138,7 +215,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitOffset() { assert.Equal(t, oldest.Key, got[0].Key) // get all segments - res, err = s.store.ListSegments(context.TODO(), storage.WithOrder(storage.OrderDesc)) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithOrder(storage.OrderDesc)) require.NoError(t, err) got = res.Results @@ -184,7 +261,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitWithNextPage() { // get newest segment opts := []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1)} - res, err := s.store.ListSegments(context.TODO(), opts...) + res, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got := res.Results @@ -202,7 +279,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitWithNextPage() { opts = append(opts, storage.WithPageToken(res.NextPageToken)) // get middle segment - res, err = s.store.ListSegments(context.TODO(), opts...) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -218,7 +295,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitWithNextPage() { opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(1), storage.WithPageToken(res.NextPageToken)} // get oldest segment - res, err = s.store.ListSegments(context.TODO(), opts...) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -227,7 +304,7 @@ func (s *DBTestSuite) TestListSegmentsPagination_LimitWithNextPage() { opts = []storage.QueryOption{storage.WithOrder(storage.OrderDesc), storage.WithLimit(3)} // get all segments - res, err = s.store.ListSegments(context.TODO(), opts...) + res, err = s.store.ListSegments(context.TODO(), storage.DefaultNamespace, opts...) require.NoError(t, err) got = res.Results @@ -257,6 +334,28 @@ func (s *DBTestSuite) TestCreateSegment() { assert.Equal(t, segment.CreatedAt.Seconds, segment.UpdatedAt.Seconds) } +func (s *DBTestSuite) TestCreateSegmentNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + MatchType: flipt.MatchType_ANY_MATCH_TYPE, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, segment.NamespaceKey) + assert.Equal(t, t.Name(), segment.Key) + assert.Equal(t, "foo", segment.Name) + assert.Equal(t, "bar", segment.Description) + assert.Equal(t, flipt.MatchType_ANY_MATCH_TYPE, segment.MatchType) + assert.NotZero(t, segment.CreatedAt) + assert.Equal(t, segment.CreatedAt.Seconds, segment.UpdatedAt.Seconds) +} + func (s *DBTestSuite) TestCreateSegment_DuplicateKey() { t := s.T() @@ -274,7 +373,29 @@ func (s *DBTestSuite) TestCreateSegment_DuplicateKey() { Description: "bar", }) - assert.EqualError(t, err, "segment \"TestDBTestSuite/TestCreateSegment_DuplicateKey\" is not unique") + assert.EqualError(t, err, "segment \"default/TestDBTestSuite/TestCreateSegment_DuplicateKey\" is not unique") +} + +func (s *DBTestSuite) TestCreateSegmentNamespace_DuplicateKey() { + t := s.T() + + _, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + + _, err = s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, fmt.Sprintf("segment \"%s/%s\" is not unique", s.namespace, t.Name())) } func (s *DBTestSuite) TestUpdateSegment() { @@ -289,6 +410,7 @@ func (s *DBTestSuite) TestUpdateSegment() { require.NoError(t, err) + assert.Equal(t, storage.DefaultNamespace, segment.NamespaceKey) assert.Equal(t, t.Name(), segment.Key) assert.Equal(t, "foo", segment.Name) assert.Equal(t, "bar", segment.Description) @@ -305,6 +427,46 @@ func (s *DBTestSuite) TestUpdateSegment() { require.NoError(t, err) + assert.Equal(t, storage.DefaultNamespace, updated.NamespaceKey) + assert.Equal(t, segment.Key, updated.Key) + assert.Equal(t, segment.Name, updated.Name) + assert.Equal(t, "foobar", updated.Description) + assert.Equal(t, flipt.MatchType_ANY_MATCH_TYPE, updated.MatchType) + assert.NotZero(t, updated.CreatedAt) + assert.NotZero(t, updated.UpdatedAt) +} +func (s *DBTestSuite) TestUpdateSegmentNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + MatchType: flipt.MatchType_ALL_MATCH_TYPE, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, segment.NamespaceKey) + assert.Equal(t, t.Name(), segment.Key) + assert.Equal(t, "foo", segment.Name) + assert.Equal(t, "bar", segment.Description) + assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, segment.MatchType) + assert.NotZero(t, segment.CreatedAt) + assert.Equal(t, segment.CreatedAt.Seconds, segment.UpdatedAt.Seconds) + + updated, err := s.store.UpdateSegment(context.TODO(), &flipt.UpdateSegmentRequest{ + NamespaceKey: s.namespace, + Key: segment.Key, + Name: segment.Name, + Description: "foobar", + MatchType: flipt.MatchType_ANY_MATCH_TYPE, + }) + + require.NoError(t, err) + + assert.Equal(t, s.namespace, updated.NamespaceKey) assert.Equal(t, segment.Key, updated.Key) assert.Equal(t, segment.Name, updated.Name) assert.Equal(t, "foobar", updated.Description) @@ -322,7 +484,20 @@ func (s *DBTestSuite) TestUpdateSegment_NotFound() { Description: "bar", }) - assert.EqualError(t, err, "segment \"foo\" not found") + assert.EqualError(t, err, "segment \"default/foo\" not found") +} + +func (s *DBTestSuite) TestUpdateSegmentNamespace_NotFound() { + t := s.T() + + _, err := s.store.UpdateSegment(context.TODO(), &flipt.UpdateSegmentRequest{ + NamespaceKey: s.namespace, + Key: "foo", + Name: "foo", + Description: "bar", + }) + + assert.EqualError(t, err, fmt.Sprintf("segment \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestDeleteSegment() { @@ -341,6 +516,26 @@ func (s *DBTestSuite) TestDeleteSegment() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteSegmentNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + err = s.store.DeleteSegment(context.TODO(), &flipt.DeleteSegmentRequest{ + NamespaceKey: s.namespace, + Key: segment.Key, + }) + require.NoError(t, err) +} + func (s *DBTestSuite) TestDeleteSegment_ExistingRule() { t := s.T() // TODO @@ -413,6 +608,16 @@ func (s *DBTestSuite) TestDeleteSegment_NotFound() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteSegmentNamespace_NotFound() { + t := s.T() + + err := s.store.DeleteSegment(context.TODO(), &flipt.DeleteSegmentRequest{ + NamespaceKey: s.namespace, + Key: "foo", + }) + require.NoError(t, err) +} + func (s *DBTestSuite) TestCreateConstraint() { t := s.T() @@ -437,6 +642,7 @@ func (s *DBTestSuite) TestCreateConstraint() { assert.NotNil(t, constraint) assert.NotZero(t, constraint.Id) + assert.Equal(t, storage.DefaultNamespace, constraint.NamespaceKey) assert.Equal(t, segment.Key, constraint.SegmentKey) assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, constraint.Type) assert.Equal(t, "foo", constraint.Property) @@ -446,7 +652,51 @@ func (s *DBTestSuite) TestCreateConstraint() { assert.Equal(t, constraint.CreatedAt.Seconds, constraint.UpdatedAt.Seconds) // get the segment again - segment, err = s.store.GetSegment(context.TODO(), segment.Key) + segment, err = s.store.GetSegment(context.TODO(), storage.DefaultNamespace, segment.Key) + + require.NoError(t, err) + assert.NotNil(t, segment) + + assert.Len(t, segment.Constraints, 1) +} + +func (s *DBTestSuite) TestCreateConstraintNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + constraint, err := s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EQ", + Value: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, constraint) + + assert.NotZero(t, constraint.Id) + assert.Equal(t, s.namespace, constraint.NamespaceKey) + assert.Equal(t, segment.Key, constraint.SegmentKey) + assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, constraint.Type) + assert.Equal(t, "foo", constraint.Property) + assert.Equal(t, flipt.OpEQ, constraint.Operator) + assert.Equal(t, "bar", constraint.Value) + assert.NotZero(t, constraint.CreatedAt) + assert.Equal(t, constraint.CreatedAt.Seconds, constraint.UpdatedAt.Seconds) + + // get the segment again + segment, err = s.store.GetSegment(context.TODO(), s.namespace, segment.Key) require.NoError(t, err) assert.NotNil(t, segment) @@ -465,7 +715,22 @@ func (s *DBTestSuite) TestCreateConstraint_SegmentNotFound() { Value: "baz", }) - assert.EqualError(t, err, "segment \"foo\" not found") + assert.EqualError(t, err, "segment \"default/foo\" not found") +} + +func (s *DBTestSuite) TestCreateConstraintNamespace_SegmentNotFound() { + t := s.T() + + _, err := s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: "foo", + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "NEQ", + Value: "baz", + }) + + assert.EqualError(t, err, fmt.Sprintf("segment \"%s/foo\" not found", s.namespace)) } func (s *DBTestSuite) TestUpdateConstraint() { @@ -492,6 +757,7 @@ func (s *DBTestSuite) TestUpdateConstraint() { assert.NotNil(t, constraint) assert.NotZero(t, constraint.Id) + assert.Equal(t, storage.DefaultNamespace, constraint.NamespaceKey) assert.Equal(t, segment.Key, constraint.SegmentKey) assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, constraint.Type) assert.Equal(t, "foo", constraint.Property) @@ -512,6 +778,7 @@ func (s *DBTestSuite) TestUpdateConstraint() { require.NoError(t, err) assert.Equal(t, constraint.Id, updated.Id) + assert.Equal(t, storage.DefaultNamespace, updated.NamespaceKey) assert.Equal(t, constraint.SegmentKey, updated.SegmentKey) assert.Equal(t, constraint.Type, updated.Type) assert.Equal(t, constraint.Property, updated.Property) @@ -521,7 +788,73 @@ func (s *DBTestSuite) TestUpdateConstraint() { assert.NotZero(t, updated.UpdatedAt) // get the segment again - segment, err = s.store.GetSegment(context.TODO(), segment.Key) + segment, err = s.store.GetSegment(context.TODO(), storage.DefaultNamespace, segment.Key) + + require.NoError(t, err) + assert.NotNil(t, segment) + + assert.Len(t, segment.Constraints, 1) +} + +func (s *DBTestSuite) TestUpdateConstraintNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + constraint, err := s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EQ", + Value: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, constraint) + + assert.NotZero(t, constraint.Id) + assert.Equal(t, s.namespace, constraint.NamespaceKey) + assert.Equal(t, segment.Key, constraint.SegmentKey) + assert.Equal(t, flipt.ComparisonType_STRING_COMPARISON_TYPE, constraint.Type) + assert.Equal(t, "foo", constraint.Property) + assert.Equal(t, flipt.OpEQ, constraint.Operator) + assert.Equal(t, "bar", constraint.Value) + assert.NotZero(t, constraint.CreatedAt) + assert.Equal(t, constraint.CreatedAt.Seconds, constraint.UpdatedAt.Seconds) + + updated, err := s.store.UpdateConstraint(context.TODO(), &flipt.UpdateConstraintRequest{ + Id: constraint.Id, + NamespaceKey: s.namespace, + SegmentKey: constraint.SegmentKey, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EMPTY", + Value: "bar", + }) + + require.NoError(t, err) + + assert.Equal(t, constraint.Id, updated.Id) + assert.Equal(t, s.namespace, updated.NamespaceKey) + assert.Equal(t, constraint.SegmentKey, updated.SegmentKey) + assert.Equal(t, constraint.Type, updated.Type) + assert.Equal(t, constraint.Property, updated.Property) + assert.Equal(t, flipt.OpEmpty, updated.Operator) + assert.Empty(t, updated.Value) + assert.NotZero(t, updated.CreatedAt) + assert.NotZero(t, updated.UpdatedAt) + + // get the segment again + segment, err = s.store.GetSegment(context.TODO(), s.namespace, segment.Key) require.NoError(t, err) assert.NotNil(t, segment) @@ -553,6 +886,32 @@ func (s *DBTestSuite) TestUpdateConstraint_NotFound() { assert.EqualError(t, err, "constraint \"foo\" not found") } +func (s *DBTestSuite) TestUpdateConstraintNamespace_NotFound() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + _, err = s.store.UpdateConstraint(context.TODO(), &flipt.UpdateConstraintRequest{ + Id: "foo", + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "NEQ", + Value: "baz", + }) + + assert.EqualError(t, err, "constraint \"foo\" not found") +} + func (s *DBTestSuite) TestDeleteConstraint() { t := s.T() @@ -580,7 +939,48 @@ func (s *DBTestSuite) TestDeleteConstraint() { require.NoError(t, err) // get the segment again - segment, err = s.store.GetSegment(context.TODO(), segment.Key) + segment, err = s.store.GetSegment(context.TODO(), storage.DefaultNamespace, segment.Key) + + require.NoError(t, err) + assert.NotNil(t, segment) + + assert.Empty(t, segment.Constraints) +} + +func (s *DBTestSuite) TestDeleteConstraintNamespace() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + constraint, err := s.store.CreateConstraint(context.TODO(), &flipt.CreateConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + Type: flipt.ComparisonType_STRING_COMPARISON_TYPE, + Property: "foo", + Operator: "EQ", + Value: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, constraint) + + err = s.store.DeleteConstraint(context.TODO(), &flipt.DeleteConstraintRequest{ + NamespaceKey: s.namespace, + SegmentKey: constraint.SegmentKey, + Id: constraint.Id, + }) + require.NoError(t, err) + + // get the segment again + segment, err = s.store.GetSegment(context.TODO(), s.namespace, segment.Key) require.NoError(t, err) assert.NotNil(t, segment) @@ -608,6 +1008,28 @@ func (s *DBTestSuite) TestDeleteConstraint_NotFound() { require.NoError(t, err) } +func (s *DBTestSuite) TestDeleteConstraintNamespace_NotFound() { + t := s.T() + + segment, err := s.store.CreateSegment(context.TODO(), &flipt.CreateSegmentRequest{ + NamespaceKey: s.namespace, + Key: t.Name(), + Name: "foo", + Description: "bar", + }) + + require.NoError(t, err) + assert.NotNil(t, segment) + + err = s.store.DeleteConstraint(context.TODO(), &flipt.DeleteConstraintRequest{ + Id: "foo", + NamespaceKey: s.namespace, + SegmentKey: segment.Key, + }) + + require.NoError(t, err) +} + func BenchmarkListSegments(b *testing.B) { s := new(DBTestSuite) t := &testing.T{} @@ -646,7 +1068,7 @@ func BenchmarkListSegments(b *testing.B) { b.Run("no-pagination", func(b *testing.B) { for i := 0; i < b.N; i++ { - segments, err := s.store.ListSegments(context.TODO()) + segments, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace) require.NoError(t, err) assert.NotEmpty(t, segments) } @@ -656,7 +1078,7 @@ func BenchmarkListSegments(b *testing.B) { pageSize := pageSize b.Run(fmt.Sprintf("pagination-limit-%d", pageSize), func(b *testing.B) { for i := 0; i < b.N; i++ { - segments, err := s.store.ListSegments(context.TODO(), storage.WithLimit(pageSize)) + segments, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithLimit(pageSize)) require.NoError(t, err) assert.NotEmpty(t, segments) } @@ -665,7 +1087,7 @@ func BenchmarkListSegments(b *testing.B) { b.Run("pagination", func(b *testing.B) { for i := 0; i < b.N; i++ { - segments, err := s.store.ListSegments(context.TODO(), storage.WithLimit(500), storage.WithOffset(50), storage.WithOrder(storage.OrderDesc)) + segments, err := s.store.ListSegments(context.TODO(), storage.DefaultNamespace, storage.WithLimit(500), storage.WithOffset(50), storage.WithOrder(storage.OrderDesc)) require.NoError(t, err) assert.NotEmpty(t, segments) } diff --git a/internal/storage/sql/sqlite/sqlite.go b/internal/storage/sql/sqlite/sqlite.go index e7dcac4be4..ce27262608 100644 --- a/internal/storage/sql/sqlite/sqlite.go +++ b/internal/storage/sql/sqlite/sqlite.go @@ -35,14 +35,35 @@ func (s *Store) String() string { return "sqlite" } +func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + namespace, err := s.Store.CreateNamespace(ctx, r) + + if err != nil { + var serr sqlite3.Error + + if errors.As(err, &serr) && serr.ExtendedCode == sqlite3.ErrConstraintPrimaryKey { + return nil, errs.ErrInvalidf(`namespace "%s" is not unique`, r.Key) + } + + return nil, err + } + + return namespace, nil +} + func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) { flag, err := s.Store.CreateFlag(ctx, r) if err != nil { var serr sqlite3.Error - if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrInvalidf("flag %q is not unique", r.Key) + if errors.As(err, &serr) { + switch serr.ExtendedCode { + case sqlite3.ErrConstraintForeignKey: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case sqlite3.ErrConstraintPrimaryKey: + return nil, errs.ErrInvalidf(`flag "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -60,9 +81,9 @@ func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest if errors.As(err, &serr) { switch serr.ExtendedCode { case sqlite3.ErrConstraintForeignKey: - return nil, errs.ErrNotFoundf("flag %q", r.FlagKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s"`, r.NamespaceKey, r.FlagKey) case sqlite3.ErrConstraintUnique: - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } } @@ -79,7 +100,7 @@ func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest var serr sqlite3.Error if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrInvalidf("variant %q is not unique", r.Key) + return nil, errs.ErrInvalidf(`variant %q is not unique for flag "%s/%s"`, r.Key, r.NamespaceKey, r.FlagKey) } return nil, err @@ -94,8 +115,13 @@ func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest if err != nil { var serr sqlite3.Error - if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrInvalidf("segment %q is not unique", r.Key) + if errors.As(err, &serr) { + switch serr.ExtendedCode { + case sqlite3.ErrConstraintForeignKey: + return nil, errs.ErrNotFoundf("namespace %q", r.NamespaceKey) + case sqlite3.ErrConstraintPrimaryKey: + return nil, errs.ErrInvalidf(`segment "%s/%s" is not unique`, r.NamespaceKey, r.Key) + } } return nil, err @@ -111,7 +137,7 @@ func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintR var serr sqlite3.Error if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrNotFoundf("segment %q", r.SegmentKey) + return nil, errs.ErrNotFoundf(`segment "%s/%s"`, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -127,7 +153,7 @@ func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*fl var serr sqlite3.Error if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrNotFoundf("flag %q or segment %q", r.FlagKey, r.SegmentKey) + return nil, errs.ErrNotFoundf(`flag "%s/%s" or segment "%s/%s"`, r.NamespaceKey, r.FlagKey, r.NamespaceKey, r.SegmentKey) } return nil, err @@ -143,7 +169,7 @@ func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistribut var serr sqlite3.Error if errors.As(err, &serr) && serr.Code == sqlite3.ErrConstraint { - return nil, errs.ErrNotFoundf("rule %q", r.RuleId) + return nil, errs.ErrNotFoundf("variant %q, rule %q, flag %q in namespace %q", r.VariantId, r.RuleId, r.FlagKey, r.NamespaceKey) } return nil, err diff --git a/internal/storage/sql/testing/testing.go b/internal/storage/sql/testing/testing.go index 42f46d3f59..25f3d61a48 100644 --- a/internal/storage/sql/testing/testing.go +++ b/internal/storage/sql/testing/testing.go @@ -7,6 +7,8 @@ import ( "fmt" "log" "os" + "strconv" + "strings" "time" "github.com/docker/go-connections/nat" @@ -55,7 +57,7 @@ func Open() (*Database, error) { var proto config.DatabaseProtocol switch os.Getenv("FLIPT_TEST_DATABASE_PROTOCOL") { - case "cockroachdb": + case "cockroachdb", "cockroach": proto = config.DatabaseCockroachDB case "postgres": proto = config.DatabasePostgres @@ -129,47 +131,31 @@ func Open() (*Database, error) { return nil, fmt.Errorf("opening db: %w", err) } - var dr database.Driver - - switch driver { - case fliptsql.SQLite: - dr, err = sqlite3.WithInstance(db, &sqlite3.Config{}) - case fliptsql.Postgres: - dr, err = pg.WithInstance(db, &pg.Config{}) - case fliptsql.CockroachDB: - dr, err = cockroachdb.WithInstance(db, &cockroachdb.Config{}) - case fliptsql.MySQL: - dr, err = ms.WithInstance(db, &ms.Config{}) + mm, err := newMigrator(db, driver) + if err != nil { + return nil, fmt.Errorf("creating migrate instance: %w", err) + } - // https://stackoverflow.com/questions/5452760/how-to-truncate-a-foreign-key-constrained-table - if _, err := db.Exec("SET FOREIGN_KEY_CHECKS = 0;"); err != nil { - return nil, fmt.Errorf("disabling foreign key checks: %w", err) - } - default: - return nil, fmt.Errorf("unknown driver: %s", proto) + // run drop to clear target DB (incase we're reusing) + if err := mm.Drop(); err != nil && !errors.Is(err, migrate.ErrNoChange) { + return nil, fmt.Errorf("running drop: %w", err) } - if err != nil { - return nil, fmt.Errorf("creating driver: %w", err) + if err := db.Close(); err != nil { + return nil, fmt.Errorf("closing db: %w", err) } - // source migrations from embedded config/migrations package - // relative to the specific driver - sourceDriver, err := iofs.New(migrations.FS, driver.String()) + // need new instance after drop + db, driver, err = fliptsql.Open(cfg, fliptsql.WithMigrate, fliptsql.WithSSLDisabled) if err != nil { - return nil, fmt.Errorf("constructing migration source driver (db driver %q): %w", driver.String(), err) + return nil, fmt.Errorf("opening db: %w", err) } - mm, err := migrate.NewWithInstance("iofs", sourceDriver, driver.String(), dr) + mm, err = newMigrator(db, driver) if err != nil { return nil, fmt.Errorf("creating migrate instance: %w", err) } - // run down migrations to clear target DB (incase we're reusing) - if err := mm.Down(); err != nil && !errors.Is(err, migrate.ErrNoChange) { - return nil, fmt.Errorf("running down migrations: %w", err) - } - if err := mm.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) { return nil, fmt.Errorf("running migrations: %w", err) } @@ -184,12 +170,6 @@ func Open() (*Database, error) { return nil, fmt.Errorf("opening db: %w", err) } - if driver == fliptsql.MySQL { - if _, err := db.Exec("SET FOREIGN_KEY_CHECKS = 1;"); err != nil { - return nil, fmt.Errorf("enabling foreign key checks: %w", err) - } - } - db.SetConnMaxLifetime(2 * time.Minute) db.SetConnMaxIdleTime(time.Minute) @@ -208,6 +188,40 @@ func Open() (*Database, error) { }, nil } +func newMigrator(db *sql.DB, driver fliptsql.Driver) (*migrate.Migrate, error) { + var ( + dr database.Driver + err error + ) + + switch driver { + case fliptsql.SQLite: + dr, err = sqlite3.WithInstance(db, &sqlite3.Config{}) + case fliptsql.Postgres: + dr, err = pg.WithInstance(db, &pg.Config{}) + case fliptsql.CockroachDB: + dr, err = cockroachdb.WithInstance(db, &cockroachdb.Config{}) + case fliptsql.MySQL: + dr, err = ms.WithInstance(db, &ms.Config{}) + + default: + return nil, fmt.Errorf("unknown driver: %s", driver) + } + + if err != nil { + return nil, fmt.Errorf("creating driver: %w", err) + } + + // source migrations from embedded config/migrations package + // relative to the specific driver + sourceDriver, err := iofs.New(migrations.FS, driver.String()) + if err != nil { + return nil, fmt.Errorf("constructing migration source driver (db driver %q): %w", driver.String(), err) + } + + return migrate.NewWithInstance("iofs", sourceDriver, driver.String(), dr) +} + type DBContainer struct { testcontainers.Container Host string @@ -278,8 +292,11 @@ func NewDBContainer(ctx context.Context, proto config.DatabaseProtocol) (*DBCont return nil, err } - var logger testContainerLogger - container.FollowOutput(&logger) + verbose, _ := strconv.ParseBool(strings.TrimSpace(os.Getenv("FLIPT_TEST_DATABASE_VERBOSE"))) + if verbose { + var logger testContainerLogger + container.FollowOutput(&logger) + } mappedPort, err := container.MappedPort(ctx, port) if err != nil { diff --git a/internal/storage/storage.go b/internal/storage/storage.go index f9c400f1db..915bffc569 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -19,6 +19,7 @@ const ( // given flagKey matches a segment type EvaluationRule struct { ID string + NamespaceKey string FlagKey string SegmentKey string SegmentMatchType flipt.MatchType @@ -113,6 +114,7 @@ type Store interface { RuleStore SegmentStore EvaluationStore + NamespaceStore fmt.Stringer } @@ -121,19 +123,31 @@ type ResultSet[T any] struct { NextPageToken string } +const DefaultNamespace = "default" + // EvaluationStore returns data necessary for evaluation type EvaluationStore interface { // GetEvaluationRules returns rules applicable to flagKey provided // Note: Rules MUST be returned in order by Rank - GetEvaluationRules(ctx context.Context, flagKey string) ([]*EvaluationRule, error) + GetEvaluationRules(ctx context.Context, namespaceKey, flagKey string) ([]*EvaluationRule, error) GetEvaluationDistributions(ctx context.Context, ruleID string) ([]*EvaluationDistribution, error) } +// NamespaceStore stores and retrieves namespaces +type NamespaceStore interface { + GetNamespace(ctx context.Context, key string) (*flipt.Namespace, error) + ListNamespaces(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Namespace], error) + CountNamespaces(ctx context.Context) (uint64, error) + CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) + UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) + DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error +} + // FlagStore stores and retrieves flags and variants type FlagStore interface { - GetFlag(ctx context.Context, key string) (*flipt.Flag, error) - ListFlags(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Flag], error) - CountFlags(ctx context.Context) (uint64, error) + GetFlag(ctx context.Context, namespaceKey, key string) (*flipt.Flag, error) + ListFlags(ctx context.Context, namespaceKey string, opts ...QueryOption) (ResultSet[*flipt.Flag], error) + CountFlags(ctx context.Context, namespaceKey string) (uint64, error) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error) UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*flipt.Flag, error) DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) error @@ -144,9 +158,9 @@ type FlagStore interface { // SegmentStore stores and retrieves segments and constraints type SegmentStore interface { - GetSegment(ctx context.Context, key string) (*flipt.Segment, error) - ListSegments(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Segment], error) - CountSegments(ctx context.Context) (uint64, error) + GetSegment(ctx context.Context, namespaceKey, key string) (*flipt.Segment, error) + ListSegments(ctx context.Context, namespaceKey string, opts ...QueryOption) (ResultSet[*flipt.Segment], error) + CountSegments(ctx context.Context, namespaceKey string) (uint64, error) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error) UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest) (*flipt.Segment, error) DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest) error @@ -157,9 +171,9 @@ type SegmentStore interface { // RuleStore stores and retrieves rules and distributions type RuleStore interface { - GetRule(ctx context.Context, id string) (*flipt.Rule, error) - ListRules(ctx context.Context, flagKey string, opts ...QueryOption) (ResultSet[*flipt.Rule], error) - CountRules(ctx context.Context) (uint64, error) + GetRule(ctx context.Context, namespaceKey, id string) (*flipt.Rule, error) + ListRules(ctx context.Context, namespaceKey, flagKey string, opts ...QueryOption) (ResultSet[*flipt.Rule], error) + CountRules(ctx context.Context, namespaceKey string) (uint64, error) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*flipt.Rule, error) UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*flipt.Rule, error) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) error diff --git a/magefile.go b/magefile.go index 7e7c0bda76..6294b0ebfd 100644 --- a/magefile.go +++ b/magefile.go @@ -142,12 +142,19 @@ func Cover() error { return sh.RunV("go", "tool", "cover", "-html=coverage.txt") } +var ignoreFmt = []string{"rpc/", "sdk/"} + // Fmt formats code func Fmt() error { fmt.Println("Formatting...") files, err := findFilesRecursive(func(path string, _ os.FileInfo) bool { - // only go files, ignoring generated files in rpc/ - return filepath.Ext(path) == ".go" && !filepath.HasPrefix(path, "rpc/") + // only go files, ignoring generated files + for _, dir := range ignoreFmt { + if filepath.HasPrefix(path, dir) { + return false + } + } + return filepath.Ext(path) == ".go" }) if err != nil { return fmt.Errorf("failed to find files: %w", err) @@ -217,14 +224,14 @@ func (u UI) Build() error { return sh.RunV("mv", ".build/ui/dist", "ui") } -// Clone clones the UI repo +// Clone clones the UI repo with an optional branch func (u UI) Clone() error { if err := os.MkdirAll(".build", 0755); err != nil { return fmt.Errorf("failed to create dir: %w", err) } if _, err := os.Stat(".build/ui/.git"); os.IsNotExist(err) { - if err := sh.RunV("git", "clone", "https://github.com/flipt-io/flipt-ui.git", ".build/ui", "--depth=1"); err != nil { + if err := sh.RunV("git", "clone", "https://github.com/flipt-io/flipt-ui.git", ".build/ui"); err != nil { return fmt.Errorf("failed to clone UI repo: %w", err) } } @@ -237,28 +244,34 @@ func (u UI) Sync() error { mg.Deps(u.Clone) fmt.Println("Syncing UI repo...") - cmd := exec.Command("git", "fetch", "--all") + branch := "main" + if os.Getenv("FLIPT_BUILD_UI_BRANCH") != "" { + branch = os.Getenv("FLIPT_BUILD_UI_BRANCH") + } + + cmd := exec.Command("git", "pull", "--all") cmd.Dir = ".build/ui" cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to fetch UI repo: %w", err) + return fmt.Errorf("failed to pull UI repo: %w", err) } - cmd = exec.Command("git", "checkout", "main") + cmd = exec.Command("git", "checkout", branch) cmd.Dir = ".build/ui" cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to checkout main branch in UI repo: %w", err) + return fmt.Errorf("failed to checkout branch %s: %w", branch, err) } - cmd = exec.Command("git", "reset", "--hard", "origin/main") + cmd = exec.Command("git", "pull") cmd.Dir = ".build/ui" cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr + return cmd.Run() } diff --git a/rpc/flipt/flipt.pb.go b/rpc/flipt/flipt.pb.go index 792126d801..849ec46487 100644 --- a/rpc/flipt/flipt.pb.go +++ b/rpc/flipt/flipt.pb.go @@ -180,10 +180,11 @@ type EvaluationRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - EntityId string `protobuf:"bytes,3,opt,name=entity_id,json=entityId,proto3" json:"entity_id,omitempty"` - Context map[string]string `protobuf:"bytes,4,rep,name=context,proto3" json:"context,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + EntityId string `protobuf:"bytes,3,opt,name=entity_id,json=entityId,proto3" json:"entity_id,omitempty"` + Context map[string]string `protobuf:"bytes,4,rep,name=context,proto3" json:"context,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *EvaluationRequest) Reset() { @@ -246,6 +247,13 @@ func (x *EvaluationRequest) GetContext() map[string]string { return nil } +func (x *EvaluationRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type BatchEvaluationRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -254,6 +262,7 @@ type BatchEvaluationRequest struct { RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` Requests []*EvaluationRequest `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests,omitempty"` ExcludeNotFound bool `protobuf:"varint,3,opt,name=exclude_not_found,json=excludeNotFound,proto3" json:"exclude_not_found,omitempty"` + NamespaceKey string `protobuf:"bytes,4,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *BatchEvaluationRequest) Reset() { @@ -309,6 +318,13 @@ func (x *BatchEvaluationRequest) GetExcludeNotFound() bool { return false } +func (x *BatchEvaluationRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type EvaluationResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -325,6 +341,7 @@ type EvaluationResponse struct { RequestDurationMillis float64 `protobuf:"fixed64,9,opt,name=request_duration_millis,json=requestDurationMillis,proto3" json:"request_duration_millis,omitempty"` Attachment string `protobuf:"bytes,10,opt,name=attachment,proto3" json:"attachment,omitempty"` Reason EvaluationReason `protobuf:"varint,11,opt,name=reason,proto3,enum=flipt.EvaluationReason" json:"reason,omitempty"` + NamespaceKey string `protobuf:"bytes,12,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *EvaluationResponse) Reset() { @@ -436,6 +453,13 @@ func (x *EvaluationResponse) GetReason() EvaluationReason { return EvaluationReason_UNKNOWN_EVALUATION_REASON } +func (x *EvaluationResponse) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type BatchEvaluationResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -499,7 +523,7 @@ func (x *BatchEvaluationResponse) GetRequestDurationMillis() float64 { return 0 } -type Flag struct { +type Namespace struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -507,16 +531,452 @@ type Flag struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + Protected bool `protobuf:"varint,4,opt,name=protected,proto3" json:"protected,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` - Variants []*Variant `protobuf:"bytes,7,rep,name=variants,proto3" json:"variants,omitempty"` +} + +func (x *Namespace) Reset() { + *x = Namespace{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Namespace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Namespace) ProtoMessage() {} + +func (x *Namespace) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Namespace.ProtoReflect.Descriptor instead. +func (*Namespace) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{4} +} + +func (x *Namespace) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Namespace) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Namespace) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Namespace) GetProtected() bool { + if x != nil { + return x.Protected + } + return false +} + +func (x *Namespace) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.CreatedAt + } + return nil +} + +func (x *Namespace) GetUpdatedAt() *timestamppb.Timestamp { + if x != nil { + return x.UpdatedAt + } + return nil +} + +type NamespaceList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Namespaces []*Namespace `protobuf:"bytes,1,rep,name=namespaces,proto3" json:"namespaces,omitempty"` + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` + TotalCount int32 `protobuf:"varint,3,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"` +} + +func (x *NamespaceList) Reset() { + *x = NamespaceList{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NamespaceList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamespaceList) ProtoMessage() {} + +func (x *NamespaceList) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamespaceList.ProtoReflect.Descriptor instead. +func (*NamespaceList) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{5} +} + +func (x *NamespaceList) GetNamespaces() []*Namespace { + if x != nil { + return x.Namespaces + } + return nil +} + +func (x *NamespaceList) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *NamespaceList) GetTotalCount() int32 { + if x != nil { + return x.TotalCount + } + return 0 +} + +type GetNamespaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *GetNamespaceRequest) Reset() { + *x = GetNamespaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNamespaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNamespaceRequest) ProtoMessage() {} + +func (x *GetNamespaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNamespaceRequest.ProtoReflect.Descriptor instead. +func (*GetNamespaceRequest) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{6} +} + +func (x *GetNamespaceRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +type ListNamespaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` + // Deprecated: Marked as deprecated in flipt.proto. + Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` +} + +func (x *ListNamespaceRequest) Reset() { + *x = ListNamespaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListNamespaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListNamespaceRequest) ProtoMessage() {} + +func (x *ListNamespaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListNamespaceRequest.ProtoReflect.Descriptor instead. +func (*ListNamespaceRequest) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{7} +} + +func (x *ListNamespaceRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +// Deprecated: Marked as deprecated in flipt.proto. +func (x *ListNamespaceRequest) GetOffset() int32 { + if x != nil { + return x.Offset + } + return 0 +} + +func (x *ListNamespaceRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +type CreateNamespaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *CreateNamespaceRequest) Reset() { + *x = CreateNamespaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateNamespaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateNamespaceRequest) ProtoMessage() {} + +func (x *CreateNamespaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateNamespaceRequest.ProtoReflect.Descriptor instead. +func (*CreateNamespaceRequest) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{8} +} + +func (x *CreateNamespaceRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *CreateNamespaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateNamespaceRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +type UpdateNamespaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *UpdateNamespaceRequest) Reset() { + *x = UpdateNamespaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateNamespaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateNamespaceRequest) ProtoMessage() {} + +func (x *UpdateNamespaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateNamespaceRequest.ProtoReflect.Descriptor instead. +func (*UpdateNamespaceRequest) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{9} +} + +func (x *UpdateNamespaceRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *UpdateNamespaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateNamespaceRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +type DeleteNamespaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *DeleteNamespaceRequest) Reset() { + *x = DeleteNamespaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_flipt_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteNamespaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteNamespaceRequest) ProtoMessage() {} + +func (x *DeleteNamespaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_flipt_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteNamespaceRequest.ProtoReflect.Descriptor instead. +func (*DeleteNamespaceRequest) Descriptor() ([]byte, []int) { + return file_flipt_proto_rawDescGZIP(), []int{10} +} + +func (x *DeleteNamespaceRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +type Flag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Variants []*Variant `protobuf:"bytes,7,rep,name=variants,proto3" json:"variants,omitempty"` + NamespaceKey string `protobuf:"bytes,8,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *Flag) Reset() { *x = Flag{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[4] + mi := &file_flipt_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -529,7 +989,7 @@ func (x *Flag) String() string { func (*Flag) ProtoMessage() {} func (x *Flag) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[4] + mi := &file_flipt_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -542,7 +1002,7 @@ func (x *Flag) ProtoReflect() protoreflect.Message { // Deprecated: Use Flag.ProtoReflect.Descriptor instead. func (*Flag) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{4} + return file_flipt_proto_rawDescGZIP(), []int{11} } func (x *Flag) GetKey() string { @@ -594,6 +1054,13 @@ func (x *Flag) GetVariants() []*Variant { return nil } +func (x *Flag) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type FlagList struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -607,7 +1074,7 @@ type FlagList struct { func (x *FlagList) Reset() { *x = FlagList{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[5] + mi := &file_flipt_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -620,7 +1087,7 @@ func (x *FlagList) String() string { func (*FlagList) ProtoMessage() {} func (x *FlagList) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[5] + mi := &file_flipt_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -633,7 +1100,7 @@ func (x *FlagList) ProtoReflect() protoreflect.Message { // Deprecated: Use FlagList.ProtoReflect.Descriptor instead. func (*FlagList) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{5} + return file_flipt_proto_rawDescGZIP(), []int{12} } func (x *FlagList) GetFlags() []*Flag { @@ -662,13 +1129,14 @@ type GetFlagRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + NamespaceKey string `protobuf:"bytes,2,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *GetFlagRequest) Reset() { *x = GetFlagRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[6] + mi := &file_flipt_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -681,7 +1149,7 @@ func (x *GetFlagRequest) String() string { func (*GetFlagRequest) ProtoMessage() {} func (x *GetFlagRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[6] + mi := &file_flipt_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -694,7 +1162,7 @@ func (x *GetFlagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetFlagRequest.ProtoReflect.Descriptor instead. func (*GetFlagRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{6} + return file_flipt_proto_rawDescGZIP(), []int{13} } func (x *GetFlagRequest) GetKey() string { @@ -704,6 +1172,13 @@ func (x *GetFlagRequest) GetKey() string { return "" } +func (x *GetFlagRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type ListFlagRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -711,14 +1186,15 @@ type ListFlagRequest struct { Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` // Deprecated: Marked as deprecated in flipt.proto. - Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + NamespaceKey string `protobuf:"bytes,4,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *ListFlagRequest) Reset() { *x = ListFlagRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[7] + mi := &file_flipt_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -731,7 +1207,7 @@ func (x *ListFlagRequest) String() string { func (*ListFlagRequest) ProtoMessage() {} func (x *ListFlagRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[7] + mi := &file_flipt_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -744,7 +1220,7 @@ func (x *ListFlagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListFlagRequest.ProtoReflect.Descriptor instead. func (*ListFlagRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{7} + return file_flipt_proto_rawDescGZIP(), []int{14} } func (x *ListFlagRequest) GetLimit() int32 { @@ -769,21 +1245,29 @@ func (x *ListFlagRequest) GetPageToken() string { return "" } +func (x *ListFlagRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type CreateFlagRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateFlagRequest) Reset() { *x = CreateFlagRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[8] + mi := &file_flipt_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -796,7 +1280,7 @@ func (x *CreateFlagRequest) String() string { func (*CreateFlagRequest) ProtoMessage() {} func (x *CreateFlagRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[8] + mi := &file_flipt_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -809,7 +1293,7 @@ func (x *CreateFlagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateFlagRequest.ProtoReflect.Descriptor instead. func (*CreateFlagRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{8} + return file_flipt_proto_rawDescGZIP(), []int{15} } func (x *CreateFlagRequest) GetKey() string { @@ -840,21 +1324,29 @@ func (x *CreateFlagRequest) GetEnabled() bool { return false } +func (x *CreateFlagRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateFlagRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateFlagRequest) Reset() { *x = UpdateFlagRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[9] + mi := &file_flipt_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -867,7 +1359,7 @@ func (x *UpdateFlagRequest) String() string { func (*UpdateFlagRequest) ProtoMessage() {} func (x *UpdateFlagRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[9] + mi := &file_flipt_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -880,7 +1372,7 @@ func (x *UpdateFlagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateFlagRequest.ProtoReflect.Descriptor instead. func (*UpdateFlagRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{9} + return file_flipt_proto_rawDescGZIP(), []int{16} } func (x *UpdateFlagRequest) GetKey() string { @@ -911,18 +1403,26 @@ func (x *UpdateFlagRequest) GetEnabled() bool { return false } +func (x *UpdateFlagRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteFlagRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + NamespaceKey string `protobuf:"bytes,2,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteFlagRequest) Reset() { *x = DeleteFlagRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[10] + mi := &file_flipt_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -935,7 +1435,7 @@ func (x *DeleteFlagRequest) String() string { func (*DeleteFlagRequest) ProtoMessage() {} func (x *DeleteFlagRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[10] + mi := &file_flipt_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -948,7 +1448,7 @@ func (x *DeleteFlagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteFlagRequest.ProtoReflect.Descriptor instead. func (*DeleteFlagRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{10} + return file_flipt_proto_rawDescGZIP(), []int{17} } func (x *DeleteFlagRequest) GetKey() string { @@ -958,25 +1458,33 @@ func (x *DeleteFlagRequest) GetKey() string { return "" } +func (x *DeleteFlagRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type Variant struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` - Attachment string `protobuf:"bytes,8,opt,name=attachment,proto3" json:"attachment,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Attachment string `protobuf:"bytes,8,opt,name=attachment,proto3" json:"attachment,omitempty"` + NamespaceKey string `protobuf:"bytes,9,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *Variant) Reset() { *x = Variant{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[11] + mi := &file_flipt_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -989,7 +1497,7 @@ func (x *Variant) String() string { func (*Variant) ProtoMessage() {} func (x *Variant) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[11] + mi := &file_flipt_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1002,7 +1510,7 @@ func (x *Variant) ProtoReflect() protoreflect.Message { // Deprecated: Use Variant.ProtoReflect.Descriptor instead. func (*Variant) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{11} + return file_flipt_proto_rawDescGZIP(), []int{18} } func (x *Variant) GetId() string { @@ -1061,22 +1569,30 @@ func (x *Variant) GetAttachment() string { return "" } +func (x *Variant) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type CreateVariantRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` - Attachment string `protobuf:"bytes,5,opt,name=attachment,proto3" json:"attachment,omitempty"` + FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + Attachment string `protobuf:"bytes,5,opt,name=attachment,proto3" json:"attachment,omitempty"` + NamespaceKey string `protobuf:"bytes,6,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateVariantRequest) Reset() { *x = CreateVariantRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[12] + mi := &file_flipt_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1089,7 +1605,7 @@ func (x *CreateVariantRequest) String() string { func (*CreateVariantRequest) ProtoMessage() {} func (x *CreateVariantRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[12] + mi := &file_flipt_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1102,7 +1618,7 @@ func (x *CreateVariantRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateVariantRequest.ProtoReflect.Descriptor instead. func (*CreateVariantRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{12} + return file_flipt_proto_rawDescGZIP(), []int{19} } func (x *CreateVariantRequest) GetFlagKey() string { @@ -1140,23 +1656,31 @@ func (x *CreateVariantRequest) GetAttachment() string { return "" } +func (x *CreateVariantRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateVariantRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` - Attachment string `protobuf:"bytes,6,opt,name=attachment,proto3" json:"attachment,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` + Attachment string `protobuf:"bytes,6,opt,name=attachment,proto3" json:"attachment,omitempty"` + NamespaceKey string `protobuf:"bytes,7,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateVariantRequest) Reset() { *x = UpdateVariantRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[13] + mi := &file_flipt_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1169,7 +1693,7 @@ func (x *UpdateVariantRequest) String() string { func (*UpdateVariantRequest) ProtoMessage() {} func (x *UpdateVariantRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[13] + mi := &file_flipt_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1182,7 +1706,7 @@ func (x *UpdateVariantRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateVariantRequest.ProtoReflect.Descriptor instead. func (*UpdateVariantRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{13} + return file_flipt_proto_rawDescGZIP(), []int{20} } func (x *UpdateVariantRequest) GetId() string { @@ -1227,19 +1751,27 @@ func (x *UpdateVariantRequest) GetAttachment() string { return "" } +func (x *UpdateVariantRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteVariantRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + NamespaceKey string `protobuf:"bytes,3,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteVariantRequest) Reset() { *x = DeleteVariantRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[14] + mi := &file_flipt_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1252,7 +1784,7 @@ func (x *DeleteVariantRequest) String() string { func (*DeleteVariantRequest) ProtoMessage() {} func (x *DeleteVariantRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[14] + mi := &file_flipt_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1265,7 +1797,7 @@ func (x *DeleteVariantRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteVariantRequest.ProtoReflect.Descriptor instead. func (*DeleteVariantRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{14} + return file_flipt_proto_rawDescGZIP(), []int{21} } func (x *DeleteVariantRequest) GetId() string { @@ -1282,24 +1814,32 @@ func (x *DeleteVariantRequest) GetFlagKey() string { return "" } +func (x *DeleteVariantRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type Segment struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` - Constraints []*Constraint `protobuf:"bytes,6,rep,name=constraints,proto3" json:"constraints,omitempty"` - MatchType MatchType `protobuf:"varint,7,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Constraints []*Constraint `protobuf:"bytes,6,rep,name=constraints,proto3" json:"constraints,omitempty"` + MatchType MatchType `protobuf:"varint,7,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + NamespaceKey string `protobuf:"bytes,8,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *Segment) Reset() { *x = Segment{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[15] + mi := &file_flipt_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1312,7 +1852,7 @@ func (x *Segment) String() string { func (*Segment) ProtoMessage() {} func (x *Segment) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[15] + mi := &file_flipt_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1325,7 +1865,7 @@ func (x *Segment) ProtoReflect() protoreflect.Message { // Deprecated: Use Segment.ProtoReflect.Descriptor instead. func (*Segment) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{15} + return file_flipt_proto_rawDescGZIP(), []int{22} } func (x *Segment) GetKey() string { @@ -1377,6 +1917,13 @@ func (x *Segment) GetMatchType() MatchType { return MatchType_ALL_MATCH_TYPE } +func (x *Segment) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type SegmentList struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1390,7 +1937,7 @@ type SegmentList struct { func (x *SegmentList) Reset() { *x = SegmentList{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[16] + mi := &file_flipt_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1403,7 +1950,7 @@ func (x *SegmentList) String() string { func (*SegmentList) ProtoMessage() {} func (x *SegmentList) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[16] + mi := &file_flipt_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1416,7 +1963,7 @@ func (x *SegmentList) ProtoReflect() protoreflect.Message { // Deprecated: Use SegmentList.ProtoReflect.Descriptor instead. func (*SegmentList) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{16} + return file_flipt_proto_rawDescGZIP(), []int{23} } func (x *SegmentList) GetSegments() []*Segment { @@ -1445,13 +1992,14 @@ type GetSegmentRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + NamespaceKey string `protobuf:"bytes,2,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *GetSegmentRequest) Reset() { *x = GetSegmentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[17] + mi := &file_flipt_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1464,7 +2012,7 @@ func (x *GetSegmentRequest) String() string { func (*GetSegmentRequest) ProtoMessage() {} func (x *GetSegmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[17] + mi := &file_flipt_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1477,7 +2025,7 @@ func (x *GetSegmentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSegmentRequest.ProtoReflect.Descriptor instead. func (*GetSegmentRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{17} + return file_flipt_proto_rawDescGZIP(), []int{24} } func (x *GetSegmentRequest) GetKey() string { @@ -1487,6 +2035,13 @@ func (x *GetSegmentRequest) GetKey() string { return "" } +func (x *GetSegmentRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type ListSegmentRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1494,14 +2049,15 @@ type ListSegmentRequest struct { Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` // Deprecated: Marked as deprecated in flipt.proto. - Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + NamespaceKey string `protobuf:"bytes,4,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *ListSegmentRequest) Reset() { *x = ListSegmentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[18] + mi := &file_flipt_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1514,7 +2070,7 @@ func (x *ListSegmentRequest) String() string { func (*ListSegmentRequest) ProtoMessage() {} func (x *ListSegmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[18] + mi := &file_flipt_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1527,7 +2083,7 @@ func (x *ListSegmentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListSegmentRequest.ProtoReflect.Descriptor instead. func (*ListSegmentRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{18} + return file_flipt_proto_rawDescGZIP(), []int{25} } func (x *ListSegmentRequest) GetLimit() int32 { @@ -1552,21 +2108,29 @@ func (x *ListSegmentRequest) GetPageToken() string { return "" } +func (x *ListSegmentRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type CreateSegmentRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - MatchType MatchType `protobuf:"varint,4,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + MatchType MatchType `protobuf:"varint,4,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateSegmentRequest) Reset() { *x = CreateSegmentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[19] + mi := &file_flipt_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1579,7 +2143,7 @@ func (x *CreateSegmentRequest) String() string { func (*CreateSegmentRequest) ProtoMessage() {} func (x *CreateSegmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[19] + mi := &file_flipt_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1592,7 +2156,7 @@ func (x *CreateSegmentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateSegmentRequest.ProtoReflect.Descriptor instead. func (*CreateSegmentRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{19} + return file_flipt_proto_rawDescGZIP(), []int{26} } func (x *CreateSegmentRequest) GetKey() string { @@ -1623,21 +2187,29 @@ func (x *CreateSegmentRequest) GetMatchType() MatchType { return MatchType_ALL_MATCH_TYPE } +func (x *CreateSegmentRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateSegmentRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - MatchType MatchType `protobuf:"varint,4,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + MatchType MatchType `protobuf:"varint,4,opt,name=match_type,json=matchType,proto3,enum=flipt.MatchType" json:"match_type,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateSegmentRequest) Reset() { *x = UpdateSegmentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[20] + mi := &file_flipt_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1650,7 +2222,7 @@ func (x *UpdateSegmentRequest) String() string { func (*UpdateSegmentRequest) ProtoMessage() {} func (x *UpdateSegmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[20] + mi := &file_flipt_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1663,7 +2235,7 @@ func (x *UpdateSegmentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateSegmentRequest.ProtoReflect.Descriptor instead. func (*UpdateSegmentRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{20} + return file_flipt_proto_rawDescGZIP(), []int{27} } func (x *UpdateSegmentRequest) GetKey() string { @@ -1694,18 +2266,26 @@ func (x *UpdateSegmentRequest) GetMatchType() MatchType { return MatchType_ALL_MATCH_TYPE } +func (x *UpdateSegmentRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteSegmentRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + NamespaceKey string `protobuf:"bytes,2,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteSegmentRequest) Reset() { *x = DeleteSegmentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[21] + mi := &file_flipt_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1718,7 +2298,7 @@ func (x *DeleteSegmentRequest) String() string { func (*DeleteSegmentRequest) ProtoMessage() {} func (x *DeleteSegmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[21] + mi := &file_flipt_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1731,7 +2311,7 @@ func (x *DeleteSegmentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteSegmentRequest.ProtoReflect.Descriptor instead. func (*DeleteSegmentRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{21} + return file_flipt_proto_rawDescGZIP(), []int{28} } func (x *DeleteSegmentRequest) GetKey() string { @@ -1741,25 +2321,33 @@ func (x *DeleteSegmentRequest) GetKey() string { return "" } +func (x *DeleteSegmentRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type Constraint struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` - Type ComparisonType `protobuf:"varint,3,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` - Property string `protobuf:"bytes,4,opt,name=property,proto3" json:"property,omitempty"` - Operator string `protobuf:"bytes,5,opt,name=operator,proto3" json:"operator,omitempty"` - Value string `protobuf:"bytes,6,opt,name=value,proto3" json:"value,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Type ComparisonType `protobuf:"varint,3,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` + Property string `protobuf:"bytes,4,opt,name=property,proto3" json:"property,omitempty"` + Operator string `protobuf:"bytes,5,opt,name=operator,proto3" json:"operator,omitempty"` + Value string `protobuf:"bytes,6,opt,name=value,proto3" json:"value,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + NamespaceKey string `protobuf:"bytes,9,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *Constraint) Reset() { *x = Constraint{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[22] + mi := &file_flipt_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1772,7 +2360,7 @@ func (x *Constraint) String() string { func (*Constraint) ProtoMessage() {} func (x *Constraint) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[22] + mi := &file_flipt_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1785,7 +2373,7 @@ func (x *Constraint) ProtoReflect() protoreflect.Message { // Deprecated: Use Constraint.ProtoReflect.Descriptor instead. func (*Constraint) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{22} + return file_flipt_proto_rawDescGZIP(), []int{29} } func (x *Constraint) GetId() string { @@ -1844,22 +2432,30 @@ func (x *Constraint) GetUpdatedAt() *timestamppb.Timestamp { return nil } +func (x *Constraint) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type CreateConstraintRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SegmentKey string `protobuf:"bytes,1,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` - Type ComparisonType `protobuf:"varint,2,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` - Property string `protobuf:"bytes,3,opt,name=property,proto3" json:"property,omitempty"` - Operator string `protobuf:"bytes,4,opt,name=operator,proto3" json:"operator,omitempty"` - Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` + SegmentKey string `protobuf:"bytes,1,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Type ComparisonType `protobuf:"varint,2,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` + Property string `protobuf:"bytes,3,opt,name=property,proto3" json:"property,omitempty"` + Operator string `protobuf:"bytes,4,opt,name=operator,proto3" json:"operator,omitempty"` + Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` + NamespaceKey string `protobuf:"bytes,6,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateConstraintRequest) Reset() { *x = CreateConstraintRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[23] + mi := &file_flipt_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1872,7 +2468,7 @@ func (x *CreateConstraintRequest) String() string { func (*CreateConstraintRequest) ProtoMessage() {} func (x *CreateConstraintRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[23] + mi := &file_flipt_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1885,7 +2481,7 @@ func (x *CreateConstraintRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateConstraintRequest.ProtoReflect.Descriptor instead. func (*CreateConstraintRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{23} + return file_flipt_proto_rawDescGZIP(), []int{30} } func (x *CreateConstraintRequest) GetSegmentKey() string { @@ -1923,23 +2519,31 @@ func (x *CreateConstraintRequest) GetValue() string { return "" } +func (x *CreateConstraintRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateConstraintRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` - Type ComparisonType `protobuf:"varint,3,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` - Property string `protobuf:"bytes,4,opt,name=property,proto3" json:"property,omitempty"` - Operator string `protobuf:"bytes,5,opt,name=operator,proto3" json:"operator,omitempty"` - Value string `protobuf:"bytes,6,opt,name=value,proto3" json:"value,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Type ComparisonType `protobuf:"varint,3,opt,name=type,proto3,enum=flipt.ComparisonType" json:"type,omitempty"` + Property string `protobuf:"bytes,4,opt,name=property,proto3" json:"property,omitempty"` + Operator string `protobuf:"bytes,5,opt,name=operator,proto3" json:"operator,omitempty"` + Value string `protobuf:"bytes,6,opt,name=value,proto3" json:"value,omitempty"` + NamespaceKey string `protobuf:"bytes,7,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateConstraintRequest) Reset() { *x = UpdateConstraintRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[24] + mi := &file_flipt_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1952,7 +2556,7 @@ func (x *UpdateConstraintRequest) String() string { func (*UpdateConstraintRequest) ProtoMessage() {} func (x *UpdateConstraintRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[24] + mi := &file_flipt_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1965,7 +2569,7 @@ func (x *UpdateConstraintRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateConstraintRequest.ProtoReflect.Descriptor instead. func (*UpdateConstraintRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{24} + return file_flipt_proto_rawDescGZIP(), []int{31} } func (x *UpdateConstraintRequest) GetId() string { @@ -2010,19 +2614,27 @@ func (x *UpdateConstraintRequest) GetValue() string { return "" } +func (x *UpdateConstraintRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteConstraintRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + NamespaceKey string `protobuf:"bytes,3,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteConstraintRequest) Reset() { *x = DeleteConstraintRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[25] + mi := &file_flipt_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2035,7 +2647,7 @@ func (x *DeleteConstraintRequest) String() string { func (*DeleteConstraintRequest) ProtoMessage() {} func (x *DeleteConstraintRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[25] + mi := &file_flipt_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2048,7 +2660,7 @@ func (x *DeleteConstraintRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteConstraintRequest.ProtoReflect.Descriptor instead. func (*DeleteConstraintRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{25} + return file_flipt_proto_rawDescGZIP(), []int{32} } func (x *DeleteConstraintRequest) GetId() string { @@ -2065,6 +2677,13 @@ func (x *DeleteConstraintRequest) GetSegmentKey() string { return "" } +func (x *DeleteConstraintRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type Rule struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2077,12 +2696,13 @@ type Rule struct { Rank int32 `protobuf:"varint,5,opt,name=rank,proto3" json:"rank,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + NamespaceKey string `protobuf:"bytes,8,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *Rule) Reset() { *x = Rule{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[26] + mi := &file_flipt_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2095,7 +2715,7 @@ func (x *Rule) String() string { func (*Rule) ProtoMessage() {} func (x *Rule) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[26] + mi := &file_flipt_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2108,7 +2728,7 @@ func (x *Rule) ProtoReflect() protoreflect.Message { // Deprecated: Use Rule.ProtoReflect.Descriptor instead. func (*Rule) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{26} + return file_flipt_proto_rawDescGZIP(), []int{33} } func (x *Rule) GetId() string { @@ -2160,6 +2780,13 @@ func (x *Rule) GetUpdatedAt() *timestamppb.Timestamp { return nil } +func (x *Rule) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type RuleList struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2173,7 +2800,7 @@ type RuleList struct { func (x *RuleList) Reset() { *x = RuleList{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[27] + mi := &file_flipt_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2186,7 +2813,7 @@ func (x *RuleList) String() string { func (*RuleList) ProtoMessage() {} func (x *RuleList) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[27] + mi := &file_flipt_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2199,7 +2826,7 @@ func (x *RuleList) ProtoReflect() protoreflect.Message { // Deprecated: Use RuleList.ProtoReflect.Descriptor instead. func (*RuleList) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{27} + return file_flipt_proto_rawDescGZIP(), []int{34} } func (x *RuleList) GetRules() []*Rule { @@ -2230,15 +2857,16 @@ type ListRuleRequest struct { Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` // Deprecated: Marked as deprecated in flipt.proto. - Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - FlagKey string `protobuf:"bytes,3,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + FlagKey string `protobuf:"bytes,3,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *ListRuleRequest) Reset() { *x = ListRuleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[28] + mi := &file_flipt_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2251,7 +2879,7 @@ func (x *ListRuleRequest) String() string { func (*ListRuleRequest) ProtoMessage() {} func (x *ListRuleRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[28] + mi := &file_flipt_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2264,7 +2892,7 @@ func (x *ListRuleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRuleRequest.ProtoReflect.Descriptor instead. func (*ListRuleRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{28} + return file_flipt_proto_rawDescGZIP(), []int{35} } func (x *ListRuleRequest) GetLimit() int32 { @@ -2296,19 +2924,27 @@ func (x *ListRuleRequest) GetPageToken() string { return "" } +func (x *ListRuleRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type GetRuleRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + NamespaceKey string `protobuf:"bytes,3,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *GetRuleRequest) Reset() { *x = GetRuleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[29] + mi := &file_flipt_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2321,7 +2957,7 @@ func (x *GetRuleRequest) String() string { func (*GetRuleRequest) ProtoMessage() {} func (x *GetRuleRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[29] + mi := &file_flipt_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2334,7 +2970,7 @@ func (x *GetRuleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRuleRequest.ProtoReflect.Descriptor instead. func (*GetRuleRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{29} + return file_flipt_proto_rawDescGZIP(), []int{36} } func (x *GetRuleRequest) GetId() string { @@ -2351,20 +2987,28 @@ func (x *GetRuleRequest) GetFlagKey() string { return "" } +func (x *GetRuleRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type CreateRuleRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` - Rank int32 `protobuf:"varint,3,opt,name=rank,proto3" json:"rank,omitempty"` + FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + SegmentKey string `protobuf:"bytes,2,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Rank int32 `protobuf:"varint,3,opt,name=rank,proto3" json:"rank,omitempty"` + NamespaceKey string `protobuf:"bytes,4,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateRuleRequest) Reset() { *x = CreateRuleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[30] + mi := &file_flipt_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2377,7 +3021,7 @@ func (x *CreateRuleRequest) String() string { func (*CreateRuleRequest) ProtoMessage() {} func (x *CreateRuleRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[30] + mi := &file_flipt_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2390,7 +3034,7 @@ func (x *CreateRuleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateRuleRequest.ProtoReflect.Descriptor instead. func (*CreateRuleRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{30} + return file_flipt_proto_rawDescGZIP(), []int{37} } func (x *CreateRuleRequest) GetFlagKey() string { @@ -2414,20 +3058,28 @@ func (x *CreateRuleRequest) GetRank() int32 { return 0 } +func (x *CreateRuleRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateRuleRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - SegmentKey string `protobuf:"bytes,3,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + SegmentKey string `protobuf:"bytes,3,opt,name=segment_key,json=segmentKey,proto3" json:"segment_key,omitempty"` + NamespaceKey string `protobuf:"bytes,4,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateRuleRequest) Reset() { *x = UpdateRuleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[31] + mi := &file_flipt_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2440,7 +3092,7 @@ func (x *UpdateRuleRequest) String() string { func (*UpdateRuleRequest) ProtoMessage() {} func (x *UpdateRuleRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[31] + mi := &file_flipt_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2453,7 +3105,7 @@ func (x *UpdateRuleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateRuleRequest.ProtoReflect.Descriptor instead. func (*UpdateRuleRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{31} + return file_flipt_proto_rawDescGZIP(), []int{38} } func (x *UpdateRuleRequest) GetId() string { @@ -2477,19 +3129,27 @@ func (x *UpdateRuleRequest) GetSegmentKey() string { return "" } +func (x *UpdateRuleRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteRuleRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + NamespaceKey string `protobuf:"bytes,3,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteRuleRequest) Reset() { *x = DeleteRuleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[32] + mi := &file_flipt_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2502,7 +3162,7 @@ func (x *DeleteRuleRequest) String() string { func (*DeleteRuleRequest) ProtoMessage() {} func (x *DeleteRuleRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[32] + mi := &file_flipt_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2515,7 +3175,7 @@ func (x *DeleteRuleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteRuleRequest.ProtoReflect.Descriptor instead. func (*DeleteRuleRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{32} + return file_flipt_proto_rawDescGZIP(), []int{39} } func (x *DeleteRuleRequest) GetId() string { @@ -2532,19 +3192,27 @@ func (x *DeleteRuleRequest) GetFlagKey() string { return "" } +func (x *DeleteRuleRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type OrderRulesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - RuleIds []string `protobuf:"bytes,2,rep,name=rule_ids,json=ruleIds,proto3" json:"rule_ids,omitempty"` + FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + RuleIds []string `protobuf:"bytes,2,rep,name=rule_ids,json=ruleIds,proto3" json:"rule_ids,omitempty"` + NamespaceKey string `protobuf:"bytes,3,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *OrderRulesRequest) Reset() { *x = OrderRulesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[33] + mi := &file_flipt_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2557,7 +3225,7 @@ func (x *OrderRulesRequest) String() string { func (*OrderRulesRequest) ProtoMessage() {} func (x *OrderRulesRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[33] + mi := &file_flipt_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2570,7 +3238,7 @@ func (x *OrderRulesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderRulesRequest.ProtoReflect.Descriptor instead. func (*OrderRulesRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{33} + return file_flipt_proto_rawDescGZIP(), []int{40} } func (x *OrderRulesRequest) GetFlagKey() string { @@ -2587,6 +3255,13 @@ func (x *OrderRulesRequest) GetRuleIds() []string { return nil } +func (x *OrderRulesRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type Distribution struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2603,7 +3278,7 @@ type Distribution struct { func (x *Distribution) Reset() { *x = Distribution{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[34] + mi := &file_flipt_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2616,7 +3291,7 @@ func (x *Distribution) String() string { func (*Distribution) ProtoMessage() {} func (x *Distribution) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[34] + mi := &file_flipt_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2629,7 +3304,7 @@ func (x *Distribution) ProtoReflect() protoreflect.Message { // Deprecated: Use Distribution.ProtoReflect.Descriptor instead. func (*Distribution) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{34} + return file_flipt_proto_rawDescGZIP(), []int{41} } func (x *Distribution) GetId() string { @@ -2679,16 +3354,17 @@ type CreateDistributionRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - RuleId string `protobuf:"bytes,2,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` - VariantId string `protobuf:"bytes,3,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` - Rollout float32 `protobuf:"fixed32,4,opt,name=rollout,proto3" json:"rollout,omitempty"` + FlagKey string `protobuf:"bytes,1,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + RuleId string `protobuf:"bytes,2,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` + VariantId string `protobuf:"bytes,3,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` + Rollout float32 `protobuf:"fixed32,4,opt,name=rollout,proto3" json:"rollout,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *CreateDistributionRequest) Reset() { *x = CreateDistributionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[35] + mi := &file_flipt_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2701,7 +3377,7 @@ func (x *CreateDistributionRequest) String() string { func (*CreateDistributionRequest) ProtoMessage() {} func (x *CreateDistributionRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[35] + mi := &file_flipt_proto_msgTypes[42] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2714,7 +3390,7 @@ func (x *CreateDistributionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateDistributionRequest.ProtoReflect.Descriptor instead. func (*CreateDistributionRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{35} + return file_flipt_proto_rawDescGZIP(), []int{42} } func (x *CreateDistributionRequest) GetFlagKey() string { @@ -2745,22 +3421,30 @@ func (x *CreateDistributionRequest) GetRollout() float32 { return 0 } +func (x *CreateDistributionRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type UpdateDistributionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - RuleId string `protobuf:"bytes,3,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` - VariantId string `protobuf:"bytes,4,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` - Rollout float32 `protobuf:"fixed32,5,opt,name=rollout,proto3" json:"rollout,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + RuleId string `protobuf:"bytes,3,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` + VariantId string `protobuf:"bytes,4,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` + Rollout float32 `protobuf:"fixed32,5,opt,name=rollout,proto3" json:"rollout,omitempty"` + NamespaceKey string `protobuf:"bytes,6,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *UpdateDistributionRequest) Reset() { *x = UpdateDistributionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[36] + mi := &file_flipt_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2773,7 +3457,7 @@ func (x *UpdateDistributionRequest) String() string { func (*UpdateDistributionRequest) ProtoMessage() {} func (x *UpdateDistributionRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[36] + mi := &file_flipt_proto_msgTypes[43] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2786,7 +3470,7 @@ func (x *UpdateDistributionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateDistributionRequest.ProtoReflect.Descriptor instead. func (*UpdateDistributionRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{36} + return file_flipt_proto_rawDescGZIP(), []int{43} } func (x *UpdateDistributionRequest) GetId() string { @@ -2824,21 +3508,29 @@ func (x *UpdateDistributionRequest) GetRollout() float32 { return 0 } +func (x *UpdateDistributionRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + type DeleteDistributionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` - RuleId string `protobuf:"bytes,3,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` - VariantId string `protobuf:"bytes,4,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FlagKey string `protobuf:"bytes,2,opt,name=flag_key,json=flagKey,proto3" json:"flag_key,omitempty"` + RuleId string `protobuf:"bytes,3,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` + VariantId string `protobuf:"bytes,4,opt,name=variant_id,json=variantId,proto3" json:"variant_id,omitempty"` + NamespaceKey string `protobuf:"bytes,5,opt,name=namespace_key,json=namespaceKey,proto3" json:"namespace_key,omitempty"` } func (x *DeleteDistributionRequest) Reset() { *x = DeleteDistributionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_flipt_proto_msgTypes[37] + mi := &file_flipt_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2851,7 +3543,7 @@ func (x *DeleteDistributionRequest) String() string { func (*DeleteDistributionRequest) ProtoMessage() {} func (x *DeleteDistributionRequest) ProtoReflect() protoreflect.Message { - mi := &file_flipt_proto_msgTypes[37] + mi := &file_flipt_proto_msgTypes[44] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2864,7 +3556,7 @@ func (x *DeleteDistributionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteDistributionRequest.ProtoReflect.Descriptor instead. func (*DeleteDistributionRequest) Descriptor() ([]byte, []int) { - return file_flipt_proto_rawDescGZIP(), []int{37} + return file_flipt_proto_rawDescGZIP(), []int{44} } func (x *DeleteDistributionRequest) GetId() string { @@ -2895,6 +3587,13 @@ func (x *DeleteDistributionRequest) GetVariantId() string { return "" } +func (x *DeleteDistributionRequest) GetNamespaceKey() string { + if x != nil { + return x.NamespaceKey + } + return "" +} + var File_flipt_proto protoreflect.FileDescriptor var file_flipt_proto_rawDesc = []byte{ @@ -2903,7 +3602,7 @@ var file_flipt_proto_rawDesc = []byte{ 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xe7, 0x01, 0x0a, 0x11, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, + 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, 0x11, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, @@ -2914,261 +3613,362 @@ var file_flipt_proto_rawDesc = []byte{ 0x32, 0x25, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x1a, 0x3a, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, 0x01, 0x0a, - 0x16, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, - 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x11, - 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x6e, 0x6f, 0x74, 0x5f, 0x66, 0x6f, 0x75, 0x6e, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, - 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0x96, 0x04, 0x0a, 0x12, 0x45, 0x76, 0x61, - 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1b, - 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x49, 0x64, 0x12, 0x56, 0x0a, 0x0f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, - 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, - 0x65, 0x78, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, - 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, - 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x12, 0x1e, 0x0a, - 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, - 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, - 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x1a, 0x41, - 0x0a, 0x13, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4b, 0x65, 0x79, 0x1a, 0x3a, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0xa9, 0x01, 0x0a, 0x17, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x09, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x22, 0x8a, 0x02, - 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x22, 0xbe, 0x01, 0x0a, 0x16, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x08, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x6e, 0x6f, 0x74, + 0x5f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x78, + 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x23, 0x0a, + 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, + 0x65, 0x79, 0x22, 0xbb, 0x04, 0x0a, 0x12, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x49, 0x64, 0x12, 0x56, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, + 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, 0x61, + 0x74, 0x63, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, + 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, + 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x36, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, + 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, + 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, + 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, + 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x1a, 0x41, 0x0a, + 0x13, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0xa9, 0x01, 0x0a, 0x17, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x09, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, + 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x15, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, 0x75, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x22, 0xe7, 0x01, 0x0a, + 0x09, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, + 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x0d, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x66, + 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x0a, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x27, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x67, 0x0a, 0x14, + 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, + 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, + 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x60, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x60, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x16, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0xaf, 0x02, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x2a, 0x0a, 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, + 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, + 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, + 0x74, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x76, 0x0a, 0x08, 0x46, 0x6c, 0x61, 0x67, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, + 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, + 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1f, + 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x47, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x87, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, + 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x23, 0x0a, + 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, + 0x65, 0x79, 0x22, 0x9a, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, + 0x9a, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x4a, 0x0a, 0x11, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xb7, 0x02, 0x0a, 0x07, 0x56, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x23, 0x0a, + 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, + 0x65, 0x79, 0x22, 0xbe, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, + 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, + 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, - 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, - 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x2a, - 0x0a, 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, - 0x52, 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x76, 0x0a, 0x08, 0x46, 0x6c, - 0x61, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, - 0x61, 0x67, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, - 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x62, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x6c, - 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, + 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x23, + 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x4b, 0x65, 0x79, 0x22, 0xce, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x61, + 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, + 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x4b, 0x65, 0x79, 0x22, 0x66, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x61, + 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, + 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xd2, 0x02, 0x0a, + 0x07, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, + 0x61, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x0b, + 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x0a, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x09, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, + 0x79, 0x22, 0x82, 0x01, 0x0a, 0x0b, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x12, 0x2a, 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x26, 0x0a, + 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, + 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x4a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, + 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, + 0x65, 0x79, 0x22, 0x8a, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x75, 0x0a, 0x11, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, + 0xb4, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x2f, 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4d, 0x61, 0x74, + 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xb4, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x22, 0x75, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, - 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x22, 0x25, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, - 0x92, 0x02, 0x0a, 0x07, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, - 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, - 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, - 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, - 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, - 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x99, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, - 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, - 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, - 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, - 0x22, 0xa9, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, - 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, - 0x67, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, - 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x41, 0x0a, 0x14, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x22, - 0xad, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, - 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, - 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, - 0x74, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x2f, - 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x22, - 0x82, 0x01, 0x0a, 0x0b, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, - 0x2a, 0x0a, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x08, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, - 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x65, 0x0a, 0x12, 0x4c, - 0x69, 0x73, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6f, 0x66, 0x66, - 0x73, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x22, 0x8f, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, - 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x6d, 0x61, 0x74, 0x63, 0x68, - 0x54, 0x79, 0x70, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, - 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, - 0x74, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x6d, 0x61, 0x74, - 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x22, 0x28, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x22, 0xac, 0x02, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, - 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, - 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, - 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, - 0x74, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, - 0x61, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, - 0xb3, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x4d, 0x0a, + 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xd1, 0x02, 0x0a, + 0x0a, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x66, 0x6c, 0x69, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, - 0x72, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc3, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, + 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, + 0x22, 0xd8, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, + 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xe8, 0x01, 0x0a, 0x17, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, + 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, + 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x6f, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, - 0x65, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, - 0x73, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x4a, 0x0a, 0x17, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, - 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x97, 0x02, 0x0a, 0x04, 0x52, 0x75, 0x6c, 0x65, + 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xbc, 0x02, 0x0a, 0x04, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, @@ -3186,224 +3986,270 @@ var file_flipt_proto_rawDesc = []byte{ 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x22, 0x76, 0x0a, 0x08, 0x52, 0x75, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x21, 0x0a, - 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x66, - 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, - 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, - 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7d, 0x0a, 0x0f, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x19, - 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, - 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3b, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, - 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, - 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, - 0x61, 0x67, 0x4b, 0x65, 0x79, 0x22, 0x63, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, - 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, - 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, - 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x22, 0x5f, 0x0a, 0x11, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x3e, 0x0a, 0x11, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x22, 0x49, 0x0a, 0x11, 0x4f, - 0x72, 0x64, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x72, - 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x72, - 0x75, 0x6c, 0x65, 0x49, 0x64, 0x73, 0x22, 0xe6, 0x01, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, - 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, - 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, - 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, - 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, - 0x88, 0x01, 0x0a, 0x19, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, - 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, - 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x02, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x22, 0x98, 0x01, 0x0a, 0x19, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, - 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, - 0x4b, 0x65, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, - 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, - 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x07, 0x72, 0x6f, - 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x22, 0x7e, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, - 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x17, 0x0a, - 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x76, 0x0a, 0x08, 0x52, 0x75, 0x6c, 0x65, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, + 0x72, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1f, 0x0a, + 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa2, + 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1a, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, + 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x6f, 0x66, + 0x66, 0x73, 0x65, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, + 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x23, + 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x4b, 0x65, 0x79, 0x22, 0x60, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, + 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x88, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, + 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, + 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, + 0x22, 0x84, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, + 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4b, + 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x63, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, + 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x6e, 0x0a, 0x11, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x0a, 0x08, + 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, + 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xe6, 0x01, 0x0a, + 0x0c, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, + 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x6e, 0x74, 0x49, 0x64, 0x2a, 0xb6, 0x01, 0x0a, 0x10, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x19, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, - 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x23, 0x0a, 0x1f, 0x46, 0x4c, 0x41, - 0x47, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, - 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x24, - 0x0a, 0x20, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x12, + 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xad, 0x01, 0x0a, 0x19, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x17, + 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, + 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, + 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xbd, 0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x17, + 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, + 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, + 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, + 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xa3, 0x01, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x6c, 0x61, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x17, + 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x72, 0x75, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x69, 0x61, + 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x2a, 0xb6, 0x01, 0x0a, 0x10, + 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x12, 0x1d, 0x0a, 0x19, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x45, 0x56, 0x41, 0x4c, + 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x00, 0x12, + 0x23, 0x0a, 0x1f, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, - 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x45, 0x56, - 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, - 0x03, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, - 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x04, 0x2a, 0x33, - 0x0a, 0x09, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x41, - 0x4c, 0x4c, 0x5f, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, - 0x12, 0x0a, 0x0e, 0x41, 0x4e, 0x59, 0x5f, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x10, 0x01, 0x2a, 0x82, 0x01, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, - 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x17, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x4f, - 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x01, 0x12, - 0x1a, 0x0a, 0x16, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, - 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x42, - 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, - 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x03, 0x32, 0xeb, 0x0d, 0x0a, 0x05, 0x46, 0x6c, 0x69, - 0x70, 0x74, 0x12, 0x41, 0x0a, 0x08, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x12, 0x18, + 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x24, 0x0a, 0x20, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x4e, 0x4f, 0x54, + 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x4d, 0x41, + 0x54, 0x43, 0x48, 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, + 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x10, 0x03, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x52, 0x52, 0x4f, 0x52, + 0x5f, 0x45, 0x56, 0x41, 0x4c, 0x55, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, + 0x4f, 0x4e, 0x10, 0x04, 0x2a, 0x33, 0x0a, 0x09, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x4c, 0x4c, 0x5f, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x4e, 0x59, 0x5f, 0x4d, 0x41, 0x54, + 0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x01, 0x2a, 0x82, 0x01, 0x0a, 0x0e, 0x43, 0x6f, + 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x17, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, + 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x54, 0x52, + 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x5f, + 0x43, 0x4f, 0x4d, 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, + 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, + 0x50, 0x41, 0x52, 0x49, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x03, 0x32, 0xca, + 0x10, 0x0a, 0x05, 0x46, 0x6c, 0x69, 0x70, 0x74, 0x12, 0x41, 0x0a, 0x08, 0x45, 0x76, 0x61, 0x6c, + 0x75, 0x61, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, + 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, - 0x2e, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, - 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x46, 0x6c, - 0x61, 0x67, 0x12, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x6c, - 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, - 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, - 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, - 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, - 0x12, 0x35, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x18, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, - 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x00, 0x12, 0x40, - 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x18, 0x2e, 0x66, - 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, - 0x12, 0x3e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, - 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x22, 0x00, - 0x12, 0x3e, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, - 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x22, 0x00, - 0x12, 0x46, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, - 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, - 0x75, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x52, - 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, - 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x09, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, - 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x22, - 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, - 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x75, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, - 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x00, 0x12, - 0x40, 0x0a, 0x0a, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x2e, - 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x00, 0x12, 0x40, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, - 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x75, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x66, 0x6c, 0x69, 0x70, - 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x66, 0x6c, - 0x69, 0x70, 0x74, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x66, 0x6c, 0x69, - 0x70, 0x74, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x22, - 0x00, 0x12, 0x50, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x67, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x66, 0x6c, - 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x3f, 0x0a, - 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x19, 0x2e, - 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, - 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x12, 0x3e, - 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x66, - 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x3e, - 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x66, - 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x46, - 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0d, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x66, + 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1a, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, + 0x74, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, + 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, + 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x66, + 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4c, 0x69, + 0x73, 0x74, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x66, + 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x00, + 0x12, 0x4a, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x07, + 0x47, 0x65, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, + 0x47, 0x65, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, + 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x00, 0x12, 0x36, 0x0a, + 0x09, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x66, 0x6c, 0x69, + 0x70, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x4c, + 0x69, 0x73, 0x74, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, + 0x6c, 0x61, 0x67, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0a, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, + 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x46, 0x6c, 0x61, + 0x67, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x6c, 0x61, + 0x67, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, + 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x56, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, + 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x56, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, + 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2f, 0x0a, + 0x07, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, + 0x2e, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x36, + 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, + 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x52, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, + 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, + 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x66, 0x6c, + 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x52, 0x75, + 0x6c, 0x65, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0a, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x75, 0x6c, + 0x65, 0x73, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x66, 0x6c, 0x69, - 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, - 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x66, 0x6c, 0x69, - 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x22, 0x00, 0x12, - 0x47, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, - 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, - 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x66, - 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, - 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x1d, 0x5a, 0x1b, 0x67, 0x6f, 0x2e, 0x66, 0x6c, 0x69, - 0x70, 0x74, 0x2e, 0x69, 0x6f, 0x2f, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2f, 0x72, 0x70, 0x63, 0x2f, - 0x66, 0x6c, 0x69, 0x70, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, + 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x13, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x13, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x66, + 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x69, 0x73, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x47, + 0x65, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x19, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, + 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x10, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, + 0x1e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x11, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, + 0x6e, 0x74, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, + 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x4c, 0x0a, + 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, + 0x74, 0x12, 0x1e, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x1d, 0x5a, 0x1b, 0x67, + 0x6f, 0x2e, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x2e, 0x69, 0x6f, 0x2f, 0x66, 0x6c, 0x69, 0x70, 0x74, + 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x66, 0x6c, 0x69, 0x70, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -3419,7 +4265,7 @@ func file_flipt_proto_rawDescGZIP() []byte { } var file_flipt_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_flipt_proto_msgTypes = make([]protoimpl.MessageInfo, 40) +var file_flipt_proto_msgTypes = make([]protoimpl.MessageInfo, 47) var file_flipt_proto_goTypes = []interface{}{ (EvaluationReason)(0), // 0: flipt.EvaluationReason (MatchType)(0), // 1: flipt.MatchType @@ -3428,135 +4274,155 @@ var file_flipt_proto_goTypes = []interface{}{ (*BatchEvaluationRequest)(nil), // 4: flipt.BatchEvaluationRequest (*EvaluationResponse)(nil), // 5: flipt.EvaluationResponse (*BatchEvaluationResponse)(nil), // 6: flipt.BatchEvaluationResponse - (*Flag)(nil), // 7: flipt.Flag - (*FlagList)(nil), // 8: flipt.FlagList - (*GetFlagRequest)(nil), // 9: flipt.GetFlagRequest - (*ListFlagRequest)(nil), // 10: flipt.ListFlagRequest - (*CreateFlagRequest)(nil), // 11: flipt.CreateFlagRequest - (*UpdateFlagRequest)(nil), // 12: flipt.UpdateFlagRequest - (*DeleteFlagRequest)(nil), // 13: flipt.DeleteFlagRequest - (*Variant)(nil), // 14: flipt.Variant - (*CreateVariantRequest)(nil), // 15: flipt.CreateVariantRequest - (*UpdateVariantRequest)(nil), // 16: flipt.UpdateVariantRequest - (*DeleteVariantRequest)(nil), // 17: flipt.DeleteVariantRequest - (*Segment)(nil), // 18: flipt.Segment - (*SegmentList)(nil), // 19: flipt.SegmentList - (*GetSegmentRequest)(nil), // 20: flipt.GetSegmentRequest - (*ListSegmentRequest)(nil), // 21: flipt.ListSegmentRequest - (*CreateSegmentRequest)(nil), // 22: flipt.CreateSegmentRequest - (*UpdateSegmentRequest)(nil), // 23: flipt.UpdateSegmentRequest - (*DeleteSegmentRequest)(nil), // 24: flipt.DeleteSegmentRequest - (*Constraint)(nil), // 25: flipt.Constraint - (*CreateConstraintRequest)(nil), // 26: flipt.CreateConstraintRequest - (*UpdateConstraintRequest)(nil), // 27: flipt.UpdateConstraintRequest - (*DeleteConstraintRequest)(nil), // 28: flipt.DeleteConstraintRequest - (*Rule)(nil), // 29: flipt.Rule - (*RuleList)(nil), // 30: flipt.RuleList - (*ListRuleRequest)(nil), // 31: flipt.ListRuleRequest - (*GetRuleRequest)(nil), // 32: flipt.GetRuleRequest - (*CreateRuleRequest)(nil), // 33: flipt.CreateRuleRequest - (*UpdateRuleRequest)(nil), // 34: flipt.UpdateRuleRequest - (*DeleteRuleRequest)(nil), // 35: flipt.DeleteRuleRequest - (*OrderRulesRequest)(nil), // 36: flipt.OrderRulesRequest - (*Distribution)(nil), // 37: flipt.Distribution - (*CreateDistributionRequest)(nil), // 38: flipt.CreateDistributionRequest - (*UpdateDistributionRequest)(nil), // 39: flipt.UpdateDistributionRequest - (*DeleteDistributionRequest)(nil), // 40: flipt.DeleteDistributionRequest - nil, // 41: flipt.EvaluationRequest.ContextEntry - nil, // 42: flipt.EvaluationResponse.RequestContextEntry - (*timestamppb.Timestamp)(nil), // 43: google.protobuf.Timestamp - (*emptypb.Empty)(nil), // 44: google.protobuf.Empty + (*Namespace)(nil), // 7: flipt.Namespace + (*NamespaceList)(nil), // 8: flipt.NamespaceList + (*GetNamespaceRequest)(nil), // 9: flipt.GetNamespaceRequest + (*ListNamespaceRequest)(nil), // 10: flipt.ListNamespaceRequest + (*CreateNamespaceRequest)(nil), // 11: flipt.CreateNamespaceRequest + (*UpdateNamespaceRequest)(nil), // 12: flipt.UpdateNamespaceRequest + (*DeleteNamespaceRequest)(nil), // 13: flipt.DeleteNamespaceRequest + (*Flag)(nil), // 14: flipt.Flag + (*FlagList)(nil), // 15: flipt.FlagList + (*GetFlagRequest)(nil), // 16: flipt.GetFlagRequest + (*ListFlagRequest)(nil), // 17: flipt.ListFlagRequest + (*CreateFlagRequest)(nil), // 18: flipt.CreateFlagRequest + (*UpdateFlagRequest)(nil), // 19: flipt.UpdateFlagRequest + (*DeleteFlagRequest)(nil), // 20: flipt.DeleteFlagRequest + (*Variant)(nil), // 21: flipt.Variant + (*CreateVariantRequest)(nil), // 22: flipt.CreateVariantRequest + (*UpdateVariantRequest)(nil), // 23: flipt.UpdateVariantRequest + (*DeleteVariantRequest)(nil), // 24: flipt.DeleteVariantRequest + (*Segment)(nil), // 25: flipt.Segment + (*SegmentList)(nil), // 26: flipt.SegmentList + (*GetSegmentRequest)(nil), // 27: flipt.GetSegmentRequest + (*ListSegmentRequest)(nil), // 28: flipt.ListSegmentRequest + (*CreateSegmentRequest)(nil), // 29: flipt.CreateSegmentRequest + (*UpdateSegmentRequest)(nil), // 30: flipt.UpdateSegmentRequest + (*DeleteSegmentRequest)(nil), // 31: flipt.DeleteSegmentRequest + (*Constraint)(nil), // 32: flipt.Constraint + (*CreateConstraintRequest)(nil), // 33: flipt.CreateConstraintRequest + (*UpdateConstraintRequest)(nil), // 34: flipt.UpdateConstraintRequest + (*DeleteConstraintRequest)(nil), // 35: flipt.DeleteConstraintRequest + (*Rule)(nil), // 36: flipt.Rule + (*RuleList)(nil), // 37: flipt.RuleList + (*ListRuleRequest)(nil), // 38: flipt.ListRuleRequest + (*GetRuleRequest)(nil), // 39: flipt.GetRuleRequest + (*CreateRuleRequest)(nil), // 40: flipt.CreateRuleRequest + (*UpdateRuleRequest)(nil), // 41: flipt.UpdateRuleRequest + (*DeleteRuleRequest)(nil), // 42: flipt.DeleteRuleRequest + (*OrderRulesRequest)(nil), // 43: flipt.OrderRulesRequest + (*Distribution)(nil), // 44: flipt.Distribution + (*CreateDistributionRequest)(nil), // 45: flipt.CreateDistributionRequest + (*UpdateDistributionRequest)(nil), // 46: flipt.UpdateDistributionRequest + (*DeleteDistributionRequest)(nil), // 47: flipt.DeleteDistributionRequest + nil, // 48: flipt.EvaluationRequest.ContextEntry + nil, // 49: flipt.EvaluationResponse.RequestContextEntry + (*timestamppb.Timestamp)(nil), // 50: google.protobuf.Timestamp + (*emptypb.Empty)(nil), // 51: google.protobuf.Empty } var file_flipt_proto_depIdxs = []int32{ - 41, // 0: flipt.EvaluationRequest.context:type_name -> flipt.EvaluationRequest.ContextEntry + 48, // 0: flipt.EvaluationRequest.context:type_name -> flipt.EvaluationRequest.ContextEntry 3, // 1: flipt.BatchEvaluationRequest.requests:type_name -> flipt.EvaluationRequest - 42, // 2: flipt.EvaluationResponse.request_context:type_name -> flipt.EvaluationResponse.RequestContextEntry - 43, // 3: flipt.EvaluationResponse.timestamp:type_name -> google.protobuf.Timestamp + 49, // 2: flipt.EvaluationResponse.request_context:type_name -> flipt.EvaluationResponse.RequestContextEntry + 50, // 3: flipt.EvaluationResponse.timestamp:type_name -> google.protobuf.Timestamp 0, // 4: flipt.EvaluationResponse.reason:type_name -> flipt.EvaluationReason 5, // 5: flipt.BatchEvaluationResponse.responses:type_name -> flipt.EvaluationResponse - 43, // 6: flipt.Flag.created_at:type_name -> google.protobuf.Timestamp - 43, // 7: flipt.Flag.updated_at:type_name -> google.protobuf.Timestamp - 14, // 8: flipt.Flag.variants:type_name -> flipt.Variant - 7, // 9: flipt.FlagList.flags:type_name -> flipt.Flag - 43, // 10: flipt.Variant.created_at:type_name -> google.protobuf.Timestamp - 43, // 11: flipt.Variant.updated_at:type_name -> google.protobuf.Timestamp - 43, // 12: flipt.Segment.created_at:type_name -> google.protobuf.Timestamp - 43, // 13: flipt.Segment.updated_at:type_name -> google.protobuf.Timestamp - 25, // 14: flipt.Segment.constraints:type_name -> flipt.Constraint - 1, // 15: flipt.Segment.match_type:type_name -> flipt.MatchType - 18, // 16: flipt.SegmentList.segments:type_name -> flipt.Segment - 1, // 17: flipt.CreateSegmentRequest.match_type:type_name -> flipt.MatchType - 1, // 18: flipt.UpdateSegmentRequest.match_type:type_name -> flipt.MatchType - 2, // 19: flipt.Constraint.type:type_name -> flipt.ComparisonType - 43, // 20: flipt.Constraint.created_at:type_name -> google.protobuf.Timestamp - 43, // 21: flipt.Constraint.updated_at:type_name -> google.protobuf.Timestamp - 2, // 22: flipt.CreateConstraintRequest.type:type_name -> flipt.ComparisonType - 2, // 23: flipt.UpdateConstraintRequest.type:type_name -> flipt.ComparisonType - 37, // 24: flipt.Rule.distributions:type_name -> flipt.Distribution - 43, // 25: flipt.Rule.created_at:type_name -> google.protobuf.Timestamp - 43, // 26: flipt.Rule.updated_at:type_name -> google.protobuf.Timestamp - 29, // 27: flipt.RuleList.rules:type_name -> flipt.Rule - 43, // 28: flipt.Distribution.created_at:type_name -> google.protobuf.Timestamp - 43, // 29: flipt.Distribution.updated_at:type_name -> google.protobuf.Timestamp - 3, // 30: flipt.Flipt.Evaluate:input_type -> flipt.EvaluationRequest - 4, // 31: flipt.Flipt.BatchEvaluate:input_type -> flipt.BatchEvaluationRequest - 9, // 32: flipt.Flipt.GetFlag:input_type -> flipt.GetFlagRequest - 10, // 33: flipt.Flipt.ListFlags:input_type -> flipt.ListFlagRequest - 11, // 34: flipt.Flipt.CreateFlag:input_type -> flipt.CreateFlagRequest - 12, // 35: flipt.Flipt.UpdateFlag:input_type -> flipt.UpdateFlagRequest - 13, // 36: flipt.Flipt.DeleteFlag:input_type -> flipt.DeleteFlagRequest - 15, // 37: flipt.Flipt.CreateVariant:input_type -> flipt.CreateVariantRequest - 16, // 38: flipt.Flipt.UpdateVariant:input_type -> flipt.UpdateVariantRequest - 17, // 39: flipt.Flipt.DeleteVariant:input_type -> flipt.DeleteVariantRequest - 32, // 40: flipt.Flipt.GetRule:input_type -> flipt.GetRuleRequest - 31, // 41: flipt.Flipt.ListRules:input_type -> flipt.ListRuleRequest - 33, // 42: flipt.Flipt.CreateRule:input_type -> flipt.CreateRuleRequest - 34, // 43: flipt.Flipt.UpdateRule:input_type -> flipt.UpdateRuleRequest - 36, // 44: flipt.Flipt.OrderRules:input_type -> flipt.OrderRulesRequest - 35, // 45: flipt.Flipt.DeleteRule:input_type -> flipt.DeleteRuleRequest - 38, // 46: flipt.Flipt.CreateDistribution:input_type -> flipt.CreateDistributionRequest - 39, // 47: flipt.Flipt.UpdateDistribution:input_type -> flipt.UpdateDistributionRequest - 40, // 48: flipt.Flipt.DeleteDistribution:input_type -> flipt.DeleteDistributionRequest - 20, // 49: flipt.Flipt.GetSegment:input_type -> flipt.GetSegmentRequest - 21, // 50: flipt.Flipt.ListSegments:input_type -> flipt.ListSegmentRequest - 22, // 51: flipt.Flipt.CreateSegment:input_type -> flipt.CreateSegmentRequest - 23, // 52: flipt.Flipt.UpdateSegment:input_type -> flipt.UpdateSegmentRequest - 24, // 53: flipt.Flipt.DeleteSegment:input_type -> flipt.DeleteSegmentRequest - 26, // 54: flipt.Flipt.CreateConstraint:input_type -> flipt.CreateConstraintRequest - 27, // 55: flipt.Flipt.UpdateConstraint:input_type -> flipt.UpdateConstraintRequest - 28, // 56: flipt.Flipt.DeleteConstraint:input_type -> flipt.DeleteConstraintRequest - 5, // 57: flipt.Flipt.Evaluate:output_type -> flipt.EvaluationResponse - 6, // 58: flipt.Flipt.BatchEvaluate:output_type -> flipt.BatchEvaluationResponse - 7, // 59: flipt.Flipt.GetFlag:output_type -> flipt.Flag - 8, // 60: flipt.Flipt.ListFlags:output_type -> flipt.FlagList - 7, // 61: flipt.Flipt.CreateFlag:output_type -> flipt.Flag - 7, // 62: flipt.Flipt.UpdateFlag:output_type -> flipt.Flag - 44, // 63: flipt.Flipt.DeleteFlag:output_type -> google.protobuf.Empty - 14, // 64: flipt.Flipt.CreateVariant:output_type -> flipt.Variant - 14, // 65: flipt.Flipt.UpdateVariant:output_type -> flipt.Variant - 44, // 66: flipt.Flipt.DeleteVariant:output_type -> google.protobuf.Empty - 29, // 67: flipt.Flipt.GetRule:output_type -> flipt.Rule - 30, // 68: flipt.Flipt.ListRules:output_type -> flipt.RuleList - 29, // 69: flipt.Flipt.CreateRule:output_type -> flipt.Rule - 29, // 70: flipt.Flipt.UpdateRule:output_type -> flipt.Rule - 44, // 71: flipt.Flipt.OrderRules:output_type -> google.protobuf.Empty - 44, // 72: flipt.Flipt.DeleteRule:output_type -> google.protobuf.Empty - 37, // 73: flipt.Flipt.CreateDistribution:output_type -> flipt.Distribution - 37, // 74: flipt.Flipt.UpdateDistribution:output_type -> flipt.Distribution - 44, // 75: flipt.Flipt.DeleteDistribution:output_type -> google.protobuf.Empty - 18, // 76: flipt.Flipt.GetSegment:output_type -> flipt.Segment - 19, // 77: flipt.Flipt.ListSegments:output_type -> flipt.SegmentList - 18, // 78: flipt.Flipt.CreateSegment:output_type -> flipt.Segment - 18, // 79: flipt.Flipt.UpdateSegment:output_type -> flipt.Segment - 44, // 80: flipt.Flipt.DeleteSegment:output_type -> google.protobuf.Empty - 25, // 81: flipt.Flipt.CreateConstraint:output_type -> flipt.Constraint - 25, // 82: flipt.Flipt.UpdateConstraint:output_type -> flipt.Constraint - 44, // 83: flipt.Flipt.DeleteConstraint:output_type -> google.protobuf.Empty - 57, // [57:84] is the sub-list for method output_type - 30, // [30:57] is the sub-list for method input_type - 30, // [30:30] is the sub-list for extension type_name - 30, // [30:30] is the sub-list for extension extendee - 0, // [0:30] is the sub-list for field type_name + 50, // 6: flipt.Namespace.created_at:type_name -> google.protobuf.Timestamp + 50, // 7: flipt.Namespace.updated_at:type_name -> google.protobuf.Timestamp + 7, // 8: flipt.NamespaceList.namespaces:type_name -> flipt.Namespace + 50, // 9: flipt.Flag.created_at:type_name -> google.protobuf.Timestamp + 50, // 10: flipt.Flag.updated_at:type_name -> google.protobuf.Timestamp + 21, // 11: flipt.Flag.variants:type_name -> flipt.Variant + 14, // 12: flipt.FlagList.flags:type_name -> flipt.Flag + 50, // 13: flipt.Variant.created_at:type_name -> google.protobuf.Timestamp + 50, // 14: flipt.Variant.updated_at:type_name -> google.protobuf.Timestamp + 50, // 15: flipt.Segment.created_at:type_name -> google.protobuf.Timestamp + 50, // 16: flipt.Segment.updated_at:type_name -> google.protobuf.Timestamp + 32, // 17: flipt.Segment.constraints:type_name -> flipt.Constraint + 1, // 18: flipt.Segment.match_type:type_name -> flipt.MatchType + 25, // 19: flipt.SegmentList.segments:type_name -> flipt.Segment + 1, // 20: flipt.CreateSegmentRequest.match_type:type_name -> flipt.MatchType + 1, // 21: flipt.UpdateSegmentRequest.match_type:type_name -> flipt.MatchType + 2, // 22: flipt.Constraint.type:type_name -> flipt.ComparisonType + 50, // 23: flipt.Constraint.created_at:type_name -> google.protobuf.Timestamp + 50, // 24: flipt.Constraint.updated_at:type_name -> google.protobuf.Timestamp + 2, // 25: flipt.CreateConstraintRequest.type:type_name -> flipt.ComparisonType + 2, // 26: flipt.UpdateConstraintRequest.type:type_name -> flipt.ComparisonType + 44, // 27: flipt.Rule.distributions:type_name -> flipt.Distribution + 50, // 28: flipt.Rule.created_at:type_name -> google.protobuf.Timestamp + 50, // 29: flipt.Rule.updated_at:type_name -> google.protobuf.Timestamp + 36, // 30: flipt.RuleList.rules:type_name -> flipt.Rule + 50, // 31: flipt.Distribution.created_at:type_name -> google.protobuf.Timestamp + 50, // 32: flipt.Distribution.updated_at:type_name -> google.protobuf.Timestamp + 3, // 33: flipt.Flipt.Evaluate:input_type -> flipt.EvaluationRequest + 4, // 34: flipt.Flipt.BatchEvaluate:input_type -> flipt.BatchEvaluationRequest + 9, // 35: flipt.Flipt.GetNamespace:input_type -> flipt.GetNamespaceRequest + 10, // 36: flipt.Flipt.ListNamespaces:input_type -> flipt.ListNamespaceRequest + 11, // 37: flipt.Flipt.CreateNamespace:input_type -> flipt.CreateNamespaceRequest + 12, // 38: flipt.Flipt.UpdateNamespace:input_type -> flipt.UpdateNamespaceRequest + 13, // 39: flipt.Flipt.DeleteNamespace:input_type -> flipt.DeleteNamespaceRequest + 16, // 40: flipt.Flipt.GetFlag:input_type -> flipt.GetFlagRequest + 17, // 41: flipt.Flipt.ListFlags:input_type -> flipt.ListFlagRequest + 18, // 42: flipt.Flipt.CreateFlag:input_type -> flipt.CreateFlagRequest + 19, // 43: flipt.Flipt.UpdateFlag:input_type -> flipt.UpdateFlagRequest + 20, // 44: flipt.Flipt.DeleteFlag:input_type -> flipt.DeleteFlagRequest + 22, // 45: flipt.Flipt.CreateVariant:input_type -> flipt.CreateVariantRequest + 23, // 46: flipt.Flipt.UpdateVariant:input_type -> flipt.UpdateVariantRequest + 24, // 47: flipt.Flipt.DeleteVariant:input_type -> flipt.DeleteVariantRequest + 39, // 48: flipt.Flipt.GetRule:input_type -> flipt.GetRuleRequest + 38, // 49: flipt.Flipt.ListRules:input_type -> flipt.ListRuleRequest + 40, // 50: flipt.Flipt.CreateRule:input_type -> flipt.CreateRuleRequest + 41, // 51: flipt.Flipt.UpdateRule:input_type -> flipt.UpdateRuleRequest + 43, // 52: flipt.Flipt.OrderRules:input_type -> flipt.OrderRulesRequest + 42, // 53: flipt.Flipt.DeleteRule:input_type -> flipt.DeleteRuleRequest + 45, // 54: flipt.Flipt.CreateDistribution:input_type -> flipt.CreateDistributionRequest + 46, // 55: flipt.Flipt.UpdateDistribution:input_type -> flipt.UpdateDistributionRequest + 47, // 56: flipt.Flipt.DeleteDistribution:input_type -> flipt.DeleteDistributionRequest + 27, // 57: flipt.Flipt.GetSegment:input_type -> flipt.GetSegmentRequest + 28, // 58: flipt.Flipt.ListSegments:input_type -> flipt.ListSegmentRequest + 29, // 59: flipt.Flipt.CreateSegment:input_type -> flipt.CreateSegmentRequest + 30, // 60: flipt.Flipt.UpdateSegment:input_type -> flipt.UpdateSegmentRequest + 31, // 61: flipt.Flipt.DeleteSegment:input_type -> flipt.DeleteSegmentRequest + 33, // 62: flipt.Flipt.CreateConstraint:input_type -> flipt.CreateConstraintRequest + 34, // 63: flipt.Flipt.UpdateConstraint:input_type -> flipt.UpdateConstraintRequest + 35, // 64: flipt.Flipt.DeleteConstraint:input_type -> flipt.DeleteConstraintRequest + 5, // 65: flipt.Flipt.Evaluate:output_type -> flipt.EvaluationResponse + 6, // 66: flipt.Flipt.BatchEvaluate:output_type -> flipt.BatchEvaluationResponse + 7, // 67: flipt.Flipt.GetNamespace:output_type -> flipt.Namespace + 8, // 68: flipt.Flipt.ListNamespaces:output_type -> flipt.NamespaceList + 7, // 69: flipt.Flipt.CreateNamespace:output_type -> flipt.Namespace + 7, // 70: flipt.Flipt.UpdateNamespace:output_type -> flipt.Namespace + 51, // 71: flipt.Flipt.DeleteNamespace:output_type -> google.protobuf.Empty + 14, // 72: flipt.Flipt.GetFlag:output_type -> flipt.Flag + 15, // 73: flipt.Flipt.ListFlags:output_type -> flipt.FlagList + 14, // 74: flipt.Flipt.CreateFlag:output_type -> flipt.Flag + 14, // 75: flipt.Flipt.UpdateFlag:output_type -> flipt.Flag + 51, // 76: flipt.Flipt.DeleteFlag:output_type -> google.protobuf.Empty + 21, // 77: flipt.Flipt.CreateVariant:output_type -> flipt.Variant + 21, // 78: flipt.Flipt.UpdateVariant:output_type -> flipt.Variant + 51, // 79: flipt.Flipt.DeleteVariant:output_type -> google.protobuf.Empty + 36, // 80: flipt.Flipt.GetRule:output_type -> flipt.Rule + 37, // 81: flipt.Flipt.ListRules:output_type -> flipt.RuleList + 36, // 82: flipt.Flipt.CreateRule:output_type -> flipt.Rule + 36, // 83: flipt.Flipt.UpdateRule:output_type -> flipt.Rule + 51, // 84: flipt.Flipt.OrderRules:output_type -> google.protobuf.Empty + 51, // 85: flipt.Flipt.DeleteRule:output_type -> google.protobuf.Empty + 44, // 86: flipt.Flipt.CreateDistribution:output_type -> flipt.Distribution + 44, // 87: flipt.Flipt.UpdateDistribution:output_type -> flipt.Distribution + 51, // 88: flipt.Flipt.DeleteDistribution:output_type -> google.protobuf.Empty + 25, // 89: flipt.Flipt.GetSegment:output_type -> flipt.Segment + 26, // 90: flipt.Flipt.ListSegments:output_type -> flipt.SegmentList + 25, // 91: flipt.Flipt.CreateSegment:output_type -> flipt.Segment + 25, // 92: flipt.Flipt.UpdateSegment:output_type -> flipt.Segment + 51, // 93: flipt.Flipt.DeleteSegment:output_type -> google.protobuf.Empty + 32, // 94: flipt.Flipt.CreateConstraint:output_type -> flipt.Constraint + 32, // 95: flipt.Flipt.UpdateConstraint:output_type -> flipt.Constraint + 51, // 96: flipt.Flipt.DeleteConstraint:output_type -> google.protobuf.Empty + 65, // [65:97] is the sub-list for method output_type + 33, // [33:65] is the sub-list for method input_type + 33, // [33:33] is the sub-list for extension type_name + 33, // [33:33] is the sub-list for extension extendee + 0, // [0:33] is the sub-list for field type_name } func init() { file_flipt_proto_init() } @@ -3614,7 +4480,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Flag); i { + switch v := v.(*Namespace); i { case 0: return &v.state case 1: @@ -3626,7 +4492,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FlagList); i { + switch v := v.(*NamespaceList); i { case 0: return &v.state case 1: @@ -3638,7 +4504,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetFlagRequest); i { + switch v := v.(*GetNamespaceRequest); i { case 0: return &v.state case 1: @@ -3650,7 +4516,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListFlagRequest); i { + switch v := v.(*ListNamespaceRequest); i { case 0: return &v.state case 1: @@ -3662,7 +4528,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateFlagRequest); i { + switch v := v.(*CreateNamespaceRequest); i { case 0: return &v.state case 1: @@ -3674,7 +4540,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateFlagRequest); i { + switch v := v.(*UpdateNamespaceRequest); i { case 0: return &v.state case 1: @@ -3686,7 +4552,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteFlagRequest); i { + switch v := v.(*DeleteNamespaceRequest); i { case 0: return &v.state case 1: @@ -3698,7 +4564,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Variant); i { + switch v := v.(*Flag); i { case 0: return &v.state case 1: @@ -3710,7 +4576,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateVariantRequest); i { + switch v := v.(*FlagList); i { case 0: return &v.state case 1: @@ -3722,7 +4588,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateVariantRequest); i { + switch v := v.(*GetFlagRequest); i { case 0: return &v.state case 1: @@ -3734,7 +4600,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteVariantRequest); i { + switch v := v.(*ListFlagRequest); i { case 0: return &v.state case 1: @@ -3746,7 +4612,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Segment); i { + switch v := v.(*CreateFlagRequest); i { case 0: return &v.state case 1: @@ -3758,7 +4624,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SegmentList); i { + switch v := v.(*UpdateFlagRequest); i { case 0: return &v.state case 1: @@ -3770,7 +4636,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetSegmentRequest); i { + switch v := v.(*DeleteFlagRequest); i { case 0: return &v.state case 1: @@ -3782,7 +4648,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListSegmentRequest); i { + switch v := v.(*Variant); i { case 0: return &v.state case 1: @@ -3794,7 +4660,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateSegmentRequest); i { + switch v := v.(*CreateVariantRequest); i { case 0: return &v.state case 1: @@ -3806,7 +4672,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateSegmentRequest); i { + switch v := v.(*UpdateVariantRequest); i { case 0: return &v.state case 1: @@ -3818,7 +4684,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteSegmentRequest); i { + switch v := v.(*DeleteVariantRequest); i { case 0: return &v.state case 1: @@ -3830,7 +4696,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Constraint); i { + switch v := v.(*Segment); i { case 0: return &v.state case 1: @@ -3842,7 +4708,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateConstraintRequest); i { + switch v := v.(*SegmentList); i { case 0: return &v.state case 1: @@ -3854,7 +4720,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateConstraintRequest); i { + switch v := v.(*GetSegmentRequest); i { case 0: return &v.state case 1: @@ -3866,7 +4732,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteConstraintRequest); i { + switch v := v.(*ListSegmentRequest); i { case 0: return &v.state case 1: @@ -3878,7 +4744,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Rule); i { + switch v := v.(*CreateSegmentRequest); i { case 0: return &v.state case 1: @@ -3890,7 +4756,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RuleList); i { + switch v := v.(*UpdateSegmentRequest); i { case 0: return &v.state case 1: @@ -3902,7 +4768,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRuleRequest); i { + switch v := v.(*DeleteSegmentRequest); i { case 0: return &v.state case 1: @@ -3914,7 +4780,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetRuleRequest); i { + switch v := v.(*Constraint); i { case 0: return &v.state case 1: @@ -3926,7 +4792,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateRuleRequest); i { + switch v := v.(*CreateConstraintRequest); i { case 0: return &v.state case 1: @@ -3938,7 +4804,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateRuleRequest); i { + switch v := v.(*UpdateConstraintRequest); i { case 0: return &v.state case 1: @@ -3950,7 +4816,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteRuleRequest); i { + switch v := v.(*DeleteConstraintRequest); i { case 0: return &v.state case 1: @@ -3962,7 +4828,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OrderRulesRequest); i { + switch v := v.(*Rule); i { case 0: return &v.state case 1: @@ -3974,7 +4840,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Distribution); i { + switch v := v.(*RuleList); i { case 0: return &v.state case 1: @@ -3986,7 +4852,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateDistributionRequest); i { + switch v := v.(*ListRuleRequest); i { case 0: return &v.state case 1: @@ -3998,7 +4864,7 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateDistributionRequest); i { + switch v := v.(*GetRuleRequest); i { case 0: return &v.state case 1: @@ -4010,6 +4876,90 @@ func file_flipt_proto_init() { } } file_flipt_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrderRulesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Distribution); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateDistributionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateDistributionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_flipt_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteDistributionRequest); i { case 0: return &v.state @@ -4028,7 +4978,7 @@ func file_flipt_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_flipt_proto_rawDesc, NumEnums: 3, - NumMessages: 40, + NumMessages: 47, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/flipt/flipt.pb.gw.go b/rpc/flipt/flipt.pb.gw.go index 99dc5eb5ce..69792eec73 100644 --- a/rpc/flipt/flipt.pb.gw.go +++ b/rpc/flipt/flipt.pb.gw.go @@ -65,6 +65,74 @@ func local_request_Flipt_Evaluate_0(ctx context.Context, marshaler runtime.Marsh } +func request_Flipt_Evaluate_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EvaluationRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := client.Evaluate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_Evaluate_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EvaluationRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := server.Evaluate(ctx, &protoReq) + return msg, metadata, err + +} + func request_Flipt_BatchEvaluate_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq BatchEvaluationRequest var metadata runtime.ServerMetadata @@ -99,8 +167,76 @@ func local_request_Flipt_BatchEvaluate_0(ctx context.Context, marshaler runtime. } -func request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetFlagRequest +func request_Flipt_BatchEvaluate_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BatchEvaluationRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := client.BatchEvaluate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_BatchEvaluate_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BatchEvaluationRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := server.BatchEvaluate(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_GetNamespace_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetNamespaceRequest var metadata runtime.ServerMetadata var ( @@ -120,13 +256,13 @@ func request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marshaler, c return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.GetFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetNamespace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetFlagRequest +func local_request_Flipt_GetNamespace_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetNamespaceRequest var metadata runtime.ServerMetadata var ( @@ -146,49 +282,49 @@ func local_request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.GetFlag(ctx, &protoReq) + msg, err := server.GetNamespace(ctx, &protoReq) return msg, metadata, err } var ( - filter_Flipt_ListFlags_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Flipt_ListNamespaces_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Flipt_ListFlags_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListFlagRequest +func request_Flipt_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListNamespaceRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListNamespaces_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ListFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ListNamespaces(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_ListFlags_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListFlagRequest +func local_request_Flipt_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListNamespaceRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListNamespaces_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ListFlags(ctx, &protoReq) + msg, err := server.ListNamespaces(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateFlagRequest +func request_Flipt_CreateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateNamespaceRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -199,13 +335,13 @@ func request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.CreateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.CreateNamespace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateFlagRequest +func local_request_Flipt_CreateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateNamespaceRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -216,13 +352,13 @@ func local_request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.CreateFlag(ctx, &protoReq) + msg, err := server.CreateNamespace(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateFlagRequest +func request_Flipt_UpdateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateNamespaceRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -250,13 +386,13 @@ func request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.UpdateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.UpdateNamespace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateFlagRequest +func local_request_Flipt_UpdateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateNamespaceRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -284,13 +420,13 @@ func local_request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.UpdateFlag(ctx, &protoReq) + msg, err := server.UpdateNamespace(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteFlagRequest +func request_Flipt_DeleteNamespace_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteNamespaceRequest var metadata runtime.ServerMetadata var ( @@ -310,13 +446,13 @@ func request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.DeleteFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.DeleteNamespace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteFlagRequest +func local_request_Flipt_DeleteNamespace_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteNamespaceRequest var metadata runtime.ServerMetadata var ( @@ -336,22 +472,18 @@ func local_request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.DeleteFlag(ctx, &protoReq) + msg, err := server.DeleteNamespace(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateVariantRequest - var metadata runtime.ServerMetadata +var ( + filter_Flipt_GetFlag_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} +) - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } +func request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetFlagRequest + var metadata runtime.ServerMetadata var ( val string @@ -360,33 +492,32 @@ func request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.CreateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetFlag_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateVariantRequest +func local_request_Flipt_GetFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetFlagRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - var ( val string ok bool @@ -394,33 +525,32 @@ func local_request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime. _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.CreateVariant(ctx, &protoReq) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetFlag_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetFlag(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateVariantRequest +func request_Flipt_GetFlag_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetFlagRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - var ( val string ok bool @@ -428,43 +558,35 @@ func request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.UpdateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateVariantRequest +func local_request_Flipt_GetFlag_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetFlagRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - var ( val string ok bool @@ -472,105 +594,73 @@ func local_request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime. _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.UpdateVariant(ctx, &protoReq) + msg, err := server.GetFlag(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_DeleteVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteVariantRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["flag_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") - } +var ( + filter_Flipt_ListFlags_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) - protoReq.FlagKey, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) - } +func request_Flipt_ListFlags_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListFlagRequest + var metadata runtime.ServerMetadata - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.DeleteVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ListFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_DeleteVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteVariantRequest +func local_request_Flipt_ListFlags_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListFlagRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["flag_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") - } - - protoReq.FlagKey, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) - } - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.DeleteVariant(ctx, &protoReq) + msg, err := server.ListFlags(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetRuleRequest +var ( + filter_Flipt_ListFlags_1 = &utilities.DoubleArray{Encoding: map[string]int{"namespace_key": 0, "namespaceKey": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Flipt_ListFlags_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListFlagRequest var metadata runtime.ServerMetadata var ( @@ -580,33 +670,30 @@ func request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marshaler, c _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.GetRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ListFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetRuleRequest +func local_request_Flipt_ListFlags_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListFlagRequest var metadata runtime.ServerMetadata var ( @@ -616,72 +703,74 @@ func local_request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListFlags_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.GetRule(ctx, &protoReq) + msg, err := server.ListFlags(ctx, &protoReq) return msg, metadata, err } -var ( - filter_Flipt_ListRules_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} -) - -func request_Flipt_ListRules_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListRuleRequest +func request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateFlagRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["flag_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } - - protoReq.FlagKey, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + msg, err := client.CreateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateFlagRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ListRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := server.CreateFlag(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_ListRules_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListRuleRequest +func request_Flipt_CreateFlag_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateFlagRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -689,30 +778,23 @@ func local_request_Flipt_ListRules_0(ctx context.Context, marshaler runtime.Mars _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := server.ListRules(ctx, &protoReq) + msg, err := client.CreateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateRuleRequest +func local_request_Flipt_CreateFlag_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateFlagRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -730,23 +812,23 @@ func request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := client.CreateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := server.CreateFlag(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateRuleRequest +func request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateFlagRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -764,23 +846,23 @@ func local_request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.CreateRule(ctx, &protoReq) + msg, err := client.UpdateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateRuleRequest +func local_request_Flipt_UpdateFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateFlagRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -798,33 +880,23 @@ func request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["flag_key"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") - } - - protoReq.FlagKey, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) - } - - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.UpdateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := server.UpdateFlag(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateRuleRequest +func request_Flipt_UpdateFlag_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateFlagRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -842,33 +914,33 @@ func local_request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.UpdateRule(ctx, &protoReq) + msg, err := client.UpdateFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq OrderRulesRequest +func local_request_Flipt_UpdateFlag_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateFlagRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -886,33 +958,72 @@ func request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := client.OrderRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.UpdateFlag(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq OrderRulesRequest +var ( + filter_Flipt_DeleteFlag_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} +) + +func request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteFlagRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteFlag_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + msg, err := client.DeleteFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteFlag_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteFlagRequest + var metadata runtime.ServerMetadata + var ( val string ok bool @@ -920,23 +1031,30 @@ func local_request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.OrderRules(ctx, &protoReq) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteFlag_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteFlag(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteRuleRequest +func request_Flipt_DeleteFlag_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteFlagRequest var metadata runtime.ServerMetadata var ( @@ -946,33 +1064,33 @@ func request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := client.DeleteRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.DeleteFlag(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteRuleRequest +func local_request_Flipt_DeleteFlag_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteFlagRequest var metadata runtime.ServerMetadata var ( @@ -982,33 +1100,33 @@ func local_request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") } - protoReq.Id, err = runtime.String(val) + protoReq.Key, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) } - msg, err := server.DeleteRule(ctx, &protoReq) + msg, err := server.DeleteFlag(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_CreateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateDistributionRequest +func request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateVariantRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -1036,23 +1154,13 @@ func request_Flipt_CreateDistribution_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["rule_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") - } - - protoReq.RuleId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) - } - - msg, err := client.CreateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.CreateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_CreateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateDistributionRequest +func local_request_Flipt_CreateVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateVariantRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -1080,23 +1188,13 @@ func local_request_Flipt_CreateDistribution_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["rule_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") - } - - protoReq.RuleId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) - } - - msg, err := server.CreateDistribution(ctx, &protoReq) + msg, err := server.CreateVariant(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateDistributionRequest +func request_Flipt_CreateVariant_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateVariantRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -1114,6 +1212,16 @@ func request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.M _ = err ) + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + val, ok = pathParams["flag_key"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") @@ -1124,33 +1232,57 @@ func request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["rule_id"] + msg, err := client.CreateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateVariant_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateVariantRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.RuleId, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.Id, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - msg, err := client.UpdateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := server.CreateVariant(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateDistributionRequest +func request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateVariantRequest var metadata runtime.ServerMetadata newReader, berr := utilities.IOReaderFactory(req.Body) @@ -1178,16 +1310,6 @@ func local_request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["rule_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") - } - - protoReq.RuleId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) - } - val, ok = pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") @@ -1198,19 +1320,23 @@ func local_request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.UpdateDistribution(ctx, &protoReq) + msg, err := client.UpdateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -var ( - filter_Flipt_DeleteDistribution_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1, "rule_id": 2, "ruleId": 3, "id": 4}, Base: []int{1, 1, 2, 3, 4, 6, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6}} -) - -func request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteDistributionRequest +func local_request_Flipt_UpdateVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateVariantRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -1228,16 +1354,6 @@ func request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["rule_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") - } - - protoReq.RuleId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) - } - val, ok = pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") @@ -1248,22 +1364,23 @@ func request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.DeleteDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := server.UpdateVariant(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteDistributionRequest +func request_Flipt_UpdateVariant_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateVariantRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -1271,24 +1388,24 @@ func local_request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler run _ = err ) - val, ok = pathParams["flag_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.FlagKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["rule_id"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.RuleId, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } val, ok = pathParams["id"] @@ -1301,22 +1418,23 @@ func local_request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.DeleteDistribution(ctx, &protoReq) + msg, err := client.UpdateVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_GetSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetSegmentRequest +func local_request_Flipt_UpdateVariant_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateVariantRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -1324,129 +1442,135 @@ func request_Flipt_GetSegment_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.Key, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := client.GetSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Flipt_GetSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetSegmentRequest - var metadata runtime.ServerMetadata + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } - var ( - val string - ok bool - err error - _ = err - ) + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } - val, ok = pathParams["key"] + val, ok = pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - protoReq.Key, err = runtime.String(val) + protoReq.Id, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.GetSegment(ctx, &protoReq) + msg, err := server.UpdateVariant(ctx, &protoReq) return msg, metadata, err } var ( - filter_Flipt_ListSegments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Flipt_DeleteVariant_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1, "id": 2}, Base: []int{1, 1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4, 4}} ) -func request_Flipt_ListSegments_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListSegmentRequest +func request_Flipt_DeleteVariant_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteVariantRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - msg, err := client.ListSegments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } -} + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } -func local_request_Flipt_ListSegments_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ListSegmentRequest - var metadata runtime.ServerMetadata + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteVariant_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ListSegments(ctx, &protoReq) + msg, err := client.DeleteVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_CreateSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateSegmentRequest +func local_request_Flipt_DeleteVariant_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteVariantRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - msg, err := client.CreateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } -} + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } -func local_request_Flipt_CreateSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateSegmentRequest - var metadata runtime.ServerMetadata + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteVariant_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.CreateSegment(ctx, &protoReq) + msg, err := server.DeleteVariant(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_UpdateSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateSegmentRequest +func request_Flipt_DeleteVariant_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteVariantRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - var ( val string ok bool @@ -1454,57 +1578,43 @@ func request_Flipt_UpdateSegment_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.Key, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := client.UpdateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Flipt_UpdateSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateSegmentRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - var ( - val string - ok bool - err error - _ = err - ) + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } - val, ok = pathParams["key"] + val, ok = pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - protoReq.Key, err = runtime.String(val) + protoReq.Id, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.UpdateSegment(ctx, &protoReq) + msg, err := client.DeleteVariant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Flipt_DeleteSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteSegmentRequest +func local_request_Flipt_DeleteVariant_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteVariantRequest var metadata runtime.ServerMetadata var ( @@ -1514,58 +1624,48 @@ func request_Flipt_DeleteSegment_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.Key, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - msg, err := client.DeleteSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Flipt_DeleteSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteSegmentRequest - var metadata runtime.ServerMetadata + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } - var ( - val string - ok bool - err error - _ = err - ) + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } - val, ok = pathParams["key"] + val, ok = pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - protoReq.Key, err = runtime.String(val) + protoReq.Id, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.DeleteSegment(ctx, &protoReq) + msg, err := server.DeleteVariant(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateConstraintRequest - var metadata runtime.ServerMetadata +var ( + filter_Flipt_GetRule_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1, "id": 2}, Base: []int{1, 1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4, 4}} +) - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } +func request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRuleRequest + var metadata runtime.ServerMetadata var ( val string @@ -1574,33 +1674,42 @@ func request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - msg, err := client.CreateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } -func local_request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq CreateConstraintRequest - var metadata runtime.ServerMetadata + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetRule_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + msg, err := client.GetRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_GetRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRuleRequest + var metadata runtime.ServerMetadata + var ( val string ok bool @@ -1608,33 +1717,42 @@ func local_request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - msg, err := server.CreateConstraint(ctx, &protoReq) - return msg, metadata, err - -} + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } -func request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateConstraintRequest - var metadata runtime.ServerMetadata + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetRule_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + msg, err := server.GetRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_GetRule_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRuleRequest + var metadata runtime.ServerMetadata + var ( val string ok bool @@ -1642,14 +1760,24 @@ func request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } val, ok = pathParams["id"] @@ -1662,23 +1790,15 @@ func request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := client.UpdateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UpdateConstraintRequest +func local_request_Flipt_GetRule_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRuleRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - var ( val string ok bool @@ -1686,14 +1806,24 @@ func local_request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } val, ok = pathParams["id"] @@ -1706,13 +1836,17 @@ func local_request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.UpdateConstraint(ctx, &protoReq) + msg, err := server.GetRule(ctx, &protoReq) return msg, metadata, err } -func request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteConstraintRequest +var ( + filter_Flipt_ListRules_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Flipt_ListRules_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListRuleRequest var metadata runtime.ServerMetadata var ( @@ -1722,33 +1856,67 @@ func request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - val, ok = pathParams["id"] + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_ListRules_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListRuleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.Id, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - msg, err := client.DeleteConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListRules(ctx, &protoReq) return msg, metadata, err } -func local_request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq DeleteConstraintRequest +var ( + filter_Flipt_ListRules_1 = &utilities.DoubleArray{Encoding: map[string]int{"namespace_key": 0, "namespaceKey": 1, "flag_key": 2, "flagKey": 3}, Base: []int{1, 1, 2, 3, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 2, 3, 4, 5}} +) + +func request_Flipt_ListRules_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListRuleRequest var metadata runtime.ServerMetadata var ( @@ -1758,1300 +1926,5354 @@ func local_request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runti _ = err ) - val, ok = pathParams["segment_key"] + val, ok = pathParams["namespace_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") } - protoReq.SegmentKey, err = runtime.String(val) + protoReq.NamespaceKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) } - val, ok = pathParams["id"] + val, ok = pathParams["flag_key"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") } - protoReq.Id, err = runtime.String(val) + protoReq.FlagKey, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) } - msg, err := server.DeleteConstraint(ctx, &protoReq) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -// RegisterFliptHandlerServer registers the http handlers for service Flipt to "mux". -// UnaryRPC :call FliptServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFliptHandlerFromEndpoint instead. -func RegisterFliptHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FliptServer) error { +func local_request_Flipt_ListRules_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListRuleRequest + var metadata runtime.ServerMetadata - mux.Handle("POST", pattern_Flipt_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/evaluate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Flipt_Evaluate_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } + var ( + val string + ok bool + err error + _ = err + ) - forward_Flipt_Evaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } - }) + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } - mux.Handle("POST", pattern_Flipt_BatchEvaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/batch-evaluate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Flipt_BatchEvaluate_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListRules_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListRules(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := client.CreateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := server.CreateRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateRule_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := client.CreateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateRule_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := server.CreateRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateRule_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateRule_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateRuleRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq OrderRulesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := client.OrderRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_OrderRules_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq OrderRulesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := server.OrderRules(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_OrderRules_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq OrderRulesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := client.OrderRules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_OrderRules_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq OrderRulesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + msg, err := server.OrderRules(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_DeleteRule_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1, "id": 2}, Base: []int{1, 1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4, 4}} +) + +func request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteRuleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteRule_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteRule_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteRuleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteRule_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_DeleteRule_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteRuleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.DeleteRule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteRule_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteRuleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.DeleteRule(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + msg, err := client.CreateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + msg, err := server.CreateDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateDistribution_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + msg, err := client.CreateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateDistribution_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + msg, err := server.CreateDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateDistribution_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateDistribution_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateDistributionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_DeleteDistribution_0 = &utilities.DoubleArray{Encoding: map[string]int{"flag_key": 0, "flagKey": 1, "rule_id": 2, "ruleId": 3, "id": 4}, Base: []int{1, 1, 2, 3, 4, 6, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6}} +) + +func request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDistributionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteDistribution_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDistributionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_DeleteDistribution_1 = &utilities.DoubleArray{Encoding: map[string]int{"namespace_key": 0, "namespaceKey": 1, "flag_key": 2, "flagKey": 3, "rule_id": 4, "ruleId": 5, "id": 6}, Base: []int{1, 1, 2, 3, 4, 5, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 8}} +) + +func request_Flipt_DeleteDistribution_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDistributionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteDistribution(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteDistribution_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDistributionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["flag_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "flag_key") + } + + protoReq.FlagKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "flag_key", err) + } + + val, ok = pathParams["rule_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rule_id") + } + + protoReq.RuleId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rule_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteDistribution_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteDistribution(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_GetSegment_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} +) + +func request_Flipt_GetSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetSegment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_GetSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_GetSegment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_GetSegment_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := client.GetSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_GetSegment_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.GetSegment(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_ListSegments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Flipt_ListSegments_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSegmentRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListSegments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_ListSegments_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSegmentRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListSegments(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_ListSegments_1 = &utilities.DoubleArray{Encoding: map[string]int{"namespace_key": 0, "namespaceKey": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Flipt_ListSegments_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListSegments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_ListSegments_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_ListSegments_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListSegments(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreateSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateSegment_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := client.CreateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateSegment_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + msg, err := server.CreateSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := client.UpdateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.UpdateSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateSegment_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := client.UpdateSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateSegment_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateSegmentRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.UpdateSegment(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_DeleteSegment_0 = &utilities.DoubleArray{Encoding: map[string]int{"key": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} +) + +func request_Flipt_DeleteSegment_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteSegment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteSegment_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteSegment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_DeleteSegment_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := client.DeleteSegment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteSegment_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteSegmentRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.DeleteSegment(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + msg, err := client.CreateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + msg, err := server.CreateConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_CreateConstraint_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + msg, err := client.CreateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_CreateConstraint_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + msg, err := server.CreateConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_UpdateConstraint_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.UpdateConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_UpdateConstraint_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateConstraintRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.UpdateConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Flipt_DeleteConstraint_0 = &utilities.DoubleArray{Encoding: map[string]int{"segment_key": 0, "segmentKey": 1, "id": 2}, Base: []int{1, 1, 2, 4, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4, 4}} +) + +func request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteConstraintRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteConstraint_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteConstraint_0(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteConstraintRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Flipt_DeleteConstraint_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Flipt_DeleteConstraint_1(ctx context.Context, marshaler runtime.Marshaler, client FliptClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteConstraintRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.DeleteConstraint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Flipt_DeleteConstraint_1(ctx context.Context, marshaler runtime.Marshaler, server FliptServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteConstraintRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["namespace_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "namespace_key") + } + + protoReq.NamespaceKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "namespace_key", err) + } + + val, ok = pathParams["segment_key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "segment_key") + } + + protoReq.SegmentKey, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "segment_key", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.DeleteConstraint(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterFliptHandlerServer registers the http handlers for service Flipt to "mux". +// UnaryRPC :call FliptServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFliptHandlerFromEndpoint instead. +func RegisterFliptHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FliptServer) error { + + mux.Handle("POST", pattern_Flipt_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_Evaluate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_Evaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_Evaluate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_Evaluate_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_Evaluate_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_BatchEvaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/batch-evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_BatchEvaluate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_BatchEvaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_BatchEvaluate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/batch-evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_BatchEvaluate_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_BatchEvaluate_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetNamespace_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListNamespaces_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListNamespaces", runtime.WithHTTPPathPattern("/api/v1/namespaces")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListNamespaces_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListNamespaces_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateNamespace_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateNamespace_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteNamespace_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetFlag_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/flags")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListFlags_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListFlags_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListFlags_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListFlags_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListFlags_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/flags")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateFlag_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateFlag_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteFlag_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateVariant_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateVariant_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteVariant_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetRule_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListRules_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListRules_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListRules_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListRules_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateRule_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateRule_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_OrderRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/order")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_OrderRules_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_OrderRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_OrderRules_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/order")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_OrderRules_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_OrderRules_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteRule_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateDistribution_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateDistribution_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteDistribution_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_GetSegment_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_GetSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListSegments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/segments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListSegments_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListSegments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_ListSegments_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_ListSegments_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_ListSegments_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/segments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateSegment_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateSegment_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteSegment_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_CreateConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_CreateConstraint_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_CreateConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_Flipt_UpdateConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_UpdateConstraint_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_Flipt_DeleteConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Flipt_DeleteConstraint_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterFliptHandlerFromEndpoint is same as RegisterFliptHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterFliptHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterFliptHandler(ctx, mux, conn) +} + +// RegisterFliptHandler registers the http handlers for service Flipt to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterFliptHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterFliptHandlerClient(ctx, mux, NewFliptClient(conn)) +} + +// RegisterFliptHandlerClient registers the http handlers for service Flipt +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FliptClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FliptClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "FliptClient" to call the correct interceptors. +func RegisterFliptHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FliptClient) error { + + mux.Handle("POST", pattern_Flipt_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_Evaluate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_Evaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_Evaluate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_Evaluate_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_Evaluate_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_BatchEvaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/batch-evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_BatchEvaluate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_BatchEvaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Flipt_BatchEvaluate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/batch-evaluate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_BatchEvaluate_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_BatchEvaluate_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Flipt_GetNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_GetNamespace_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_BatchEvaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListNamespaces_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListNamespaces", runtime.WithHTTPPathPattern("/api/v1/namespaces")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_GetFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_ListNamespaces_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListNamespaces_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/flags")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_ListFlags_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateNamespace_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListFlags_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/flags")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_UpdateNamespace_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteNamespace", runtime.WithHTTPPathPattern("/api/v1/namespaces/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_DeleteNamespace_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteNamespace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteFlag_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_GetFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_GetFlag_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/flags")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_ListFlags_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListFlags_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListFlags_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteVariant_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_ListFlags_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListFlags_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/flags")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_GetRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_ListRules_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateFlag_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_UpdateFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_UpdateFlag_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_OrderRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/order")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_OrderRules_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_DeleteFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_OrderRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteFlag_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteRule_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_DeleteFlag_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteFlag_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateVariant_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteDistribution_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_UpdateVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_GetSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_UpdateVariant_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListSegments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/segments")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_ListSegments_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_DeleteVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListSegments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteVariant_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/segments")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_DeleteVariant_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteVariant_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_GetRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteSegment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_GetRule_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_CreateConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_ListRules_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListRules_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/UpdateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_UpdateConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_ListRules_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListRules_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/flipt.Flipt/DeleteConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Flipt_DeleteConstraint_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + resp, md, err := request_Flipt_CreateRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterFliptHandlerFromEndpoint is same as RegisterFliptHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterFliptHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterFliptHandler(ctx, mux, conn) -} - -// RegisterFliptHandler registers the http handlers for service Flipt to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterFliptHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterFliptHandlerClient(ctx, mux, NewFliptClient(conn)) -} + forward_Flipt_CreateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) -// RegisterFliptHandlerClient registers the http handlers for service Flipt -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FliptClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FliptClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "FliptClient" to call the correct interceptors. -func RegisterFliptHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FliptClient) error { + }) - mux.Handle("POST", pattern_Flipt_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/Evaluate", runtime.WithHTTPPathPattern("/api/v1/evaluate")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_Evaluate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateRule_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_Evaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_BatchEvaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/BatchEvaluate", runtime.WithHTTPPathPattern("/api/v1/batch-evaluate")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_BatchEvaluate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_BatchEvaluate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_GetFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateRule_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_OrderRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListFlags", runtime.WithHTTPPathPattern("/api/v1/flags")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/order")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_ListFlags_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_OrderRules_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListFlags_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_OrderRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_OrderRules_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateFlag", runtime.WithHTTPPathPattern("/api/v1/flags")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/order")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_OrderRules_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_OrderRules_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_UpdateFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteFlag_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteRule_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteFlag", runtime.WithHTTPPathPattern("/api/v1/flags/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_DeleteFlag_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteRule_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteFlag_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteRule_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_UpdateVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateDistribution_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteVariant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteVariant", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/variants/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_DeleteVariant_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteVariant_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_GetRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateDistribution_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_ListRules_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteDistribution_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteDistribution_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_UpdateRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_GetSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_OrderRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_GetSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/OrderRules", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/order")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_OrderRules_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_GetSegment_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_OrderRules_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_GetSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteRule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListSegments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteRule", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/segments")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_DeleteRule_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_ListSegments_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteRule_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListSegments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Flipt_ListSegments_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_ListSegments_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_ListSegments_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/segments")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_UpdateDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteDistribution_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteDistribution", runtime.WithHTTPPathPattern("/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_DeleteDistribution_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateSegment_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteDistribution_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_GetSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/GetSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_GetSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_GetSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Flipt_ListSegments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_Flipt_UpdateSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/ListSegments", runtime.WithHTTPPathPattern("/api/v1/segments")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_ListSegments_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_UpdateSegment_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_ListSegments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_UpdateSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateSegment", runtime.WithHTTPPathPattern("/api/v1/segments")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("PUT", pattern_Flipt_UpdateSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("DELETE", pattern_Flipt_DeleteSegment_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{key}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_UpdateSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_DeleteSegment_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_UpdateSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_DeleteSegment_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("DELETE", pattern_Flipt_DeleteSegment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteSegment", runtime.WithHTTPPathPattern("/api/v1/segments/{key}")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_DeleteSegment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateConstraint_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_DeleteSegment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("POST", pattern_Flipt_CreateConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_Flipt_CreateConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/segments/{segment_key}/constraints")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/CreateConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Flipt_CreateConstraint_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Flipt_CreateConstraint_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Flipt_CreateConstraint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Flipt_CreateConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -3077,6 +7299,28 @@ func RegisterFliptHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("PUT", pattern_Flipt_UpdateConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/UpdateConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_UpdateConstraint_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_UpdateConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("DELETE", pattern_Flipt_DeleteConstraint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -3099,117 +7343,267 @@ func RegisterFliptHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("DELETE", pattern_Flipt_DeleteConstraint_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/flipt.Flipt/DeleteConstraint", runtime.WithHTTPPathPattern("/api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Flipt_DeleteConstraint_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Flipt_DeleteConstraint_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Flipt_Evaluate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "evaluate"}, "")) + pattern_Flipt_Evaluate_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "evaluate"}, "")) + pattern_Flipt_BatchEvaluate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "batch-evaluate"}, "")) + pattern_Flipt_BatchEvaluate_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "batch-evaluate"}, "")) + + pattern_Flipt_GetNamespace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "namespaces", "key"}, "")) + + pattern_Flipt_ListNamespaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "namespaces"}, "")) + + pattern_Flipt_CreateNamespace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "namespaces"}, "")) + + pattern_Flipt_UpdateNamespace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "namespaces", "key"}, "")) + + pattern_Flipt_DeleteNamespace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "namespaces", "key"}, "")) + pattern_Flipt_GetFlag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "flags", "key"}, "")) + pattern_Flipt_GetFlag_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "key"}, "")) + pattern_Flipt_ListFlags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "flags"}, "")) + pattern_Flipt_ListFlags_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "flags"}, "")) + pattern_Flipt_CreateFlag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "flags"}, "")) + pattern_Flipt_CreateFlag_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "flags"}, "")) + pattern_Flipt_UpdateFlag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "flags", "key"}, "")) + pattern_Flipt_UpdateFlag_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "key"}, "")) + pattern_Flipt_DeleteFlag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "flags", "key"}, "")) + pattern_Flipt_DeleteFlag_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "key"}, "")) + pattern_Flipt_CreateVariant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "flags", "flag_key", "variants"}, "")) + pattern_Flipt_CreateVariant_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "variants"}, "")) + pattern_Flipt_UpdateVariant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "flags", "flag_key", "variants", "id"}, "")) + pattern_Flipt_UpdateVariant_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "variants", "id"}, "")) + pattern_Flipt_DeleteVariant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "flags", "flag_key", "variants", "id"}, "")) + pattern_Flipt_DeleteVariant_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "variants", "id"}, "")) + pattern_Flipt_GetRule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_GetRule_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_ListRules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "flags", "flag_key", "rules"}, "")) + pattern_Flipt_ListRules_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules"}, "")) + pattern_Flipt_CreateRule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "flags", "flag_key", "rules"}, "")) + pattern_Flipt_CreateRule_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules"}, "")) + pattern_Flipt_UpdateRule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_UpdateRule_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_OrderRules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"api", "v1", "flags", "flag_key", "rules", "order"}, "")) + pattern_Flipt_OrderRules_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 2, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "order"}, "")) + pattern_Flipt_DeleteRule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_DeleteRule_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "id"}, "")) + pattern_Flipt_CreateDistribution_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "flags", "flag_key", "rules", "rule_id", "distributions"}, "")) + pattern_Flipt_CreateDistribution_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "rule_id", "distributions"}, "")) + pattern_Flipt_UpdateDistribution_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "flags", "flag_key", "rules", "rule_id", "distributions", "id"}, "")) + pattern_Flipt_UpdateDistribution_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "rule_id", "distributions", "id"}, "")) + pattern_Flipt_DeleteDistribution_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "flags", "flag_key", "rules", "rule_id", "distributions", "id"}, "")) + pattern_Flipt_DeleteDistribution_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"api", "v1", "namespaces", "namespace_key", "flags", "flag_key", "rules", "rule_id", "distributions", "id"}, "")) + pattern_Flipt_GetSegment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "segments", "key"}, "")) + pattern_Flipt_GetSegment_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "key"}, "")) + pattern_Flipt_ListSegments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "segments"}, "")) + pattern_Flipt_ListSegments_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "segments"}, "")) + pattern_Flipt_CreateSegment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "segments"}, "")) + pattern_Flipt_CreateSegment_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "namespaces", "namespace_key", "segments"}, "")) + pattern_Flipt_UpdateSegment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "segments", "key"}, "")) + pattern_Flipt_UpdateSegment_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "key"}, "")) + pattern_Flipt_DeleteSegment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "segments", "key"}, "")) + pattern_Flipt_DeleteSegment_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "key"}, "")) + pattern_Flipt_CreateConstraint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "segments", "segment_key", "constraints"}, "")) + pattern_Flipt_CreateConstraint_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "segment_key", "constraints"}, "")) + pattern_Flipt_UpdateConstraint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "segments", "segment_key", "constraints", "id"}, "")) + pattern_Flipt_UpdateConstraint_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "segment_key", "constraints", "id"}, "")) + pattern_Flipt_DeleteConstraint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"api", "v1", "segments", "segment_key", "constraints", "id"}, "")) + + pattern_Flipt_DeleteConstraint_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v1", "namespaces", "namespace_key", "segments", "segment_key", "constraints", "id"}, "")) ) var ( forward_Flipt_Evaluate_0 = runtime.ForwardResponseMessage + forward_Flipt_Evaluate_1 = runtime.ForwardResponseMessage + forward_Flipt_BatchEvaluate_0 = runtime.ForwardResponseMessage + forward_Flipt_BatchEvaluate_1 = runtime.ForwardResponseMessage + + forward_Flipt_GetNamespace_0 = runtime.ForwardResponseMessage + + forward_Flipt_ListNamespaces_0 = runtime.ForwardResponseMessage + + forward_Flipt_CreateNamespace_0 = runtime.ForwardResponseMessage + + forward_Flipt_UpdateNamespace_0 = runtime.ForwardResponseMessage + + forward_Flipt_DeleteNamespace_0 = runtime.ForwardResponseMessage + forward_Flipt_GetFlag_0 = runtime.ForwardResponseMessage + forward_Flipt_GetFlag_1 = runtime.ForwardResponseMessage + forward_Flipt_ListFlags_0 = runtime.ForwardResponseMessage + forward_Flipt_ListFlags_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateFlag_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateFlag_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateFlag_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateFlag_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteFlag_0 = runtime.ForwardResponseMessage + forward_Flipt_DeleteFlag_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateVariant_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateVariant_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateVariant_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateVariant_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteVariant_0 = runtime.ForwardResponseMessage + forward_Flipt_DeleteVariant_1 = runtime.ForwardResponseMessage + forward_Flipt_GetRule_0 = runtime.ForwardResponseMessage + forward_Flipt_GetRule_1 = runtime.ForwardResponseMessage + forward_Flipt_ListRules_0 = runtime.ForwardResponseMessage + forward_Flipt_ListRules_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateRule_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateRule_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateRule_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateRule_1 = runtime.ForwardResponseMessage + forward_Flipt_OrderRules_0 = runtime.ForwardResponseMessage + forward_Flipt_OrderRules_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteRule_0 = runtime.ForwardResponseMessage + forward_Flipt_DeleteRule_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateDistribution_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateDistribution_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateDistribution_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateDistribution_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteDistribution_0 = runtime.ForwardResponseMessage + forward_Flipt_DeleteDistribution_1 = runtime.ForwardResponseMessage + forward_Flipt_GetSegment_0 = runtime.ForwardResponseMessage + forward_Flipt_GetSegment_1 = runtime.ForwardResponseMessage + forward_Flipt_ListSegments_0 = runtime.ForwardResponseMessage + forward_Flipt_ListSegments_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateSegment_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateSegment_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateSegment_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateSegment_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteSegment_0 = runtime.ForwardResponseMessage + forward_Flipt_DeleteSegment_1 = runtime.ForwardResponseMessage + forward_Flipt_CreateConstraint_0 = runtime.ForwardResponseMessage + forward_Flipt_CreateConstraint_1 = runtime.ForwardResponseMessage + forward_Flipt_UpdateConstraint_0 = runtime.ForwardResponseMessage + forward_Flipt_UpdateConstraint_1 = runtime.ForwardResponseMessage + forward_Flipt_DeleteConstraint_0 = runtime.ForwardResponseMessage + + forward_Flipt_DeleteConstraint_1 = runtime.ForwardResponseMessage ) diff --git a/rpc/flipt/flipt.proto b/rpc/flipt/flipt.proto index 0c9a76e1bb..8b57b179ca 100644 --- a/rpc/flipt/flipt.proto +++ b/rpc/flipt/flipt.proto @@ -12,12 +12,14 @@ message EvaluationRequest { string flag_key = 2; string entity_id = 3; map context = 4; + string namespace_key = 5; } message BatchEvaluationRequest { string request_id = 1; repeated EvaluationRequest requests = 2; bool exclude_not_found = 3; + string namespace_key = 4; } message EvaluationResponse { @@ -32,6 +34,7 @@ message EvaluationResponse { double request_duration_millis = 9; string attachment = 10; EvaluationReason reason = 11; + string namespace_key = 12; } enum EvaluationReason { @@ -48,6 +51,47 @@ message BatchEvaluationResponse { double request_duration_millis = 3; } +message Namespace { + string key = 1; + string name = 2; + string description = 3; + bool protected = 4; + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp updated_at = 6; +} + +message NamespaceList { + repeated Namespace namespaces = 1; + string next_page_token = 2; + int32 total_count = 3; +} + +message GetNamespaceRequest { + string key = 1; +} + +message ListNamespaceRequest { + int32 limit = 1; + int32 offset = 2 [deprecated = true]; + string page_token = 3; +} + +message CreateNamespaceRequest { + string key = 1; + string name = 2; + string description = 3; +} + +message UpdateNamespaceRequest { + string key = 1; + string name = 2; + string description = 3; +} + +message DeleteNamespaceRequest { + string key = 1; +} + message Flag { string key = 1; string name = 2; @@ -56,6 +100,7 @@ message Flag { google.protobuf.Timestamp created_at = 5; google.protobuf.Timestamp updated_at = 6; repeated Variant variants = 7; + string namespace_key = 8; } message FlagList { @@ -66,12 +111,14 @@ message FlagList { message GetFlagRequest { string key = 1; + string namespace_key = 2; } message ListFlagRequest { int32 limit = 1; int32 offset = 2 [deprecated = true]; string page_token = 3; + string namespace_key = 4; } message CreateFlagRequest { @@ -79,6 +126,7 @@ message CreateFlagRequest { string name = 2; string description = 3; bool enabled = 4; + string namespace_key = 5; } message UpdateFlagRequest { @@ -86,10 +134,12 @@ message UpdateFlagRequest { string name = 2; string description = 3; bool enabled = 4; + string namespace_key = 5; } message DeleteFlagRequest { string key = 1; + string namespace_key = 2; } message Variant { @@ -101,6 +151,7 @@ message Variant { google.protobuf.Timestamp created_at = 6; google.protobuf.Timestamp updated_at = 7; string attachment = 8; + string namespace_key = 9; } message CreateVariantRequest { @@ -109,6 +160,7 @@ message CreateVariantRequest { string name = 3; string description = 4; string attachment = 5; + string namespace_key = 6; } message UpdateVariantRequest { @@ -118,11 +170,13 @@ message UpdateVariantRequest { string name = 4; string description = 5; string attachment = 6; + string namespace_key = 7; } message DeleteVariantRequest { string id = 1; string flag_key = 2; + string namespace_key = 3; } enum MatchType { @@ -138,6 +192,7 @@ message Segment { google.protobuf.Timestamp updated_at = 5; repeated Constraint constraints = 6; MatchType match_type = 7; + string namespace_key = 8; } message SegmentList { @@ -148,12 +203,14 @@ message SegmentList { message GetSegmentRequest { string key = 1; + string namespace_key = 2; } message ListSegmentRequest { int32 limit = 1; int32 offset = 2 [deprecated = true]; string page_token = 3; + string namespace_key = 4; } message CreateSegmentRequest { @@ -161,6 +218,7 @@ message CreateSegmentRequest { string name = 2; string description = 3; MatchType match_type = 4; + string namespace_key = 5; } message UpdateSegmentRequest { @@ -168,10 +226,12 @@ message UpdateSegmentRequest { string name = 2; string description = 3; MatchType match_type = 4; + string namespace_key = 5; } message DeleteSegmentRequest { string key = 1; + string namespace_key = 2; } enum ComparisonType { @@ -190,6 +250,7 @@ message Constraint { string value = 6; google.protobuf.Timestamp created_at = 7; google.protobuf.Timestamp updated_at = 8; + string namespace_key = 9; } message CreateConstraintRequest { @@ -198,6 +259,7 @@ message CreateConstraintRequest { string property = 3; string operator = 4; string value = 5; + string namespace_key = 6; } message UpdateConstraintRequest { @@ -207,11 +269,13 @@ message UpdateConstraintRequest { string property = 4; string operator = 5; string value = 6; + string namespace_key = 7; } message DeleteConstraintRequest { string id = 1; string segment_key = 2; + string namespace_key = 3; } message Rule { @@ -222,6 +286,7 @@ message Rule { int32 rank = 5; google.protobuf.Timestamp created_at = 6; google.protobuf.Timestamp updated_at = 7; + string namespace_key = 8; } message RuleList { @@ -235,33 +300,39 @@ message ListRuleRequest { int32 offset = 2 [deprecated = true]; string flag_key = 3; string page_token = 4; + string namespace_key = 5; } message GetRuleRequest { string id = 1; string flag_key = 2; + string namespace_key = 3; } message CreateRuleRequest { string flag_key = 1; string segment_key = 2; int32 rank = 3; + string namespace_key = 4; } message UpdateRuleRequest { string id = 1; string flag_key = 2; string segment_key = 3; + string namespace_key = 4; } message DeleteRuleRequest { string id = 1; string flag_key = 2; + string namespace_key = 3; } message OrderRulesRequest { string flag_key = 1; repeated string rule_ids = 2; + string namespace_key = 3; } message Distribution { @@ -278,6 +349,7 @@ message CreateDistributionRequest { string rule_id = 2; string variant_id = 3; float rollout = 4; + string namespace_key = 5; } message UpdateDistributionRequest { @@ -286,6 +358,7 @@ message UpdateDistributionRequest { string rule_id = 3; string variant_id = 4; float rollout = 5; + string namespace_key = 6; } message DeleteDistributionRequest { @@ -293,11 +366,17 @@ message DeleteDistributionRequest { string flag_key = 2; string rule_id = 3; string variant_id = 4; + string namespace_key = 5; } service Flipt { rpc Evaluate(EvaluationRequest) returns (EvaluationResponse) {} rpc BatchEvaluate(BatchEvaluationRequest) returns (BatchEvaluationResponse) {} + rpc GetNamespace(GetNamespaceRequest) returns (Namespace) { } + rpc ListNamespaces(ListNamespaceRequest) returns (NamespaceList) {} + rpc CreateNamespace(CreateNamespaceRequest) returns (Namespace) {} + rpc UpdateNamespace(UpdateNamespaceRequest) returns (Namespace) {} + rpc DeleteNamespace(DeleteNamespaceRequest) returns (google.protobuf.Empty) {} rpc GetFlag(GetFlagRequest) returns (Flag) {} rpc ListFlags(ListFlagRequest) returns (FlagList) {} rpc CreateFlag(CreateFlagRequest) returns (Flag) {} diff --git a/rpc/flipt/flipt.yaml b/rpc/flipt/flipt.yaml index dfe54436b9..b39478e853 100644 --- a/rpc/flipt/flipt.yaml +++ b/rpc/flipt/flipt.yaml @@ -4,84 +4,245 @@ config_version: 3 http: rules: + # namespaces + # + - selector: flipt.Flipt.GetNamespace + get: /api/v1/namespaces/{key} + + - selector: flipt.Flipt.ListNamespaces + get: /api/v1/namespaces + + - selector: flipt.Flipt.CreateNamespace + post: /api/v1/namespaces + body: "*" + + - selector: flipt.Flipt.UpdateNamespace + put: /api/v1/namespaces/{key} + body: "*" + + - selector: flipt.Flipt.DeleteNamespace + delete: /api/v1/namespaces/{key} + + # evaluation + # - selector: flipt.Flipt.Evaluate post: /api/v1/evaluate body: "*" + + - selector: flipt.Flipt.Evaluate + post: /api/v1/namespaces/{namespace_key}/evaluate + body: "*" + - selector: flipt.Flipt.BatchEvaluate post: /api/v1/batch-evaluate body: "*" + + - selector: flipt.Flipt.BatchEvaluate + post: /api/v1/namespaces/{namespace_key}/batch-evaluate + body: "*" + + # flags + # - selector: flipt.Flipt.GetFlag get: /api/v1/flags/{key} + + - selector: flipt.Flipt.GetFlag + get: /api/v1/namespaces/{namespace_key}/flags/{key} + - selector: flipt.Flipt.ListFlags get: /api/v1/flags + + - selector: flipt.Flipt.ListFlags + get: /api/v1/namespaces/{namespace_key}/flags + - selector: flipt.Flipt.CreateFlag post: /api/v1/flags body: "*" + + - selector: flipt.Flipt.CreateFlag + post: /api/v1/namespaces/{namespace_key}/flags + body: "*" + - selector: flipt.Flipt.UpdateFlag put: /api/v1/flags/{key} body: "*" + + - selector: flipt.Flipt.UpdateFlag + put: /api/v1/namespaces/{namespace_key}/flags/{key} + body: "*" + - selector: flipt.Flipt.DeleteFlag delete: /api/v1/flags/{key} + + - selector: flipt.Flipt.DeleteFlag + delete: /api/v1/namespaces/{namespace_key}/flags/{key} + + # variants + # - selector: flipt.Flipt.CreateVariant post: /api/v1/flags/{flag_key}/variants body: "*" + + - selector: flipt.Flipt.CreateVariant + post: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants + body: "*" + - selector: flipt.Flipt.UpdateVariant put: /api/v1/flags/{flag_key}/variants/{id} body: "*" + + - selector: flipt.Flipt.UpdateVariant + put: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id} + body: "*" + - selector: flipt.Flipt.DeleteVariant delete: /api/v1/flags/{flag_key}/variants/{id} + + - selector: flipt.Flipt.DeleteVariant + delete: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/variants/{id} + + # rules + # - selector: flipt.Flipt.GetRule get: /api/v1/flags/{flag_key}/rules/{id} + + - selector: flipt.Flipt.GetRule + get: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id} + - selector: flipt.Flipt.ListRules get: /api/v1/flags/{flag_key}/rules + + - selector: flipt.Flipt.ListRules + get: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules + - selector: flipt.Flipt.CreateRule post: /api/v1/flags/{flag_key}/rules body: "*" + + - selector: flipt.Flipt.CreateRule + post: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules + body: "*" + - selector: flipt.Flipt.UpdateRule put: /api/v1/flags/{flag_key}/rules/{id} body: "*" + + - selector: flipt.Flipt.UpdateRule + put: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id} + body: "*" + - selector: flipt.Flipt.OrderRules put: /api/v1/flags/{flag_key}/rules/order body: "*" + + - selector: flipt.Flipt.OrderRules + put: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/order + body: "*" + - selector: flipt.Flipt.DeleteRule delete: /api/v1/flags/{flag_key}/rules/{id} + + - selector: flipt.Flipt.DeleteRule + delete: /api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{id} + + # distributions + # - selector: flipt.Flipt.CreateDistribution post: "/api/v1/flags/{flag_key}/rules/{rule_id}/distributions" body: "*" + + - selector: flipt.Flipt.CreateDistribution + post: "/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions" + body: "*" + - selector: flipt.Flipt.UpdateDistribution put: "/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}" body: "*" + + - selector: flipt.Flipt.UpdateDistribution + put: "/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}" + body: "*" + - selector: flipt.Flipt.DeleteDistribution delete: "/api/v1/flags/{flag_key}/rules/{rule_id}/distributions/{id}" + + - selector: flipt.Flipt.DeleteDistribution + delete: "/api/v1/namespaces/{namespace_key}/flags/{flag_key}/rules/{rule_id}/distributions/{id}" + + # segments + # - selector: flipt.Flipt.GetSegment get: /api/v1/segments/{key} + + - selector: flipt.Flipt.GetSegment + get: /api/v1/namespaces/{namespace_key}/segments/{key} + - selector: flipt.Flipt.ListSegments get: /api/v1/segments + + - selector: flipt.Flipt.ListSegments + get: /api/v1/namespaces/{namespace_key}/segments + - selector: flipt.Flipt.CreateSegment post: /api/v1/segments body: "*" + + - selector: flipt.Flipt.CreateSegment + post: /api/v1/namespaces/{namespace_key}/segments + body: "*" + - selector: flipt.Flipt.UpdateSegment put: /api/v1/segments/{key} body: "*" + + - selector: flipt.Flipt.UpdateSegment + put: /api/v1/namespaces/{namespace_key}/segments/{key} + body: "*" + - selector: flipt.Flipt.DeleteSegment delete: /api/v1/segments/{key} + + - selector: flipt.Flipt.DeleteSegment + delete: /api/v1/namespaces/{namespace_key}/segments/{key} + + # constraints + # - selector: flipt.Flipt.CreateConstraint post: /api/v1/segments/{segment_key}/constraints body: "*" + + - selector: flipt.Flipt.CreateConstraint + post: /api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints + body: "*" + - selector: flipt.Flipt.UpdateConstraint put: /api/v1/segments/{segment_key}/constraints/{id} body: "*" + + - selector: flipt.Flipt.UpdateConstraint + put: /api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id} + body: "*" + - selector: flipt.Flipt.DeleteConstraint delete: /api/v1/segments/{segment_key}/constraints/{id} + + - selector: flipt.Flipt.DeleteConstraint + delete: /api/v1/namespaces/{namespace_key}/segments/{segment_key}/constraints/{id} + # metadata + # - selector: flipt.meta.MetadataService.GetConfiguration get: /meta/config - selector: flipt.meta.MetadataService.GetInfo get: /meta/info + # authentication public routes + # - selector: flipt.auth.PublicAuthenticationService.ListAuthenticationMethods get: /auth/v1/method + # authentication + # - selector: flipt.auth.AuthenticationService.GetAuthenticationSelf get: /auth/v1/self - selector: flipt.auth.AuthenticationService.ExpireAuthenticationSelf @@ -92,6 +253,7 @@ http: get: /auth/v1/tokens - selector: flipt.auth.AuthenticationService.DeleteAuthentication delete: /auth/v1/tokens/{id} + # authentication methods # # method: token diff --git a/rpc/flipt/flipt_grpc.pb.go b/rpc/flipt/flipt_grpc.pb.go index e770c35eb8..a67f188da4 100644 --- a/rpc/flipt/flipt_grpc.pb.go +++ b/rpc/flipt/flipt_grpc.pb.go @@ -22,6 +22,11 @@ const _ = grpc.SupportPackageIsVersion7 const ( Flipt_Evaluate_FullMethodName = "/flipt.Flipt/Evaluate" Flipt_BatchEvaluate_FullMethodName = "/flipt.Flipt/BatchEvaluate" + Flipt_GetNamespace_FullMethodName = "/flipt.Flipt/GetNamespace" + Flipt_ListNamespaces_FullMethodName = "/flipt.Flipt/ListNamespaces" + Flipt_CreateNamespace_FullMethodName = "/flipt.Flipt/CreateNamespace" + Flipt_UpdateNamespace_FullMethodName = "/flipt.Flipt/UpdateNamespace" + Flipt_DeleteNamespace_FullMethodName = "/flipt.Flipt/DeleteNamespace" Flipt_GetFlag_FullMethodName = "/flipt.Flipt/GetFlag" Flipt_ListFlags_FullMethodName = "/flipt.Flipt/ListFlags" Flipt_CreateFlag_FullMethodName = "/flipt.Flipt/CreateFlag" @@ -55,6 +60,11 @@ const ( type FliptClient interface { Evaluate(ctx context.Context, in *EvaluationRequest, opts ...grpc.CallOption) (*EvaluationResponse, error) BatchEvaluate(ctx context.Context, in *BatchEvaluationRequest, opts ...grpc.CallOption) (*BatchEvaluationResponse, error) + GetNamespace(ctx context.Context, in *GetNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) + ListNamespaces(ctx context.Context, in *ListNamespaceRequest, opts ...grpc.CallOption) (*NamespaceList, error) + CreateNamespace(ctx context.Context, in *CreateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) + UpdateNamespace(ctx context.Context, in *UpdateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) + DeleteNamespace(ctx context.Context, in *DeleteNamespaceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetFlag(ctx context.Context, in *GetFlagRequest, opts ...grpc.CallOption) (*Flag, error) ListFlags(ctx context.Context, in *ListFlagRequest, opts ...grpc.CallOption) (*FlagList, error) CreateFlag(ctx context.Context, in *CreateFlagRequest, opts ...grpc.CallOption) (*Flag, error) @@ -108,6 +118,51 @@ func (c *fliptClient) BatchEvaluate(ctx context.Context, in *BatchEvaluationRequ return out, nil } +func (c *fliptClient) GetNamespace(ctx context.Context, in *GetNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) { + out := new(Namespace) + err := c.cc.Invoke(ctx, Flipt_GetNamespace_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fliptClient) ListNamespaces(ctx context.Context, in *ListNamespaceRequest, opts ...grpc.CallOption) (*NamespaceList, error) { + out := new(NamespaceList) + err := c.cc.Invoke(ctx, Flipt_ListNamespaces_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fliptClient) CreateNamespace(ctx context.Context, in *CreateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) { + out := new(Namespace) + err := c.cc.Invoke(ctx, Flipt_CreateNamespace_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fliptClient) UpdateNamespace(ctx context.Context, in *UpdateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) { + out := new(Namespace) + err := c.cc.Invoke(ctx, Flipt_UpdateNamespace_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fliptClient) DeleteNamespace(ctx context.Context, in *DeleteNamespaceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Flipt_DeleteNamespace_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *fliptClient) GetFlag(ctx context.Context, in *GetFlagRequest, opts ...grpc.CallOption) (*Flag, error) { out := new(Flag) err := c.cc.Invoke(ctx, Flipt_GetFlag_FullMethodName, in, out, opts...) @@ -339,6 +394,11 @@ func (c *fliptClient) DeleteConstraint(ctx context.Context, in *DeleteConstraint type FliptServer interface { Evaluate(context.Context, *EvaluationRequest) (*EvaluationResponse, error) BatchEvaluate(context.Context, *BatchEvaluationRequest) (*BatchEvaluationResponse, error) + GetNamespace(context.Context, *GetNamespaceRequest) (*Namespace, error) + ListNamespaces(context.Context, *ListNamespaceRequest) (*NamespaceList, error) + CreateNamespace(context.Context, *CreateNamespaceRequest) (*Namespace, error) + UpdateNamespace(context.Context, *UpdateNamespaceRequest) (*Namespace, error) + DeleteNamespace(context.Context, *DeleteNamespaceRequest) (*emptypb.Empty, error) GetFlag(context.Context, *GetFlagRequest) (*Flag, error) ListFlags(context.Context, *ListFlagRequest) (*FlagList, error) CreateFlag(context.Context, *CreateFlagRequest) (*Flag, error) @@ -377,6 +437,21 @@ func (UnimplementedFliptServer) Evaluate(context.Context, *EvaluationRequest) (* func (UnimplementedFliptServer) BatchEvaluate(context.Context, *BatchEvaluationRequest) (*BatchEvaluationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BatchEvaluate not implemented") } +func (UnimplementedFliptServer) GetNamespace(context.Context, *GetNamespaceRequest) (*Namespace, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNamespace not implemented") +} +func (UnimplementedFliptServer) ListNamespaces(context.Context, *ListNamespaceRequest) (*NamespaceList, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListNamespaces not implemented") +} +func (UnimplementedFliptServer) CreateNamespace(context.Context, *CreateNamespaceRequest) (*Namespace, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateNamespace not implemented") +} +func (UnimplementedFliptServer) UpdateNamespace(context.Context, *UpdateNamespaceRequest) (*Namespace, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateNamespace not implemented") +} +func (UnimplementedFliptServer) DeleteNamespace(context.Context, *DeleteNamespaceRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteNamespace not implemented") +} func (UnimplementedFliptServer) GetFlag(context.Context, *GetFlagRequest) (*Flag, error) { return nil, status.Errorf(codes.Unimplemented, "method GetFlag not implemented") } @@ -501,6 +576,96 @@ func _Flipt_BatchEvaluate_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Flipt_GetNamespace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetNamespaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FliptServer).GetNamespace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Flipt_GetNamespace_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FliptServer).GetNamespace(ctx, req.(*GetNamespaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Flipt_ListNamespaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListNamespaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FliptServer).ListNamespaces(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Flipt_ListNamespaces_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FliptServer).ListNamespaces(ctx, req.(*ListNamespaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Flipt_CreateNamespace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateNamespaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FliptServer).CreateNamespace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Flipt_CreateNamespace_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FliptServer).CreateNamespace(ctx, req.(*CreateNamespaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Flipt_UpdateNamespace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateNamespaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FliptServer).UpdateNamespace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Flipt_UpdateNamespace_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FliptServer).UpdateNamespace(ctx, req.(*UpdateNamespaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Flipt_DeleteNamespace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteNamespaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FliptServer).DeleteNamespace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Flipt_DeleteNamespace_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FliptServer).DeleteNamespace(ctx, req.(*DeleteNamespaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Flipt_GetFlag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetFlagRequest) if err := dec(in); err != nil { @@ -966,6 +1131,26 @@ var Flipt_ServiceDesc = grpc.ServiceDesc{ MethodName: "BatchEvaluate", Handler: _Flipt_BatchEvaluate_Handler, }, + { + MethodName: "GetNamespace", + Handler: _Flipt_GetNamespace_Handler, + }, + { + MethodName: "ListNamespaces", + Handler: _Flipt_ListNamespaces_Handler, + }, + { + MethodName: "CreateNamespace", + Handler: _Flipt_CreateNamespace_Handler, + }, + { + MethodName: "UpdateNamespace", + Handler: _Flipt_UpdateNamespace_Handler, + }, + { + MethodName: "DeleteNamespace", + Handler: _Flipt_DeleteNamespace_Handler, + }, { MethodName: "GetFlag", Handler: _Flipt_GetFlag_Handler, diff --git a/rpc/flipt/validation.go b/rpc/flipt/validation.go index 595ca6141b..1f720806ee 100644 --- a/rpc/flipt/validation.go +++ b/rpc/flipt/validation.go @@ -459,3 +459,32 @@ func (req *DeleteConstraintRequest) Validate() error { return nil } + +// Namespaces +func (req *CreateNamespaceRequest) Validate() error { + if req.Key == "" { + return errors.EmptyFieldError("key") + } + + if !keyRegex.MatchString(req.Key) { + return errors.InvalidFieldError("key", "contains invalid characters") + } + + if req.Name == "" { + return errors.EmptyFieldError("name") + } + + return nil +} + +func (req *UpdateNamespaceRequest) Validate() error { + if req.Key == "" { + return errors.EmptyFieldError("key") + } + + if req.Name == "" { + return errors.EmptyFieldError("name") + } + + return nil +} diff --git a/rpc/flipt/validation_test.go b/rpc/flipt/validation_test.go index c4e961af01..23ee283efe 100644 --- a/rpc/flipt/validation_test.go +++ b/rpc/flipt/validation_test.go @@ -1485,3 +1485,106 @@ func TestValidate_DeleteConstraintRequest(t *testing.T) { }) } } + +func TestValidate_CreateNamespaceRequest(t *testing.T) { + tests := []struct { + name string + req *CreateNamespaceRequest + wantErr error + }{ + { + name: "emptyKey", + req: &CreateNamespaceRequest{ + Key: "", + Name: "name", + Description: "desc", + }, + wantErr: errors.EmptyFieldError("key"), + }, + { + name: "invalidKey", + req: &CreateNamespaceRequest{ + Key: "foo:bar", + Name: "name", + Description: "desc", + }, + wantErr: errors.InvalidFieldError("key", "contains invalid characters"), + }, + { + name: "emptyName", + req: &CreateNamespaceRequest{ + Key: "key", + Name: "", + Description: "desc", + }, + wantErr: errors.EmptyFieldError("name"), + }, + { + name: "valid", + req: &CreateNamespaceRequest{ + Key: "key", + Name: "name", + Description: "desc", + }, + }, + } + + for _, tt := range tests { + var ( + req = tt.req + wantErr = tt.wantErr + ) + + t.Run(tt.name, func(t *testing.T) { + err := req.Validate() + assert.Equal(t, wantErr, err) + }) + } +} + +func TestValidate_UpdateNamespaceRequest(t *testing.T) { + tests := []struct { + name string + req *UpdateNamespaceRequest + wantErr error + }{ + { + name: "emptyKey", + req: &UpdateNamespaceRequest{ + Key: "", + Name: "name", + Description: "desc", + }, + wantErr: errors.EmptyFieldError("key"), + }, + { + name: "emptyName", + req: &UpdateNamespaceRequest{ + Key: "key", + Name: "", + Description: "desc", + }, + wantErr: errors.EmptyFieldError("name"), + }, + { + name: "valid", + req: &UpdateNamespaceRequest{ + Key: "key", + Name: "name", + Description: "desc", + }, + }, + } + + for _, tt := range tests { + var ( + req = tt.req + wantErr = tt.wantErr + ) + + t.Run(tt.name, func(t *testing.T) { + err := req.Validate() + assert.Equal(t, wantErr, err) + }) + } +} diff --git a/sdk/go/flipt.sdk.gen.go b/sdk/go/flipt.sdk.gen.go index 23da1ac1d4..8591905e5f 100644 --- a/sdk/go/flipt.sdk.gen.go +++ b/sdk/go/flipt.sdk.gen.go @@ -28,6 +28,47 @@ func (x *Flipt) BatchEvaluate(ctx context.Context, v *flipt.BatchEvaluationReque return x.transport.BatchEvaluate(ctx, v) } +func (x *Flipt) GetNamespace(ctx context.Context, v *flipt.GetNamespaceRequest) (*flipt.Namespace, error) { + ctx, err := authenticate(ctx, x.tokenProvider) + if err != nil { + return nil, err + } + return x.transport.GetNamespace(ctx, v) +} + +func (x *Flipt) ListNamespaces(ctx context.Context, v *flipt.ListNamespaceRequest) (*flipt.NamespaceList, error) { + ctx, err := authenticate(ctx, x.tokenProvider) + if err != nil { + return nil, err + } + return x.transport.ListNamespaces(ctx, v) +} + +func (x *Flipt) CreateNamespace(ctx context.Context, v *flipt.CreateNamespaceRequest) (*flipt.Namespace, error) { + ctx, err := authenticate(ctx, x.tokenProvider) + if err != nil { + return nil, err + } + return x.transport.CreateNamespace(ctx, v) +} + +func (x *Flipt) UpdateNamespace(ctx context.Context, v *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error) { + ctx, err := authenticate(ctx, x.tokenProvider) + if err != nil { + return nil, err + } + return x.transport.UpdateNamespace(ctx, v) +} + +func (x *Flipt) DeleteNamespace(ctx context.Context, v *flipt.DeleteNamespaceRequest) error { + ctx, err := authenticate(ctx, x.tokenProvider) + if err != nil { + return err + } + _, err = x.transport.DeleteNamespace(ctx, v) + return err +} + func (x *Flipt) GetFlag(ctx context.Context, v *flipt.GetFlagRequest) (*flipt.Flag, error) { ctx, err := authenticate(ctx, x.tokenProvider) if err != nil { diff --git a/sdk/go/http/flipt.sdk.gen.go b/sdk/go/http/flipt.sdk.gen.go index 65d5dc5326..0c27d55cea 100644 --- a/sdk/go/http/flipt.sdk.gen.go +++ b/sdk/go/http/flipt.sdk.gen.go @@ -28,7 +28,7 @@ func (x *FliptClient) Evaluate(ctx context.Context, v *flipt.EvaluationRequest, return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+"/api/v1/evaluate", body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/evaluate", v.NamespaceKey), body) if err != nil { return nil, err } @@ -60,7 +60,7 @@ func (x *FliptClient) BatchEvaluate(ctx context.Context, v *flipt.BatchEvaluatio return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+"/api/v1/batch-evaluate", body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/batch-evaluate", v.NamespaceKey), body) if err != nil { return nil, err } @@ -84,10 +84,158 @@ func (x *FliptClient) BatchEvaluate(ctx context.Context, v *flipt.BatchEvaluatio return &output, nil } +func (x *FliptClient) GetNamespace(ctx context.Context, v *flipt.GetNamespaceRequest, _ ...grpc.CallOption) (*flipt.Namespace, error) { + var body io.Reader + var values url.Values + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v", v.Key), body) + if err != nil { + return nil, err + } + req.URL.RawQuery = values.Encode() + resp, err := x.client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var output flipt.Namespace + respData, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if err := checkResponse(resp, respData); err != nil { + return nil, err + } + if err := (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(respData, &output); err != nil { + return nil, err + } + return &output, nil +} + +func (x *FliptClient) ListNamespaces(ctx context.Context, v *flipt.ListNamespaceRequest, _ ...grpc.CallOption) (*flipt.NamespaceList, error) { + var body io.Reader + values := url.Values{} + values.Set("limit", fmt.Sprintf("%v", v.Limit)) + values.Set("offset", fmt.Sprintf("%v", v.Offset)) + values.Set("pageToken", v.PageToken) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+"/api/v1/namespaces", body) + if err != nil { + return nil, err + } + req.URL.RawQuery = values.Encode() + resp, err := x.client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var output flipt.NamespaceList + respData, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if err := checkResponse(resp, respData); err != nil { + return nil, err + } + if err := (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(respData, &output); err != nil { + return nil, err + } + return &output, nil +} + +func (x *FliptClient) CreateNamespace(ctx context.Context, v *flipt.CreateNamespaceRequest, _ ...grpc.CallOption) (*flipt.Namespace, error) { + var body io.Reader + var values url.Values + reqData, err := protojson.Marshal(v) + if err != nil { + return nil, err + } + body = bytes.NewReader(reqData) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+"/api/v1/namespaces", body) + if err != nil { + return nil, err + } + req.URL.RawQuery = values.Encode() + resp, err := x.client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var output flipt.Namespace + respData, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if err := checkResponse(resp, respData); err != nil { + return nil, err + } + if err := (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(respData, &output); err != nil { + return nil, err + } + return &output, nil +} + +func (x *FliptClient) UpdateNamespace(ctx context.Context, v *flipt.UpdateNamespaceRequest, _ ...grpc.CallOption) (*flipt.Namespace, error) { + var body io.Reader + var values url.Values + reqData, err := protojson.Marshal(v) + if err != nil { + return nil, err + } + body = bytes.NewReader(reqData) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v", v.Key), body) + if err != nil { + return nil, err + } + req.URL.RawQuery = values.Encode() + resp, err := x.client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var output flipt.Namespace + respData, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if err := checkResponse(resp, respData); err != nil { + return nil, err + } + if err := (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(respData, &output); err != nil { + return nil, err + } + return &output, nil +} + +func (x *FliptClient) DeleteNamespace(ctx context.Context, v *flipt.DeleteNamespaceRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { + var body io.Reader + var values url.Values + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v", v.Key), body) + if err != nil { + return nil, err + } + req.URL.RawQuery = values.Encode() + resp, err := x.client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var output emptypb.Empty + respData, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + if err := checkResponse(resp, respData); err != nil { + return nil, err + } + if err := (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(respData, &output); err != nil { + return nil, err + } + return &output, nil +} + func (x *FliptClient) GetFlag(ctx context.Context, v *flipt.GetFlagRequest, _ ...grpc.CallOption) (*flipt.Flag, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/flags/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -117,7 +265,7 @@ func (x *FliptClient) ListFlags(ctx context.Context, v *flipt.ListFlagRequest, _ values.Set("limit", fmt.Sprintf("%v", v.Limit)) values.Set("offset", fmt.Sprintf("%v", v.Offset)) values.Set("pageToken", v.PageToken) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+"/api/v1/flags", body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags", v.NamespaceKey), body) if err != nil { return nil, err } @@ -149,7 +297,7 @@ func (x *FliptClient) CreateFlag(ctx context.Context, v *flipt.CreateFlagRequest return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+"/api/v1/flags", body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags", v.NamespaceKey), body) if err != nil { return nil, err } @@ -181,7 +329,7 @@ func (x *FliptClient) UpdateFlag(ctx context.Context, v *flipt.UpdateFlagRequest return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/flags/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -208,7 +356,7 @@ func (x *FliptClient) UpdateFlag(ctx context.Context, v *flipt.UpdateFlagRequest func (x *FliptClient) DeleteFlag(ctx context.Context, v *flipt.DeleteFlagRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/flags/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -240,7 +388,7 @@ func (x *FliptClient) CreateVariant(ctx context.Context, v *flipt.CreateVariantR return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/flags/%v/variants", v.FlagKey), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/variants", v.NamespaceKey, v.FlagKey), body) if err != nil { return nil, err } @@ -272,7 +420,7 @@ func (x *FliptClient) UpdateVariant(ctx context.Context, v *flipt.UpdateVariantR return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/flags/%v/variants/%v", v.FlagKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/variants/%v", v.NamespaceKey, v.FlagKey, v.Id), body) if err != nil { return nil, err } @@ -299,7 +447,7 @@ func (x *FliptClient) UpdateVariant(ctx context.Context, v *flipt.UpdateVariantR func (x *FliptClient) DeleteVariant(ctx context.Context, v *flipt.DeleteVariantRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/flags/%v/variants/%v", v.FlagKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/variants/%v", v.NamespaceKey, v.FlagKey, v.Id), body) if err != nil { return nil, err } @@ -326,7 +474,7 @@ func (x *FliptClient) DeleteVariant(ctx context.Context, v *flipt.DeleteVariantR func (x *FliptClient) GetRule(ctx context.Context, v *flipt.GetRuleRequest, _ ...grpc.CallOption) (*flipt.Rule, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v", v.FlagKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v", v.NamespaceKey, v.FlagKey, v.Id), body) if err != nil { return nil, err } @@ -356,7 +504,7 @@ func (x *FliptClient) ListRules(ctx context.Context, v *flipt.ListRuleRequest, _ values.Set("limit", fmt.Sprintf("%v", v.Limit)) values.Set("offset", fmt.Sprintf("%v", v.Offset)) values.Set("pageToken", v.PageToken) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules", v.FlagKey), body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules", v.NamespaceKey, v.FlagKey), body) if err != nil { return nil, err } @@ -388,7 +536,7 @@ func (x *FliptClient) CreateRule(ctx context.Context, v *flipt.CreateRuleRequest return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules", v.FlagKey), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules", v.NamespaceKey, v.FlagKey), body) if err != nil { return nil, err } @@ -420,7 +568,7 @@ func (x *FliptClient) UpdateRule(ctx context.Context, v *flipt.UpdateRuleRequest return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v", v.FlagKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v", v.NamespaceKey, v.FlagKey, v.Id), body) if err != nil { return nil, err } @@ -452,7 +600,7 @@ func (x *FliptClient) OrderRules(ctx context.Context, v *flipt.OrderRulesRequest return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/order", v.FlagKey), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/order", v.NamespaceKey, v.FlagKey), body) if err != nil { return nil, err } @@ -479,7 +627,7 @@ func (x *FliptClient) OrderRules(ctx context.Context, v *flipt.OrderRulesRequest func (x *FliptClient) DeleteRule(ctx context.Context, v *flipt.DeleteRuleRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v", v.FlagKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v", v.NamespaceKey, v.FlagKey, v.Id), body) if err != nil { return nil, err } @@ -511,7 +659,7 @@ func (x *FliptClient) CreateDistribution(ctx context.Context, v *flipt.CreateDis return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v/distributions", v.FlagKey, v.RuleId), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v/distributions", v.NamespaceKey, v.FlagKey, v.RuleId), body) if err != nil { return nil, err } @@ -543,7 +691,7 @@ func (x *FliptClient) UpdateDistribution(ctx context.Context, v *flipt.UpdateDis return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v/distributions/%v", v.FlagKey, v.RuleId, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v/distributions/%v", v.NamespaceKey, v.FlagKey, v.RuleId, v.Id), body) if err != nil { return nil, err } @@ -571,7 +719,7 @@ func (x *FliptClient) DeleteDistribution(ctx context.Context, v *flipt.DeleteDis var body io.Reader values := url.Values{} values.Set("variantId", v.VariantId) - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/flags/%v/rules/%v/distributions/%v", v.FlagKey, v.RuleId, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/flags/%v/rules/%v/distributions/%v", v.NamespaceKey, v.FlagKey, v.RuleId, v.Id), body) if err != nil { return nil, err } @@ -598,7 +746,7 @@ func (x *FliptClient) DeleteDistribution(ctx context.Context, v *flipt.DeleteDis func (x *FliptClient) GetSegment(ctx context.Context, v *flipt.GetSegmentRequest, _ ...grpc.CallOption) (*flipt.Segment, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/segments/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -628,7 +776,7 @@ func (x *FliptClient) ListSegments(ctx context.Context, v *flipt.ListSegmentRequ values.Set("limit", fmt.Sprintf("%v", v.Limit)) values.Set("offset", fmt.Sprintf("%v", v.Offset)) values.Set("pageToken", v.PageToken) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+"/api/v1/segments", body) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments", v.NamespaceKey), body) if err != nil { return nil, err } @@ -660,7 +808,7 @@ func (x *FliptClient) CreateSegment(ctx context.Context, v *flipt.CreateSegmentR return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+"/api/v1/segments", body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments", v.NamespaceKey), body) if err != nil { return nil, err } @@ -692,7 +840,7 @@ func (x *FliptClient) UpdateSegment(ctx context.Context, v *flipt.UpdateSegmentR return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/segments/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -719,7 +867,7 @@ func (x *FliptClient) UpdateSegment(ctx context.Context, v *flipt.UpdateSegmentR func (x *FliptClient) DeleteSegment(ctx context.Context, v *flipt.DeleteSegmentRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/segments/%v", v.Key), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v", v.NamespaceKey, v.Key), body) if err != nil { return nil, err } @@ -751,7 +899,7 @@ func (x *FliptClient) CreateConstraint(ctx context.Context, v *flipt.CreateConst return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/segments/%v/constraints", v.SegmentKey), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v/constraints", v.NamespaceKey, v.SegmentKey), body) if err != nil { return nil, err } @@ -783,7 +931,7 @@ func (x *FliptClient) UpdateConstraint(ctx context.Context, v *flipt.UpdateConst return nil, err } body = bytes.NewReader(reqData) - req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/segments/%v/constraints/%v", v.SegmentKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodPut, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v/constraints/%v", v.NamespaceKey, v.SegmentKey, v.Id), body) if err != nil { return nil, err } @@ -810,7 +958,7 @@ func (x *FliptClient) UpdateConstraint(ctx context.Context, v *flipt.UpdateConst func (x *FliptClient) DeleteConstraint(ctx context.Context, v *flipt.DeleteConstraintRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) { var body io.Reader var values url.Values - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/segments/%v/constraints/%v", v.SegmentKey, v.Id), body) + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, x.addr+fmt.Sprintf("/api/v1/namespaces/%v/segments/%v/constraints/%v", v.NamespaceKey, v.SegmentKey, v.Id), body) if err != nil { return nil, err }