From 15cbf77e1291338b5a356d9694354014c5e39dd0 Mon Sep 17 00:00:00 2001 From: Case Delst Date: Fri, 13 Sep 2024 15:58:16 -0700 Subject: [PATCH] refactor: Move endpoints to their own files, rename (#429) * Rename operations to make more sense * Move methods to separate files --- internal/dev_server/api/api.yaml | 10 +- .../dev_server/api/delete_flag_override.go | 21 + internal/dev_server/api/delete_project.go | 22 + internal/dev_server/api/get_environments.go | 33 ++ internal/dev_server/api/get_project.go | 60 +++ internal/dev_server/api/get_projects.go | 19 + internal/dev_server/api/patch_project.go | 60 +++ internal/dev_server/api/patch_sync_project.go | 60 +++ internal/dev_server/api/post_add_project.go | 74 +++ internal/dev_server/api/put_override_flag.go | 31 ++ internal/dev_server/api/server.gen.go | 468 +++++++++--------- internal/dev_server/api/server.go | 318 ------------ 12 files changed, 623 insertions(+), 553 deletions(-) create mode 100644 internal/dev_server/api/delete_flag_override.go create mode 100644 internal/dev_server/api/delete_project.go create mode 100644 internal/dev_server/api/get_environments.go create mode 100644 internal/dev_server/api/get_project.go create mode 100644 internal/dev_server/api/get_projects.go create mode 100644 internal/dev_server/api/patch_project.go create mode 100644 internal/dev_server/api/patch_sync_project.go create mode 100644 internal/dev_server/api/post_add_project.go create mode 100644 internal/dev_server/api/put_override_flag.go diff --git a/internal/dev_server/api/api.yaml b/internal/dev_server/api/api.yaml index 2dadf333..ca7e15cc 100644 --- a/internal/dev_server/api/api.yaml +++ b/internal/dev_server/api/api.yaml @@ -12,6 +12,7 @@ paths: /dev/projects: get: summary: lists all projects that have been configured for the dev server + operationId: getProjects responses: 200: description: OK. List of projects @@ -26,6 +27,7 @@ paths: /dev/projects/{projectKey}/sync: patch: summary: updates the flag state for the given project and source environment + operationId: patchSyncProject parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/projectExpand" @@ -37,6 +39,7 @@ paths: /dev/projects/{projectKey}: get: summary: get the specified project and its configuration for syncing from the LaunchDarkly Service + operationId: getProject parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/projectExpand" @@ -47,6 +50,7 @@ paths: description: No project found patch: summary: updates the project context or sourceEnvironmentKey + operationId: patchProject parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/projectExpand" @@ -68,6 +72,7 @@ paths: description: No project found delete: summary: remove the specified project from the dev server + operationId: deleteProject parameters: - $ref: "#/components/parameters/projectKey" responses: @@ -77,6 +82,7 @@ paths: $ref: "#/components/responses/ErrorResponse" post: summary: Add the project to the dev server + operationId: postAddProject parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/projectExpand" @@ -103,6 +109,7 @@ paths: /dev/projects/{projectKey}/overrides/{flagKey}: put: summary: override flag value with value provided in the body + operationId: putOverrideFlag parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/flagKey" @@ -121,6 +128,7 @@ paths: delete: summary: remove override for flag + operationId: deleteFlagOverride parameters: - $ref: "#/components/parameters/projectKey" - $ref: "#/components/parameters/flagKey" @@ -131,7 +139,7 @@ paths: description: no matching override found /dev/projects/{projectKey}/environments: get: - operationId: getProjectsEnvironments + operationId: getEnvironments summary: list all environments for the given project parameters: - $ref: "#/components/parameters/projectKey" diff --git a/internal/dev_server/api/delete_flag_override.go b/internal/dev_server/api/delete_flag_override.go new file mode 100644 index 00000000..b438b029 --- /dev/null +++ b/internal/dev_server/api/delete_flag_override.go @@ -0,0 +1,21 @@ +package api + +import ( + "context" + + "github.com/pkg/errors" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) DeleteFlagOverride(ctx context.Context, request DeleteFlagOverrideRequestObject) (DeleteFlagOverrideResponseObject, error) { + store := model.StoreFromContext(ctx) + err := store.DeactivateOverride(ctx, request.ProjectKey, request.FlagKey) + if err != nil { + if errors.Is(err, model.ErrNotFound) { + return DeleteFlagOverride404Response{}, nil + } + return nil, err + } + return DeleteFlagOverride204Response{}, nil +} diff --git a/internal/dev_server/api/delete_project.go b/internal/dev_server/api/delete_project.go new file mode 100644 index 00000000..7a7cef34 --- /dev/null +++ b/internal/dev_server/api/delete_project.go @@ -0,0 +1,22 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) DeleteProject(ctx context.Context, request DeleteProjectRequestObject) (DeleteProjectResponseObject, error) { + store := model.StoreFromContext(ctx) + deleted, err := store.DeleteDevProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + if !deleted { + return DeleteProject404JSONResponse{ErrorResponseJSONResponse{ + Code: "not_found", + Message: "project not found", + }}, nil + } + return DeleteProject204Response{}, nil +} diff --git a/internal/dev_server/api/get_environments.go b/internal/dev_server/api/get_environments.go new file mode 100644 index 00000000..d0e4597e --- /dev/null +++ b/internal/dev_server/api/get_environments.go @@ -0,0 +1,33 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) GetEnvironments(ctx context.Context, request GetEnvironmentsRequestObject) (GetEnvironmentsResponseObject, error) { + store := model.StoreFromContext(ctx) + project, err := store.GetDevProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + if project == nil { + return GetEnvironments404JSONResponse{}, nil + } + + environments, err := model.GetEnvironmentsForProject(ctx, project.Key) + if err != nil { + return nil, err + } + + var envReps []Environment + for _, env := range environments { + envReps = append(envReps, Environment{ + Key: env.Key, + Name: env.Name, + }) + } + + return GetEnvironments200JSONResponse(envReps), nil +} diff --git a/internal/dev_server/api/get_project.go b/internal/dev_server/api/get_project.go new file mode 100644 index 00000000..d54591f9 --- /dev/null +++ b/internal/dev_server/api/get_project.go @@ -0,0 +1,60 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) GetProject(ctx context.Context, request GetProjectRequestObject) (GetProjectResponseObject, error) { + store := model.StoreFromContext(ctx) + project, err := store.GetDevProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + if project == nil { + return GetProject404Response{}, nil + } + + response := ProjectJSONResponse{ + LastSyncedFromSource: project.LastSyncTime.Unix(), + Context: project.Context, + SourceEnvironmentKey: project.SourceEnvironmentKey, + FlagsState: &project.AllFlagsState, + } + + if request.Params.Expand != nil { + for _, item := range *request.Params.Expand { + if item == "overrides" { + overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respOverrides := make(model.FlagsState) + for _, override := range overrides { + if !override.Active { + continue + } + respOverrides[override.FlagKey] = model.FlagState{ + Value: override.Value, + Version: override.Version, + } + } + response.Overrides = &respOverrides + } + if item == "availableVariations" { + availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respAvailableVariations := availableVariationsToResponseFormat(availableVariations) + response.AvailableVariations = &respAvailableVariations + } + } + + } + + return GetProject200JSONResponse{ + response, + }, nil +} diff --git a/internal/dev_server/api/get_projects.go b/internal/dev_server/api/get_projects.go new file mode 100644 index 00000000..94bab318 --- /dev/null +++ b/internal/dev_server/api/get_projects.go @@ -0,0 +1,19 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) GetProjects(ctx context.Context, _ GetProjectsRequestObject) (GetProjectsResponseObject, error) { + store := model.StoreFromContext(ctx) + projectKeys, err := store.GetDevProjectKeys(ctx) + if err != nil { + return nil, err + } + if projectKeys == nil { + projectKeys = make([]string, 0) // HACK to make the json behavior compatible with go. + } + return GetProjects200JSONResponse(projectKeys), nil +} diff --git a/internal/dev_server/api/patch_project.go b/internal/dev_server/api/patch_project.go new file mode 100644 index 00000000..c7fcd4a6 --- /dev/null +++ b/internal/dev_server/api/patch_project.go @@ -0,0 +1,60 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) PatchProject(ctx context.Context, request PatchProjectRequestObject) (PatchProjectResponseObject, error) { + store := model.StoreFromContext(ctx) + project, err := model.UpdateProject(ctx, request.ProjectKey, request.Body.Context, request.Body.SourceEnvironmentKey) + if err != nil { + return nil, err + } + if project.Key == "" && project.SourceEnvironmentKey == "" { + return PatchProject404Response{}, nil + } + + response := ProjectJSONResponse{ + LastSyncedFromSource: project.LastSyncTime.Unix(), + Context: project.Context, + SourceEnvironmentKey: project.SourceEnvironmentKey, + FlagsState: &project.AllFlagsState, + } + + if request.Params.Expand != nil { + for _, item := range *request.Params.Expand { + if item == "overrides" { + overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respOverrides := make(model.FlagsState) + for _, override := range overrides { + if !override.Active { + continue + } + respOverrides[override.FlagKey] = model.FlagState{ + Value: override.Value, + Version: override.Version, + } + } + response.Overrides = &respOverrides + } + if item == "availableVariations" { + availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respAvailableVariations := availableVariationsToResponseFormat(availableVariations) + response.AvailableVariations = &respAvailableVariations + } + } + + } + + return PatchProject200JSONResponse{ + response, + }, nil +} diff --git a/internal/dev_server/api/patch_sync_project.go b/internal/dev_server/api/patch_sync_project.go new file mode 100644 index 00000000..94420b20 --- /dev/null +++ b/internal/dev_server/api/patch_sync_project.go @@ -0,0 +1,60 @@ +package api + +import ( + "context" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) PatchSyncProject(ctx context.Context, request PatchSyncProjectRequestObject) (PatchSyncProjectResponseObject, error) { + store := model.StoreFromContext(ctx) + project, err := model.UpdateProject(ctx, request.ProjectKey, nil, nil) + if err != nil { + return nil, err + } + if project.Key == "" && project.SourceEnvironmentKey == "" { + return PatchSyncProject404Response{}, nil + } + + response := ProjectJSONResponse{ + LastSyncedFromSource: project.LastSyncTime.Unix(), + Context: project.Context, + SourceEnvironmentKey: project.SourceEnvironmentKey, + FlagsState: &project.AllFlagsState, + } + + if request.Params.Expand != nil { + for _, item := range *request.Params.Expand { + if item == "overrides" { + overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respOverrides := make(model.FlagsState) + for _, override := range overrides { + if !override.Active { + continue + } + respOverrides[override.FlagKey] = model.FlagState{ + Value: override.Value, + Version: override.Version, + } + } + response.Overrides = &respOverrides + } + if item == "availableVariations" { + availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respAvailableVariations := availableVariationsToResponseFormat(availableVariations) + response.AvailableVariations = &respAvailableVariations + } + } + + } + + return PatchSyncProject200JSONResponse{ + response, + }, nil +} diff --git a/internal/dev_server/api/post_add_project.go b/internal/dev_server/api/post_add_project.go new file mode 100644 index 00000000..37f0f5ad --- /dev/null +++ b/internal/dev_server/api/post_add_project.go @@ -0,0 +1,74 @@ +package api + +import ( + "context" + + "github.com/pkg/errors" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) PostAddProject(ctx context.Context, request PostAddProjectRequestObject) (PostAddProjectResponseObject, error) { + if request.Body.SourceEnvironmentKey == "" { + return PostAddProject400JSONResponse{ + ErrorResponseJSONResponse{ + Code: "invalid_request", + Message: "sourceEnvironmentKey is required", + }, + }, nil + } + + store := model.StoreFromContext(ctx) + project, err := model.CreateProject(ctx, request.ProjectKey, request.Body.SourceEnvironmentKey, request.Body.Context) + switch { + case errors.Is(err, model.ErrAlreadyExists): + return PostAddProject409JSONResponse{ + Code: "conflict", + Message: "project already exists", + }, nil + case err != nil: + return nil, err + } + + response := ProjectJSONResponse{ + LastSyncedFromSource: project.LastSyncTime.Unix(), + Context: project.Context, + SourceEnvironmentKey: project.SourceEnvironmentKey, + FlagsState: &project.AllFlagsState, + } + + if request.Params.Expand != nil { + for _, item := range *request.Params.Expand { + if item == "overrides" { + overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respOverrides := make(model.FlagsState) + for _, override := range overrides { + if !override.Active { + continue + } + respOverrides[override.FlagKey] = model.FlagState{ + Value: override.Value, + Version: override.Version, + } + } + response.Overrides = &respOverrides + } + if item == "availableVariations" { + availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) + if err != nil { + return nil, err + } + respAvailableVariations := availableVariationsToResponseFormat(availableVariations) + response.AvailableVariations = &respAvailableVariations + } + } + + } + + return PostAddProject201JSONResponse{ + response, + }, nil +} diff --git a/internal/dev_server/api/put_override_flag.go b/internal/dev_server/api/put_override_flag.go new file mode 100644 index 00000000..533bd1b4 --- /dev/null +++ b/internal/dev_server/api/put_override_flag.go @@ -0,0 +1,31 @@ +package api + +import ( + "context" + + "github.com/pkg/errors" + + "github.com/launchdarkly/ldcli/internal/dev_server/model" +) + +func (s server) PutOverrideFlag(ctx context.Context, request PutOverrideFlagRequestObject) (PutOverrideFlagResponseObject, error) { + if request.Body == nil { + return nil, errors.New("empty override body") + } + override, err := model.UpsertOverride(ctx, request.ProjectKey, request.FlagKey, *request.Body) + if err != nil { + if errors.As(err, &model.Error{}) { + return PutOverrideFlag400JSONResponse{ + ErrorResponseJSONResponse{ + Code: "invalid_request", + Message: err.Error(), + }, + }, nil + } + return nil, err + } + return PutOverrideFlag200JSONResponse{FlagOverrideJSONResponse{ + Override: override.Active, + Value: override.Value, + }}, nil +} diff --git a/internal/dev_server/api/server.gen.go b/internal/dev_server/api/server.gen.go index ef7e4ec4..2a670346 100644 --- a/internal/dev_server/api/server.gen.go +++ b/internal/dev_server/api/server.gen.go @@ -17,28 +17,28 @@ import ( strictnethttp "github.com/oapi-codegen/runtime/strictmiddleware/nethttp" ) -// Defines values for GetDevProjectsProjectKeyParamsExpand. +// Defines values for GetProjectParamsExpand. const ( - GetDevProjectsProjectKeyParamsExpandAvailableVariations GetDevProjectsProjectKeyParamsExpand = "availableVariations" - GetDevProjectsProjectKeyParamsExpandOverrides GetDevProjectsProjectKeyParamsExpand = "overrides" + GetProjectParamsExpandAvailableVariations GetProjectParamsExpand = "availableVariations" + GetProjectParamsExpandOverrides GetProjectParamsExpand = "overrides" ) -// Defines values for PatchDevProjectsProjectKeyParamsExpand. +// Defines values for PatchProjectParamsExpand. const ( - PatchDevProjectsProjectKeyParamsExpandAvailableVariations PatchDevProjectsProjectKeyParamsExpand = "availableVariations" - PatchDevProjectsProjectKeyParamsExpandOverrides PatchDevProjectsProjectKeyParamsExpand = "overrides" + PatchProjectParamsExpandAvailableVariations PatchProjectParamsExpand = "availableVariations" + PatchProjectParamsExpandOverrides PatchProjectParamsExpand = "overrides" ) -// Defines values for PostDevProjectsProjectKeyParamsExpand. +// Defines values for PostAddProjectParamsExpand. const ( - PostDevProjectsProjectKeyParamsExpandAvailableVariations PostDevProjectsProjectKeyParamsExpand = "availableVariations" - PostDevProjectsProjectKeyParamsExpandOverrides PostDevProjectsProjectKeyParamsExpand = "overrides" + PostAddProjectParamsExpandAvailableVariations PostAddProjectParamsExpand = "availableVariations" + PostAddProjectParamsExpandOverrides PostAddProjectParamsExpand = "overrides" ) -// Defines values for PatchDevProjectsProjectKeySyncParamsExpand. +// Defines values for PatchSyncProjectParamsExpand. const ( - PatchDevProjectsProjectKeySyncParamsExpandAvailableVariations PatchDevProjectsProjectKeySyncParamsExpand = "availableVariations" - PatchDevProjectsProjectKeySyncParamsExpandOverrides PatchDevProjectsProjectKeySyncParamsExpand = "overrides" + PatchSyncProjectParamsExpandAvailableVariations PatchSyncProjectParamsExpand = "availableVariations" + PatchSyncProjectParamsExpandOverrides PatchSyncProjectParamsExpand = "overrides" ) // Context context object to use when evaluating flags in source environment @@ -111,17 +111,17 @@ type FlagOverride struct { Value FlagValue `json:"value"` } -// GetDevProjectsProjectKeyParams defines parameters for GetDevProjectsProjectKey. -type GetDevProjectsProjectKeyParams struct { +// GetProjectParams defines parameters for GetProject. +type GetProjectParams struct { // Expand Available expand options for this endpoint. Expand *ProjectExpand `form:"expand,omitempty" json:"expand,omitempty"` } -// GetDevProjectsProjectKeyParamsExpand defines parameters for GetDevProjectsProjectKey. -type GetDevProjectsProjectKeyParamsExpand string +// GetProjectParamsExpand defines parameters for GetProject. +type GetProjectParamsExpand string -// PatchDevProjectsProjectKeyJSONBody defines parameters for PatchDevProjectsProjectKey. -type PatchDevProjectsProjectKeyJSONBody struct { +// PatchProjectJSONBody defines parameters for PatchProject. +type PatchProjectJSONBody struct { // Context context object to use when evaluating flags in source environment Context *Context `json:"context,omitempty"` @@ -129,17 +129,17 @@ type PatchDevProjectsProjectKeyJSONBody struct { SourceEnvironmentKey *string `json:"sourceEnvironmentKey,omitempty"` } -// PatchDevProjectsProjectKeyParams defines parameters for PatchDevProjectsProjectKey. -type PatchDevProjectsProjectKeyParams struct { +// PatchProjectParams defines parameters for PatchProject. +type PatchProjectParams struct { // Expand Available expand options for this endpoint. Expand *ProjectExpand `form:"expand,omitempty" json:"expand,omitempty"` } -// PatchDevProjectsProjectKeyParamsExpand defines parameters for PatchDevProjectsProjectKey. -type PatchDevProjectsProjectKeyParamsExpand string +// PatchProjectParamsExpand defines parameters for PatchProject. +type PatchProjectParamsExpand string -// PostDevProjectsProjectKeyJSONBody defines parameters for PostDevProjectsProjectKey. -type PostDevProjectsProjectKeyJSONBody struct { +// PostAddProjectJSONBody defines parameters for PostAddProject. +type PostAddProjectJSONBody struct { // Context context object to use when evaluating flags in source environment Context *Context `json:"context,omitempty"` @@ -147,62 +147,62 @@ type PostDevProjectsProjectKeyJSONBody struct { SourceEnvironmentKey string `json:"sourceEnvironmentKey"` } -// PostDevProjectsProjectKeyParams defines parameters for PostDevProjectsProjectKey. -type PostDevProjectsProjectKeyParams struct { +// PostAddProjectParams defines parameters for PostAddProject. +type PostAddProjectParams struct { // Expand Available expand options for this endpoint. Expand *ProjectExpand `form:"expand,omitempty" json:"expand,omitempty"` } -// PostDevProjectsProjectKeyParamsExpand defines parameters for PostDevProjectsProjectKey. -type PostDevProjectsProjectKeyParamsExpand string +// PostAddProjectParamsExpand defines parameters for PostAddProject. +type PostAddProjectParamsExpand string -// PatchDevProjectsProjectKeySyncParams defines parameters for PatchDevProjectsProjectKeySync. -type PatchDevProjectsProjectKeySyncParams struct { +// PatchSyncProjectParams defines parameters for PatchSyncProject. +type PatchSyncProjectParams struct { // Expand Available expand options for this endpoint. Expand *ProjectExpand `form:"expand,omitempty" json:"expand,omitempty"` } -// PatchDevProjectsProjectKeySyncParamsExpand defines parameters for PatchDevProjectsProjectKeySync. -type PatchDevProjectsProjectKeySyncParamsExpand string +// PatchSyncProjectParamsExpand defines parameters for PatchSyncProject. +type PatchSyncProjectParamsExpand string -// PatchDevProjectsProjectKeyJSONRequestBody defines body for PatchDevProjectsProjectKey for application/json ContentType. -type PatchDevProjectsProjectKeyJSONRequestBody PatchDevProjectsProjectKeyJSONBody +// PatchProjectJSONRequestBody defines body for PatchProject for application/json ContentType. +type PatchProjectJSONRequestBody PatchProjectJSONBody -// PostDevProjectsProjectKeyJSONRequestBody defines body for PostDevProjectsProjectKey for application/json ContentType. -type PostDevProjectsProjectKeyJSONRequestBody PostDevProjectsProjectKeyJSONBody +// PostAddProjectJSONRequestBody defines body for PostAddProject for application/json ContentType. +type PostAddProjectJSONRequestBody PostAddProjectJSONBody -// PutDevProjectsProjectKeyOverridesFlagKeyJSONRequestBody defines body for PutDevProjectsProjectKeyOverridesFlagKey for application/json ContentType. -type PutDevProjectsProjectKeyOverridesFlagKeyJSONRequestBody = FlagValue +// PutOverrideFlagJSONRequestBody defines body for PutOverrideFlag for application/json ContentType. +type PutOverrideFlagJSONRequestBody = FlagValue // ServerInterface represents all server handlers. type ServerInterface interface { // lists all projects that have been configured for the dev server // (GET /dev/projects) - GetDevProjects(w http.ResponseWriter, r *http.Request) + GetProjects(w http.ResponseWriter, r *http.Request) // remove the specified project from the dev server // (DELETE /dev/projects/{projectKey}) - DeleteDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) + DeleteProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) // get the specified project and its configuration for syncing from the LaunchDarkly Service // (GET /dev/projects/{projectKey}) - GetDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params GetDevProjectsProjectKeyParams) + GetProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params GetProjectParams) // updates the project context or sourceEnvironmentKey // (PATCH /dev/projects/{projectKey}) - PatchDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchDevProjectsProjectKeyParams) + PatchProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchProjectParams) // Add the project to the dev server // (POST /dev/projects/{projectKey}) - PostDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PostDevProjectsProjectKeyParams) + PostAddProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PostAddProjectParams) // list all environments for the given project // (GET /dev/projects/{projectKey}/environments) - GetProjectsEnvironments(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) + GetEnvironments(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) // remove override for flag // (DELETE /dev/projects/{projectKey}/overrides/{flagKey}) - DeleteDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) + DeleteFlagOverride(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) // override flag value with value provided in the body // (PUT /dev/projects/{projectKey}/overrides/{flagKey}) - PutDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) + PutOverrideFlag(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) // updates the flag state for the given project and source environment // (PATCH /dev/projects/{projectKey}/sync) - PatchDevProjectsProjectKeySync(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchDevProjectsProjectKeySyncParams) + PatchSyncProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchSyncProjectParams) } // ServerInterfaceWrapper converts contexts to parameters. @@ -214,12 +214,12 @@ type ServerInterfaceWrapper struct { type MiddlewareFunc func(http.Handler) http.Handler -// GetDevProjects operation middleware -func (siw *ServerInterfaceWrapper) GetDevProjects(w http.ResponseWriter, r *http.Request) { +// GetProjects operation middleware +func (siw *ServerInterfaceWrapper) GetProjects(w http.ResponseWriter, r *http.Request) { ctx := r.Context() handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetDevProjects(w, r) + siw.Handler.GetProjects(w, r) })) for _, middleware := range siw.HandlerMiddlewares { @@ -229,8 +229,8 @@ func (siw *ServerInterfaceWrapper) GetDevProjects(w http.ResponseWriter, r *http handler.ServeHTTP(w, r.WithContext(ctx)) } -// DeleteDevProjectsProjectKey operation middleware -func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKey(w http.ResponseWriter, r *http.Request) { +// DeleteProject operation middleware +func (siw *ServerInterfaceWrapper) DeleteProject(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -245,7 +245,7 @@ func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKey(w http.ResponseWr } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteDevProjectsProjectKey(w, r, projectKey) + siw.Handler.DeleteProject(w, r, projectKey) })) for _, middleware := range siw.HandlerMiddlewares { @@ -255,8 +255,8 @@ func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKey(w http.ResponseWr handler.ServeHTTP(w, r.WithContext(ctx)) } -// GetDevProjectsProjectKey operation middleware -func (siw *ServerInterfaceWrapper) GetDevProjectsProjectKey(w http.ResponseWriter, r *http.Request) { +// GetProject operation middleware +func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -271,7 +271,7 @@ func (siw *ServerInterfaceWrapper) GetDevProjectsProjectKey(w http.ResponseWrite } // Parameter object where we will unmarshal all parameters from the context - var params GetDevProjectsProjectKeyParams + var params GetProjectParams // ------------- Optional query parameter "expand" ------------- @@ -282,7 +282,7 @@ func (siw *ServerInterfaceWrapper) GetDevProjectsProjectKey(w http.ResponseWrite } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetDevProjectsProjectKey(w, r, projectKey, params) + siw.Handler.GetProject(w, r, projectKey, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -292,8 +292,8 @@ func (siw *ServerInterfaceWrapper) GetDevProjectsProjectKey(w http.ResponseWrite handler.ServeHTTP(w, r.WithContext(ctx)) } -// PatchDevProjectsProjectKey operation middleware -func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKey(w http.ResponseWriter, r *http.Request) { +// PatchProject operation middleware +func (siw *ServerInterfaceWrapper) PatchProject(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -308,7 +308,7 @@ func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKey(w http.ResponseWri } // Parameter object where we will unmarshal all parameters from the context - var params PatchDevProjectsProjectKeyParams + var params PatchProjectParams // ------------- Optional query parameter "expand" ------------- @@ -319,7 +319,7 @@ func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKey(w http.ResponseWri } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.PatchDevProjectsProjectKey(w, r, projectKey, params) + siw.Handler.PatchProject(w, r, projectKey, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -329,8 +329,8 @@ func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKey(w http.ResponseWri handler.ServeHTTP(w, r.WithContext(ctx)) } -// PostDevProjectsProjectKey operation middleware -func (siw *ServerInterfaceWrapper) PostDevProjectsProjectKey(w http.ResponseWriter, r *http.Request) { +// PostAddProject operation middleware +func (siw *ServerInterfaceWrapper) PostAddProject(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -345,7 +345,7 @@ func (siw *ServerInterfaceWrapper) PostDevProjectsProjectKey(w http.ResponseWrit } // Parameter object where we will unmarshal all parameters from the context - var params PostDevProjectsProjectKeyParams + var params PostAddProjectParams // ------------- Optional query parameter "expand" ------------- @@ -356,7 +356,7 @@ func (siw *ServerInterfaceWrapper) PostDevProjectsProjectKey(w http.ResponseWrit } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.PostDevProjectsProjectKey(w, r, projectKey, params) + siw.Handler.PostAddProject(w, r, projectKey, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -366,8 +366,8 @@ func (siw *ServerInterfaceWrapper) PostDevProjectsProjectKey(w http.ResponseWrit handler.ServeHTTP(w, r.WithContext(ctx)) } -// GetProjectsEnvironments operation middleware -func (siw *ServerInterfaceWrapper) GetProjectsEnvironments(w http.ResponseWriter, r *http.Request) { +// GetEnvironments operation middleware +func (siw *ServerInterfaceWrapper) GetEnvironments(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -382,7 +382,7 @@ func (siw *ServerInterfaceWrapper) GetProjectsEnvironments(w http.ResponseWriter } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetProjectsEnvironments(w, r, projectKey) + siw.Handler.GetEnvironments(w, r, projectKey) })) for _, middleware := range siw.HandlerMiddlewares { @@ -392,8 +392,8 @@ func (siw *ServerInterfaceWrapper) GetProjectsEnvironments(w http.ResponseWriter handler.ServeHTTP(w, r.WithContext(ctx)) } -// DeleteDevProjectsProjectKeyOverridesFlagKey operation middleware -func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request) { +// DeleteFlagOverride operation middleware +func (siw *ServerInterfaceWrapper) DeleteFlagOverride(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -417,7 +417,7 @@ func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKeyOverridesFlagKey(w } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteDevProjectsProjectKeyOverridesFlagKey(w, r, projectKey, flagKey) + siw.Handler.DeleteFlagOverride(w, r, projectKey, flagKey) })) for _, middleware := range siw.HandlerMiddlewares { @@ -427,8 +427,8 @@ func (siw *ServerInterfaceWrapper) DeleteDevProjectsProjectKeyOverridesFlagKey(w handler.ServeHTTP(w, r.WithContext(ctx)) } -// PutDevProjectsProjectKeyOverridesFlagKey operation middleware -func (siw *ServerInterfaceWrapper) PutDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request) { +// PutOverrideFlag operation middleware +func (siw *ServerInterfaceWrapper) PutOverrideFlag(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -452,7 +452,7 @@ func (siw *ServerInterfaceWrapper) PutDevProjectsProjectKeyOverridesFlagKey(w ht } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.PutDevProjectsProjectKeyOverridesFlagKey(w, r, projectKey, flagKey) + siw.Handler.PutOverrideFlag(w, r, projectKey, flagKey) })) for _, middleware := range siw.HandlerMiddlewares { @@ -462,8 +462,8 @@ func (siw *ServerInterfaceWrapper) PutDevProjectsProjectKeyOverridesFlagKey(w ht handler.ServeHTTP(w, r.WithContext(ctx)) } -// PatchDevProjectsProjectKeySync operation middleware -func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKeySync(w http.ResponseWriter, r *http.Request) { +// PatchSyncProject operation middleware +func (siw *ServerInterfaceWrapper) PatchSyncProject(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var err error @@ -478,7 +478,7 @@ func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKeySync(w http.Respons } // Parameter object where we will unmarshal all parameters from the context - var params PatchDevProjectsProjectKeySyncParams + var params PatchSyncProjectParams // ------------- Optional query parameter "expand" ------------- @@ -489,7 +489,7 @@ func (siw *ServerInterfaceWrapper) PatchDevProjectsProjectKeySync(w http.Respons } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.PatchDevProjectsProjectKeySync(w, r, projectKey, params) + siw.Handler.PatchSyncProject(w, r, projectKey, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -612,23 +612,23 @@ func HandlerWithOptions(si ServerInterface, options GorillaServerOptions) http.H ErrorHandlerFunc: options.ErrorHandlerFunc, } - r.HandleFunc(options.BaseURL+"/dev/projects", wrapper.GetDevProjects).Methods("GET") + r.HandleFunc(options.BaseURL+"/dev/projects", wrapper.GetProjects).Methods("GET") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.DeleteDevProjectsProjectKey).Methods("DELETE") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.DeleteProject).Methods("DELETE") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.GetDevProjectsProjectKey).Methods("GET") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.GetProject).Methods("GET") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.PatchDevProjectsProjectKey).Methods("PATCH") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.PatchProject).Methods("PATCH") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.PostDevProjectsProjectKey).Methods("POST") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}", wrapper.PostAddProject).Methods("POST") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/environments", wrapper.GetProjectsEnvironments).Methods("GET") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/environments", wrapper.GetEnvironments).Methods("GET") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/overrides/{flagKey}", wrapper.DeleteDevProjectsProjectKeyOverridesFlagKey).Methods("DELETE") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/overrides/{flagKey}", wrapper.DeleteFlagOverride).Methods("DELETE") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/overrides/{flagKey}", wrapper.PutDevProjectsProjectKeyOverridesFlagKey).Methods("PUT") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/overrides/{flagKey}", wrapper.PutOverrideFlag).Methods("PUT") - r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/sync", wrapper.PatchDevProjectsProjectKeySync).Methods("PATCH") + r.HandleFunc(options.BaseURL+"/dev/projects/{projectKey}/sync", wrapper.PatchSyncProject).Methods("PATCH") return r } @@ -651,129 +651,129 @@ type FlagOverrideJSONResponse struct { type ProjectJSONResponse Project -type GetDevProjectsRequestObject struct { +type GetProjectsRequestObject struct { } -type GetDevProjectsResponseObject interface { - VisitGetDevProjectsResponse(w http.ResponseWriter) error +type GetProjectsResponseObject interface { + VisitGetProjectsResponse(w http.ResponseWriter) error } -type GetDevProjects200JSONResponse []string +type GetProjects200JSONResponse []string -func (response GetDevProjects200JSONResponse) VisitGetDevProjectsResponse(w http.ResponseWriter) error { +func (response GetProjects200JSONResponse) VisitGetProjectsResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type DeleteDevProjectsProjectKeyRequestObject struct { +type DeleteProjectRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` } -type DeleteDevProjectsProjectKeyResponseObject interface { - VisitDeleteDevProjectsProjectKeyResponse(w http.ResponseWriter) error +type DeleteProjectResponseObject interface { + VisitDeleteProjectResponse(w http.ResponseWriter) error } -type DeleteDevProjectsProjectKey204Response struct { +type DeleteProject204Response struct { } -func (response DeleteDevProjectsProjectKey204Response) VisitDeleteDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response DeleteProject204Response) VisitDeleteProjectResponse(w http.ResponseWriter) error { w.WriteHeader(204) return nil } -type DeleteDevProjectsProjectKey404JSONResponse struct{ ErrorResponseJSONResponse } +type DeleteProject404JSONResponse struct{ ErrorResponseJSONResponse } -func (response DeleteDevProjectsProjectKey404JSONResponse) VisitDeleteDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response DeleteProject404JSONResponse) VisitDeleteProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(404) return json.NewEncoder(w).Encode(response) } -type GetDevProjectsProjectKeyRequestObject struct { +type GetProjectRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` - Params GetDevProjectsProjectKeyParams + Params GetProjectParams } -type GetDevProjectsProjectKeyResponseObject interface { - VisitGetDevProjectsProjectKeyResponse(w http.ResponseWriter) error +type GetProjectResponseObject interface { + VisitGetProjectResponse(w http.ResponseWriter) error } -type GetDevProjectsProjectKey200JSONResponse struct{ ProjectJSONResponse } +type GetProject200JSONResponse struct{ ProjectJSONResponse } -func (response GetDevProjectsProjectKey200JSONResponse) VisitGetDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response GetProject200JSONResponse) VisitGetProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type GetDevProjectsProjectKey404Response struct { +type GetProject404Response struct { } -func (response GetDevProjectsProjectKey404Response) VisitGetDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response GetProject404Response) VisitGetProjectResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type PatchDevProjectsProjectKeyRequestObject struct { +type PatchProjectRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` - Params PatchDevProjectsProjectKeyParams - Body *PatchDevProjectsProjectKeyJSONRequestBody + Params PatchProjectParams + Body *PatchProjectJSONRequestBody } -type PatchDevProjectsProjectKeyResponseObject interface { - VisitPatchDevProjectsProjectKeyResponse(w http.ResponseWriter) error +type PatchProjectResponseObject interface { + VisitPatchProjectResponse(w http.ResponseWriter) error } -type PatchDevProjectsProjectKey200JSONResponse struct{ ProjectJSONResponse } +type PatchProject200JSONResponse struct{ ProjectJSONResponse } -func (response PatchDevProjectsProjectKey200JSONResponse) VisitPatchDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response PatchProject200JSONResponse) VisitPatchProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type PatchDevProjectsProjectKey404Response struct { +type PatchProject404Response struct { } -func (response PatchDevProjectsProjectKey404Response) VisitPatchDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response PatchProject404Response) VisitPatchProjectResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type PostDevProjectsProjectKeyRequestObject struct { +type PostAddProjectRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` - Params PostDevProjectsProjectKeyParams - Body *PostDevProjectsProjectKeyJSONRequestBody + Params PostAddProjectParams + Body *PostAddProjectJSONRequestBody } -type PostDevProjectsProjectKeyResponseObject interface { - VisitPostDevProjectsProjectKeyResponse(w http.ResponseWriter) error +type PostAddProjectResponseObject interface { + VisitPostAddProjectResponse(w http.ResponseWriter) error } -type PostDevProjectsProjectKey201JSONResponse struct{ ProjectJSONResponse } +type PostAddProject201JSONResponse struct{ ProjectJSONResponse } -func (response PostDevProjectsProjectKey201JSONResponse) VisitPostDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response PostAddProject201JSONResponse) VisitPostAddProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(201) return json.NewEncoder(w).Encode(response) } -type PostDevProjectsProjectKey400JSONResponse struct{ ErrorResponseJSONResponse } +type PostAddProject400JSONResponse struct{ ErrorResponseJSONResponse } -func (response PostDevProjectsProjectKey400JSONResponse) VisitPostDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response PostAddProject400JSONResponse) VisitPostAddProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(400) return json.NewEncoder(w).Encode(response) } -type PostDevProjectsProjectKey409JSONResponse struct { +type PostAddProject409JSONResponse struct { // Code specific error code encountered Code string `json:"code"` @@ -781,40 +781,40 @@ type PostDevProjectsProjectKey409JSONResponse struct { Message string `json:"message"` } -func (response PostDevProjectsProjectKey409JSONResponse) VisitPostDevProjectsProjectKeyResponse(w http.ResponseWriter) error { +func (response PostAddProject409JSONResponse) VisitPostAddProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(409) return json.NewEncoder(w).Encode(response) } -type GetProjectsEnvironmentsRequestObject struct { +type GetEnvironmentsRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` } -type GetProjectsEnvironmentsResponseObject interface { - VisitGetProjectsEnvironmentsResponse(w http.ResponseWriter) error +type GetEnvironmentsResponseObject interface { + VisitGetEnvironmentsResponse(w http.ResponseWriter) error } -type GetProjectsEnvironments200JSONResponse []Environment +type GetEnvironments200JSONResponse []Environment -func (response GetProjectsEnvironments200JSONResponse) VisitGetProjectsEnvironmentsResponse(w http.ResponseWriter) error { +func (response GetEnvironments200JSONResponse) VisitGetEnvironmentsResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type GetProjectsEnvironments400JSONResponse struct{ ErrorResponseJSONResponse } +type GetEnvironments400JSONResponse struct{ ErrorResponseJSONResponse } -func (response GetProjectsEnvironments400JSONResponse) VisitGetProjectsEnvironmentsResponse(w http.ResponseWriter) error { +func (response GetEnvironments400JSONResponse) VisitGetEnvironmentsResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(400) return json.NewEncoder(w).Encode(response) } -type GetProjectsEnvironments404JSONResponse struct { +type GetEnvironments404JSONResponse struct { // Code specific error code encountered Code string `json:"code"` @@ -822,88 +822,88 @@ type GetProjectsEnvironments404JSONResponse struct { Message string `json:"message"` } -func (response GetProjectsEnvironments404JSONResponse) VisitGetProjectsEnvironmentsResponse(w http.ResponseWriter) error { +func (response GetEnvironments404JSONResponse) VisitGetEnvironmentsResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(404) return json.NewEncoder(w).Encode(response) } -type DeleteDevProjectsProjectKeyOverridesFlagKeyRequestObject struct { +type DeleteFlagOverrideRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` FlagKey FlagKey `json:"flagKey"` } -type DeleteDevProjectsProjectKeyOverridesFlagKeyResponseObject interface { - VisitDeleteDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error +type DeleteFlagOverrideResponseObject interface { + VisitDeleteFlagOverrideResponse(w http.ResponseWriter) error } -type DeleteDevProjectsProjectKeyOverridesFlagKey204Response struct { +type DeleteFlagOverride204Response struct { } -func (response DeleteDevProjectsProjectKeyOverridesFlagKey204Response) VisitDeleteDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error { +func (response DeleteFlagOverride204Response) VisitDeleteFlagOverrideResponse(w http.ResponseWriter) error { w.WriteHeader(204) return nil } -type DeleteDevProjectsProjectKeyOverridesFlagKey404Response struct { +type DeleteFlagOverride404Response struct { } -func (response DeleteDevProjectsProjectKeyOverridesFlagKey404Response) VisitDeleteDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error { +func (response DeleteFlagOverride404Response) VisitDeleteFlagOverrideResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } -type PutDevProjectsProjectKeyOverridesFlagKeyRequestObject struct { +type PutOverrideFlagRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` FlagKey FlagKey `json:"flagKey"` - Body *PutDevProjectsProjectKeyOverridesFlagKeyJSONRequestBody + Body *PutOverrideFlagJSONRequestBody } -type PutDevProjectsProjectKeyOverridesFlagKeyResponseObject interface { - VisitPutDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error +type PutOverrideFlagResponseObject interface { + VisitPutOverrideFlagResponse(w http.ResponseWriter) error } -type PutDevProjectsProjectKeyOverridesFlagKey200JSONResponse struct{ FlagOverrideJSONResponse } +type PutOverrideFlag200JSONResponse struct{ FlagOverrideJSONResponse } -func (response PutDevProjectsProjectKeyOverridesFlagKey200JSONResponse) VisitPutDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error { +func (response PutOverrideFlag200JSONResponse) VisitPutOverrideFlagResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type PutDevProjectsProjectKeyOverridesFlagKey400JSONResponse struct{ ErrorResponseJSONResponse } +type PutOverrideFlag400JSONResponse struct{ ErrorResponseJSONResponse } -func (response PutDevProjectsProjectKeyOverridesFlagKey400JSONResponse) VisitPutDevProjectsProjectKeyOverridesFlagKeyResponse(w http.ResponseWriter) error { +func (response PutOverrideFlag400JSONResponse) VisitPutOverrideFlagResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(400) return json.NewEncoder(w).Encode(response) } -type PatchDevProjectsProjectKeySyncRequestObject struct { +type PatchSyncProjectRequestObject struct { ProjectKey ProjectKey `json:"projectKey"` - Params PatchDevProjectsProjectKeySyncParams + Params PatchSyncProjectParams } -type PatchDevProjectsProjectKeySyncResponseObject interface { - VisitPatchDevProjectsProjectKeySyncResponse(w http.ResponseWriter) error +type PatchSyncProjectResponseObject interface { + VisitPatchSyncProjectResponse(w http.ResponseWriter) error } -type PatchDevProjectsProjectKeySync200JSONResponse struct{ ProjectJSONResponse } +type PatchSyncProject200JSONResponse struct{ ProjectJSONResponse } -func (response PatchDevProjectsProjectKeySync200JSONResponse) VisitPatchDevProjectsProjectKeySyncResponse(w http.ResponseWriter) error { +func (response PatchSyncProject200JSONResponse) VisitPatchSyncProjectResponse(w http.ResponseWriter) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) return json.NewEncoder(w).Encode(response) } -type PatchDevProjectsProjectKeySync404Response struct { +type PatchSyncProject404Response struct { } -func (response PatchDevProjectsProjectKeySync404Response) VisitPatchDevProjectsProjectKeySyncResponse(w http.ResponseWriter) error { +func (response PatchSyncProject404Response) VisitPatchSyncProjectResponse(w http.ResponseWriter) error { w.WriteHeader(404) return nil } @@ -912,31 +912,31 @@ func (response PatchDevProjectsProjectKeySync404Response) VisitPatchDevProjectsP type StrictServerInterface interface { // lists all projects that have been configured for the dev server // (GET /dev/projects) - GetDevProjects(ctx context.Context, request GetDevProjectsRequestObject) (GetDevProjectsResponseObject, error) + GetProjects(ctx context.Context, request GetProjectsRequestObject) (GetProjectsResponseObject, error) // remove the specified project from the dev server // (DELETE /dev/projects/{projectKey}) - DeleteDevProjectsProjectKey(ctx context.Context, request DeleteDevProjectsProjectKeyRequestObject) (DeleteDevProjectsProjectKeyResponseObject, error) + DeleteProject(ctx context.Context, request DeleteProjectRequestObject) (DeleteProjectResponseObject, error) // get the specified project and its configuration for syncing from the LaunchDarkly Service // (GET /dev/projects/{projectKey}) - GetDevProjectsProjectKey(ctx context.Context, request GetDevProjectsProjectKeyRequestObject) (GetDevProjectsProjectKeyResponseObject, error) + GetProject(ctx context.Context, request GetProjectRequestObject) (GetProjectResponseObject, error) // updates the project context or sourceEnvironmentKey // (PATCH /dev/projects/{projectKey}) - PatchDevProjectsProjectKey(ctx context.Context, request PatchDevProjectsProjectKeyRequestObject) (PatchDevProjectsProjectKeyResponseObject, error) + PatchProject(ctx context.Context, request PatchProjectRequestObject) (PatchProjectResponseObject, error) // Add the project to the dev server // (POST /dev/projects/{projectKey}) - PostDevProjectsProjectKey(ctx context.Context, request PostDevProjectsProjectKeyRequestObject) (PostDevProjectsProjectKeyResponseObject, error) + PostAddProject(ctx context.Context, request PostAddProjectRequestObject) (PostAddProjectResponseObject, error) // list all environments for the given project // (GET /dev/projects/{projectKey}/environments) - GetProjectsEnvironments(ctx context.Context, request GetProjectsEnvironmentsRequestObject) (GetProjectsEnvironmentsResponseObject, error) + GetEnvironments(ctx context.Context, request GetEnvironmentsRequestObject) (GetEnvironmentsResponseObject, error) // remove override for flag // (DELETE /dev/projects/{projectKey}/overrides/{flagKey}) - DeleteDevProjectsProjectKeyOverridesFlagKey(ctx context.Context, request DeleteDevProjectsProjectKeyOverridesFlagKeyRequestObject) (DeleteDevProjectsProjectKeyOverridesFlagKeyResponseObject, error) + DeleteFlagOverride(ctx context.Context, request DeleteFlagOverrideRequestObject) (DeleteFlagOverrideResponseObject, error) // override flag value with value provided in the body // (PUT /dev/projects/{projectKey}/overrides/{flagKey}) - PutDevProjectsProjectKeyOverridesFlagKey(ctx context.Context, request PutDevProjectsProjectKeyOverridesFlagKeyRequestObject) (PutDevProjectsProjectKeyOverridesFlagKeyResponseObject, error) + PutOverrideFlag(ctx context.Context, request PutOverrideFlagRequestObject) (PutOverrideFlagResponseObject, error) // updates the flag state for the given project and source environment // (PATCH /dev/projects/{projectKey}/sync) - PatchDevProjectsProjectKeySync(ctx context.Context, request PatchDevProjectsProjectKeySyncRequestObject) (PatchDevProjectsProjectKeySyncResponseObject, error) + PatchSyncProject(ctx context.Context, request PatchSyncProjectRequestObject) (PatchSyncProjectResponseObject, error) } type StrictHandlerFunc = strictnethttp.StrictHTTPHandlerFunc @@ -968,23 +968,23 @@ type strictHandler struct { options StrictHTTPServerOptions } -// GetDevProjects operation middleware -func (sh *strictHandler) GetDevProjects(w http.ResponseWriter, r *http.Request) { - var request GetDevProjectsRequestObject +// GetProjects operation middleware +func (sh *strictHandler) GetProjects(w http.ResponseWriter, r *http.Request) { + var request GetProjectsRequestObject handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.GetDevProjects(ctx, request.(GetDevProjectsRequestObject)) + return sh.ssi.GetProjects(ctx, request.(GetProjectsRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "GetDevProjects") + handler = middleware(handler, "GetProjects") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(GetDevProjectsResponseObject); ok { - if err := validResponse.VisitGetDevProjectsResponse(w); err != nil { + } else if validResponse, ok := response.(GetProjectsResponseObject); ok { + if err := validResponse.VisitGetProjectsResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -992,25 +992,25 @@ func (sh *strictHandler) GetDevProjects(w http.ResponseWriter, r *http.Request) } } -// DeleteDevProjectsProjectKey operation middleware -func (sh *strictHandler) DeleteDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) { - var request DeleteDevProjectsProjectKeyRequestObject +// DeleteProject operation middleware +func (sh *strictHandler) DeleteProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) { + var request DeleteProjectRequestObject request.ProjectKey = projectKey handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.DeleteDevProjectsProjectKey(ctx, request.(DeleteDevProjectsProjectKeyRequestObject)) + return sh.ssi.DeleteProject(ctx, request.(DeleteProjectRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "DeleteDevProjectsProjectKey") + handler = middleware(handler, "DeleteProject") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(DeleteDevProjectsProjectKeyResponseObject); ok { - if err := validResponse.VisitDeleteDevProjectsProjectKeyResponse(w); err != nil { + } else if validResponse, ok := response.(DeleteProjectResponseObject); ok { + if err := validResponse.VisitDeleteProjectResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1018,26 +1018,26 @@ func (sh *strictHandler) DeleteDevProjectsProjectKey(w http.ResponseWriter, r *h } } -// GetDevProjectsProjectKey operation middleware -func (sh *strictHandler) GetDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params GetDevProjectsProjectKeyParams) { - var request GetDevProjectsProjectKeyRequestObject +// GetProject operation middleware +func (sh *strictHandler) GetProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params GetProjectParams) { + var request GetProjectRequestObject request.ProjectKey = projectKey request.Params = params handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.GetDevProjectsProjectKey(ctx, request.(GetDevProjectsProjectKeyRequestObject)) + return sh.ssi.GetProject(ctx, request.(GetProjectRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "GetDevProjectsProjectKey") + handler = middleware(handler, "GetProject") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(GetDevProjectsProjectKeyResponseObject); ok { - if err := validResponse.VisitGetDevProjectsProjectKeyResponse(w); err != nil { + } else if validResponse, ok := response.(GetProjectResponseObject); ok { + if err := validResponse.VisitGetProjectResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1045,14 +1045,14 @@ func (sh *strictHandler) GetDevProjectsProjectKey(w http.ResponseWriter, r *http } } -// PatchDevProjectsProjectKey operation middleware -func (sh *strictHandler) PatchDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchDevProjectsProjectKeyParams) { - var request PatchDevProjectsProjectKeyRequestObject +// PatchProject operation middleware +func (sh *strictHandler) PatchProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchProjectParams) { + var request PatchProjectRequestObject request.ProjectKey = projectKey request.Params = params - var body PatchDevProjectsProjectKeyJSONRequestBody + var body PatchProjectJSONRequestBody if err := json.NewDecoder(r.Body).Decode(&body); err != nil { sh.options.RequestErrorHandlerFunc(w, r, fmt.Errorf("can't decode JSON body: %w", err)) return @@ -1060,18 +1060,18 @@ func (sh *strictHandler) PatchDevProjectsProjectKey(w http.ResponseWriter, r *ht request.Body = &body handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.PatchDevProjectsProjectKey(ctx, request.(PatchDevProjectsProjectKeyRequestObject)) + return sh.ssi.PatchProject(ctx, request.(PatchProjectRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PatchDevProjectsProjectKey") + handler = middleware(handler, "PatchProject") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(PatchDevProjectsProjectKeyResponseObject); ok { - if err := validResponse.VisitPatchDevProjectsProjectKeyResponse(w); err != nil { + } else if validResponse, ok := response.(PatchProjectResponseObject); ok { + if err := validResponse.VisitPatchProjectResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1079,14 +1079,14 @@ func (sh *strictHandler) PatchDevProjectsProjectKey(w http.ResponseWriter, r *ht } } -// PostDevProjectsProjectKey operation middleware -func (sh *strictHandler) PostDevProjectsProjectKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PostDevProjectsProjectKeyParams) { - var request PostDevProjectsProjectKeyRequestObject +// PostAddProject operation middleware +func (sh *strictHandler) PostAddProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PostAddProjectParams) { + var request PostAddProjectRequestObject request.ProjectKey = projectKey request.Params = params - var body PostDevProjectsProjectKeyJSONRequestBody + var body PostAddProjectJSONRequestBody if err := json.NewDecoder(r.Body).Decode(&body); err != nil { sh.options.RequestErrorHandlerFunc(w, r, fmt.Errorf("can't decode JSON body: %w", err)) return @@ -1094,18 +1094,18 @@ func (sh *strictHandler) PostDevProjectsProjectKey(w http.ResponseWriter, r *htt request.Body = &body handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.PostDevProjectsProjectKey(ctx, request.(PostDevProjectsProjectKeyRequestObject)) + return sh.ssi.PostAddProject(ctx, request.(PostAddProjectRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PostDevProjectsProjectKey") + handler = middleware(handler, "PostAddProject") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(PostDevProjectsProjectKeyResponseObject); ok { - if err := validResponse.VisitPostDevProjectsProjectKeyResponse(w); err != nil { + } else if validResponse, ok := response.(PostAddProjectResponseObject); ok { + if err := validResponse.VisitPostAddProjectResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1113,25 +1113,25 @@ func (sh *strictHandler) PostDevProjectsProjectKey(w http.ResponseWriter, r *htt } } -// GetProjectsEnvironments operation middleware -func (sh *strictHandler) GetProjectsEnvironments(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) { - var request GetProjectsEnvironmentsRequestObject +// GetEnvironments operation middleware +func (sh *strictHandler) GetEnvironments(w http.ResponseWriter, r *http.Request, projectKey ProjectKey) { + var request GetEnvironmentsRequestObject request.ProjectKey = projectKey handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.GetProjectsEnvironments(ctx, request.(GetProjectsEnvironmentsRequestObject)) + return sh.ssi.GetEnvironments(ctx, request.(GetEnvironmentsRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "GetProjectsEnvironments") + handler = middleware(handler, "GetEnvironments") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(GetProjectsEnvironmentsResponseObject); ok { - if err := validResponse.VisitGetProjectsEnvironmentsResponse(w); err != nil { + } else if validResponse, ok := response.(GetEnvironmentsResponseObject); ok { + if err := validResponse.VisitGetEnvironmentsResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1139,26 +1139,26 @@ func (sh *strictHandler) GetProjectsEnvironments(w http.ResponseWriter, r *http. } } -// DeleteDevProjectsProjectKeyOverridesFlagKey operation middleware -func (sh *strictHandler) DeleteDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) { - var request DeleteDevProjectsProjectKeyOverridesFlagKeyRequestObject +// DeleteFlagOverride operation middleware +func (sh *strictHandler) DeleteFlagOverride(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) { + var request DeleteFlagOverrideRequestObject request.ProjectKey = projectKey request.FlagKey = flagKey handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.DeleteDevProjectsProjectKeyOverridesFlagKey(ctx, request.(DeleteDevProjectsProjectKeyOverridesFlagKeyRequestObject)) + return sh.ssi.DeleteFlagOverride(ctx, request.(DeleteFlagOverrideRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "DeleteDevProjectsProjectKeyOverridesFlagKey") + handler = middleware(handler, "DeleteFlagOverride") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(DeleteDevProjectsProjectKeyOverridesFlagKeyResponseObject); ok { - if err := validResponse.VisitDeleteDevProjectsProjectKeyOverridesFlagKeyResponse(w); err != nil { + } else if validResponse, ok := response.(DeleteFlagOverrideResponseObject); ok { + if err := validResponse.VisitDeleteFlagOverrideResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1166,14 +1166,14 @@ func (sh *strictHandler) DeleteDevProjectsProjectKeyOverridesFlagKey(w http.Resp } } -// PutDevProjectsProjectKeyOverridesFlagKey operation middleware -func (sh *strictHandler) PutDevProjectsProjectKeyOverridesFlagKey(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) { - var request PutDevProjectsProjectKeyOverridesFlagKeyRequestObject +// PutOverrideFlag operation middleware +func (sh *strictHandler) PutOverrideFlag(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, flagKey FlagKey) { + var request PutOverrideFlagRequestObject request.ProjectKey = projectKey request.FlagKey = flagKey - var body PutDevProjectsProjectKeyOverridesFlagKeyJSONRequestBody + var body PutOverrideFlagJSONRequestBody if err := json.NewDecoder(r.Body).Decode(&body); err != nil { sh.options.RequestErrorHandlerFunc(w, r, fmt.Errorf("can't decode JSON body: %w", err)) return @@ -1181,18 +1181,18 @@ func (sh *strictHandler) PutDevProjectsProjectKeyOverridesFlagKey(w http.Respons request.Body = &body handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.PutDevProjectsProjectKeyOverridesFlagKey(ctx, request.(PutDevProjectsProjectKeyOverridesFlagKeyRequestObject)) + return sh.ssi.PutOverrideFlag(ctx, request.(PutOverrideFlagRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PutDevProjectsProjectKeyOverridesFlagKey") + handler = middleware(handler, "PutOverrideFlag") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(PutDevProjectsProjectKeyOverridesFlagKeyResponseObject); ok { - if err := validResponse.VisitPutDevProjectsProjectKeyOverridesFlagKeyResponse(w); err != nil { + } else if validResponse, ok := response.(PutOverrideFlagResponseObject); ok { + if err := validResponse.VisitPutOverrideFlagResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { @@ -1200,26 +1200,26 @@ func (sh *strictHandler) PutDevProjectsProjectKeyOverridesFlagKey(w http.Respons } } -// PatchDevProjectsProjectKeySync operation middleware -func (sh *strictHandler) PatchDevProjectsProjectKeySync(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchDevProjectsProjectKeySyncParams) { - var request PatchDevProjectsProjectKeySyncRequestObject +// PatchSyncProject operation middleware +func (sh *strictHandler) PatchSyncProject(w http.ResponseWriter, r *http.Request, projectKey ProjectKey, params PatchSyncProjectParams) { + var request PatchSyncProjectRequestObject request.ProjectKey = projectKey request.Params = params handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) { - return sh.ssi.PatchDevProjectsProjectKeySync(ctx, request.(PatchDevProjectsProjectKeySyncRequestObject)) + return sh.ssi.PatchSyncProject(ctx, request.(PatchSyncProjectRequestObject)) } for _, middleware := range sh.middlewares { - handler = middleware(handler, "PatchDevProjectsProjectKeySync") + handler = middleware(handler, "PatchSyncProject") } response, err := handler(r.Context(), w, r, request) if err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) - } else if validResponse, ok := response.(PatchDevProjectsProjectKeySyncResponseObject); ok { - if err := validResponse.VisitPatchDevProjectsProjectKeySyncResponse(w); err != nil { + } else if validResponse, ok := response.(PatchSyncProjectResponseObject); ok { + if err := validResponse.VisitPatchSyncProjectResponse(w); err != nil { sh.options.ResponseErrorHandlerFunc(w, r, err) } } else if response != nil { diff --git a/internal/dev_server/api/server.go b/internal/dev_server/api/server.go index 16d4d783..9dd8811f 100644 --- a/internal/dev_server/api/server.go +++ b/internal/dev_server/api/server.go @@ -1,12 +1,5 @@ package api -import ( - "context" - "errors" - - "github.com/launchdarkly/ldcli/internal/dev_server/model" -) - //go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config oapi-codegen-cfg.yaml api.yaml var _ StrictServerInterface = server{} @@ -16,314 +9,3 @@ type server struct { func NewStrictServer() StrictServerInterface { return server{} } - -func (s server) GetDevProjects(ctx context.Context, request GetDevProjectsRequestObject) (GetDevProjectsResponseObject, error) { - store := model.StoreFromContext(ctx) - projectKeys, err := store.GetDevProjectKeys(ctx) - if err != nil { - return nil, err - } - if projectKeys == nil { - projectKeys = make([]string, 0) // HACK to make the json behavior compatible with go. - } - return GetDevProjects200JSONResponse(projectKeys), nil -} - -func (s server) DeleteDevProjectsProjectKey(ctx context.Context, request DeleteDevProjectsProjectKeyRequestObject) (DeleteDevProjectsProjectKeyResponseObject, error) { - store := model.StoreFromContext(ctx) - deleted, err := store.DeleteDevProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - if !deleted { - return DeleteDevProjectsProjectKey404JSONResponse{ErrorResponseJSONResponse{ - Code: "not_found", - Message: "project not found", - }}, nil - } - return DeleteDevProjectsProjectKey204Response{}, nil -} - -func (s server) GetDevProjectsProjectKey(ctx context.Context, request GetDevProjectsProjectKeyRequestObject) (GetDevProjectsProjectKeyResponseObject, error) { - store := model.StoreFromContext(ctx) - project, err := store.GetDevProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - if project == nil { - return GetDevProjectsProjectKey404Response{}, nil - } - - response := ProjectJSONResponse{ - LastSyncedFromSource: project.LastSyncTime.Unix(), - Context: project.Context, - SourceEnvironmentKey: project.SourceEnvironmentKey, - FlagsState: &project.AllFlagsState, - } - - if request.Params.Expand != nil { - for _, item := range *request.Params.Expand { - if item == "overrides" { - overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respOverrides := make(model.FlagsState) - for _, override := range overrides { - if !override.Active { - continue - } - respOverrides[override.FlagKey] = model.FlagState{ - Value: override.Value, - Version: override.Version, - } - } - response.Overrides = &respOverrides - } - if item == "availableVariations" { - availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respAvailableVariations := availableVariationsToResponseFormat(availableVariations) - response.AvailableVariations = &respAvailableVariations - } - } - - } - - return GetDevProjectsProjectKey200JSONResponse{ - response, - }, nil -} - -func (s server) PostDevProjectsProjectKey(ctx context.Context, request PostDevProjectsProjectKeyRequestObject) (PostDevProjectsProjectKeyResponseObject, error) { - if request.Body.SourceEnvironmentKey == "" { - return PostDevProjectsProjectKey400JSONResponse{ - ErrorResponseJSONResponse{ - Code: "invalid_request", - Message: "sourceEnvironmentKey is required", - }, - }, nil - } - - store := model.StoreFromContext(ctx) - project, err := model.CreateProject(ctx, request.ProjectKey, request.Body.SourceEnvironmentKey, request.Body.Context) - switch { - case errors.Is(err, model.ErrAlreadyExists): - return PostDevProjectsProjectKey409JSONResponse{ - Code: "conflict", - Message: "project already exists", - }, nil - case err != nil: - return nil, err - } - - response := ProjectJSONResponse{ - LastSyncedFromSource: project.LastSyncTime.Unix(), - Context: project.Context, - SourceEnvironmentKey: project.SourceEnvironmentKey, - FlagsState: &project.AllFlagsState, - } - - if request.Params.Expand != nil { - for _, item := range *request.Params.Expand { - if item == "overrides" { - overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respOverrides := make(model.FlagsState) - for _, override := range overrides { - if !override.Active { - continue - } - respOverrides[override.FlagKey] = model.FlagState{ - Value: override.Value, - Version: override.Version, - } - } - response.Overrides = &respOverrides - } - if item == "availableVariations" { - availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respAvailableVariations := availableVariationsToResponseFormat(availableVariations) - response.AvailableVariations = &respAvailableVariations - } - } - - } - - return PostDevProjectsProjectKey201JSONResponse{ - response, - }, nil -} - -func (s server) PatchDevProjectsProjectKey(ctx context.Context, request PatchDevProjectsProjectKeyRequestObject) (PatchDevProjectsProjectKeyResponseObject, error) { - store := model.StoreFromContext(ctx) - project, err := model.UpdateProject(ctx, request.ProjectKey, request.Body.Context, request.Body.SourceEnvironmentKey) - if err != nil { - return nil, err - } - if project.Key == "" && project.SourceEnvironmentKey == "" { - return PatchDevProjectsProjectKey404Response{}, nil - } - - response := ProjectJSONResponse{ - LastSyncedFromSource: project.LastSyncTime.Unix(), - Context: project.Context, - SourceEnvironmentKey: project.SourceEnvironmentKey, - FlagsState: &project.AllFlagsState, - } - - if request.Params.Expand != nil { - for _, item := range *request.Params.Expand { - if item == "overrides" { - overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respOverrides := make(model.FlagsState) - for _, override := range overrides { - if !override.Active { - continue - } - respOverrides[override.FlagKey] = model.FlagState{ - Value: override.Value, - Version: override.Version, - } - } - response.Overrides = &respOverrides - } - if item == "availableVariations" { - availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respAvailableVariations := availableVariationsToResponseFormat(availableVariations) - response.AvailableVariations = &respAvailableVariations - } - } - - } - - return PatchDevProjectsProjectKey200JSONResponse{ - response, - }, nil -} - -func (s server) PatchDevProjectsProjectKeySync(ctx context.Context, request PatchDevProjectsProjectKeySyncRequestObject) (PatchDevProjectsProjectKeySyncResponseObject, error) { - store := model.StoreFromContext(ctx) - project, err := model.UpdateProject(ctx, request.ProjectKey, nil, nil) - if err != nil { - return nil, err - } - if project.Key == "" && project.SourceEnvironmentKey == "" { - return PatchDevProjectsProjectKeySync404Response{}, nil - } - - response := ProjectJSONResponse{ - LastSyncedFromSource: project.LastSyncTime.Unix(), - Context: project.Context, - SourceEnvironmentKey: project.SourceEnvironmentKey, - FlagsState: &project.AllFlagsState, - } - - if request.Params.Expand != nil { - for _, item := range *request.Params.Expand { - if item == "overrides" { - overrides, err := store.GetOverridesForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respOverrides := make(model.FlagsState) - for _, override := range overrides { - if !override.Active { - continue - } - respOverrides[override.FlagKey] = model.FlagState{ - Value: override.Value, - Version: override.Version, - } - } - response.Overrides = &respOverrides - } - if item == "availableVariations" { - availableVariations, err := store.GetAvailableVariationsForProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - respAvailableVariations := availableVariationsToResponseFormat(availableVariations) - response.AvailableVariations = &respAvailableVariations - } - } - - } - - return PatchDevProjectsProjectKeySync200JSONResponse{ - response, - }, nil -} - -func (s server) DeleteDevProjectsProjectKeyOverridesFlagKey(ctx context.Context, request DeleteDevProjectsProjectKeyOverridesFlagKeyRequestObject) (DeleteDevProjectsProjectKeyOverridesFlagKeyResponseObject, error) { - store := model.StoreFromContext(ctx) - err := store.DeactivateOverride(ctx, request.ProjectKey, request.FlagKey) - if err != nil { - if errors.Is(err, model.ErrNotFound) { - return DeleteDevProjectsProjectKeyOverridesFlagKey404Response{}, nil - } - return nil, err - } - return DeleteDevProjectsProjectKeyOverridesFlagKey204Response{}, nil -} - -func (s server) PutDevProjectsProjectKeyOverridesFlagKey(ctx context.Context, request PutDevProjectsProjectKeyOverridesFlagKeyRequestObject) (PutDevProjectsProjectKeyOverridesFlagKeyResponseObject, error) { - if request.Body == nil { - return nil, errors.New("empty override body") - } - override, err := model.UpsertOverride(ctx, request.ProjectKey, request.FlagKey, *request.Body) - if err != nil { - if errors.As(err, &model.Error{}) { - return PutDevProjectsProjectKeyOverridesFlagKey400JSONResponse{ - ErrorResponseJSONResponse{ - Code: "invalid_request", - Message: err.Error(), - }, - }, nil - } - return nil, err - } - return PutDevProjectsProjectKeyOverridesFlagKey200JSONResponse{FlagOverrideJSONResponse{ - Override: override.Active, - Value: override.Value, - }}, nil -} - -func (s server) GetProjectsEnvironments(ctx context.Context, request GetProjectsEnvironmentsRequestObject) (GetProjectsEnvironmentsResponseObject, error) { - store := model.StoreFromContext(ctx) - project, err := store.GetDevProject(ctx, request.ProjectKey) - if err != nil { - return nil, err - } - if project == nil { - return GetProjectsEnvironments404JSONResponse{}, nil - } - - environments, err := model.GetEnvironmentsForProject(ctx, project.Key) - if err != nil { - return nil, err - } - - var envReps []Environment - for _, env := range environments { - envReps = append(envReps, Environment{ - Key: env.Key, - Name: env.Name, - }) - } - - return GetProjectsEnvironments200JSONResponse(envReps), nil -}