diff --git a/api/api.yml b/api/api.yml index a54298c..85a5550 100644 --- a/api/api.yml +++ b/api/api.yml @@ -15,18 +15,18 @@ paths: - Liveness summary: Get system health status responses: - '200': + "200": description: System is healthy content: application/json: schema: - $ref: '#/components/schemas/HealthResponse' - '500': + $ref: "#/components/schemas/HealthResponse" + "500": description: System is down content: application/json: schema: - $ref: '#/components/schemas/HealthResponse' + $ref: "#/components/schemas/HealthResponse" /_ready: get: @@ -34,18 +34,157 @@ paths: - Readiness summary: Get system readiness responses: - '200': + "200": description: System is ready to accept traffic content: application/json: schema: - $ref: '#/components/schemas/HealthResponse' - '500': + $ref: "#/components/schemas/HealthResponse" + "500": description: System not ready to accept traffic content: application/json: schema: - $ref: '#/components/schemas/HealthResponse' + $ref: "#/components/schemas/HealthResponse" + + /client/{teamId}/{projectId}/{environmentId}/lock: + post: + tags: + - Environments + summary: Lock the state of Terraform environment + operationId: lockEnvironment + parameters: + - $ref: "#/components/parameters/teamId" + - $ref: "#/components/parameters/projectId" + - $ref: "#/components/parameters/environmentId" + security: + - basic_auth: [] # Use basic auth to lock the environment + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/LockInfo" + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/LockInfo" + "404": + description: Resource not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + + /client/{teamId}/{projectId}/{environmentId}/unlock: + post: + tags: + - Environments + summary: Unlock the state of Terraform environment + operationId: unlockEnvironment + parameters: + - $ref: "#/components/parameters/teamId" + - $ref: "#/components/parameters/projectId" + - $ref: "#/components/parameters/environmentId" + security: + - basic_auth: [] # Use basic auth to unlock the environment + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/LockInfo" + responses: + "200": + description: Successful response + "204": + description: Successful response + "404": + description: Resource not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + + /client/{teamId}/{projectId}/{environmentId}/state: + get: + tags: + - Environments + summary: Get the state of Terraform environment + operationId: getEnvironmentState + parameters: + - $ref: "#/components/parameters/teamId" + - $ref: "#/components/parameters/projectId" + - $ref: "#/components/parameters/environmentId" + security: + - basic_auth: [] # Use basic auth to get the environment state + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/Payload" + "404": + description: Resource not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + post: + tags: + - Environments + summary: Update the state of Terraform environment + operationId: updateEnvironmentState + parameters: + - $ref: "#/components/parameters/teamId" + - $ref: "#/components/parameters/projectId" + - $ref: "#/components/parameters/environmentId" + security: + - basic_auth: [] # Use basic auth to update the environment state + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Payload" + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/Payload" + "404": + description: Resource not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" /api/v1/user: get: @@ -66,7 +205,7 @@ paths: type: integer default: 0 responses: - '200': + "200": description: Successful response content: application/json: @@ -76,7 +215,7 @@ paths: users: type: array items: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" metadata: type: object properties: @@ -86,12 +225,12 @@ paths: type: integer totalCount: type: integer - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" post: tags: @@ -103,20 +242,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UserCreate' + $ref: "#/components/schemas/UserCreate" responses: - '201': + "201": description: User created content: application/json: schema: - $ref: '#/components/schemas/User' - '500': + $ref: "#/components/schemas/User" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/user/{id}: get: @@ -132,24 +271,24 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/User' - '404': + $ref: "#/components/schemas/User" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" put: tags: @@ -167,26 +306,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UserUpdate' + $ref: "#/components/schemas/UserUpdate" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/User' - '404': + $ref: "#/components/schemas/User" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" delete: tags: @@ -201,20 +340,20 @@ paths: schema: type: string responses: - '204': + "204": description: Successful response - '404': + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/team: post: @@ -227,20 +366,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TeamCreate' + $ref: "#/components/schemas/TeamCreate" responses: - '201': + "201": description: Team created content: application/json: schema: - $ref: '#/components/schemas/Team' - '500': + $ref: "#/components/schemas/Team" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" get: tags: @@ -260,7 +399,7 @@ paths: type: integer default: 0 responses: - '200': + "200": description: Successful response content: application/json: @@ -270,7 +409,7 @@ paths: teams: type: array items: - $ref: '#/components/schemas/Team' + $ref: "#/components/schemas/Team" metadata: type: object properties: @@ -280,12 +419,12 @@ paths: type: integer totalCount: type: integer - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/team/{id}: get: @@ -301,24 +440,24 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Team' - '404': + $ref: "#/components/schemas/Team" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" put: tags: @@ -336,26 +475,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TeamUpdate' + $ref: "#/components/schemas/TeamUpdate" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Team' - '404': + $ref: "#/components/schemas/Team" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" delete: tags: @@ -370,20 +509,20 @@ paths: schema: type: string responses: - '204': + "204": description: Successful response - '404': + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/project: post: @@ -396,20 +535,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ProjectCreate' + $ref: "#/components/schemas/ProjectCreate" responses: - '201': + "201": description: Project created content: application/json: schema: - $ref: '#/components/schemas/Project' - '500': + $ref: "#/components/schemas/Project" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" get: tags: @@ -429,7 +568,7 @@ paths: type: integer default: 0 responses: - '200': + "200": description: Successful response content: application/json: @@ -439,7 +578,7 @@ paths: projects: type: array items: - $ref: '#/components/schemas/Project' + $ref: "#/components/schemas/Project" metadata: type: object properties: @@ -449,12 +588,12 @@ paths: type: integer totalCount: type: integer - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/project/{id}: get: @@ -470,24 +609,24 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Project' - '404': + $ref: "#/components/schemas/Project" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" put: tags: @@ -505,26 +644,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ProjectUpdate' + $ref: "#/components/schemas/ProjectUpdate" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Project' - '404': + $ref: "#/components/schemas/Project" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" delete: tags: @@ -539,21 +678,20 @@ paths: schema: type: string responses: - '204': + "204": description: Successful response - '404': + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - + $ref: "#/components/schemas/ErrorResponse" /api/v1/project/{projectId}/environment: post: @@ -572,20 +710,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/EnvironmentCreate' + $ref: "#/components/schemas/EnvironmentCreate" responses: - '201': + "201": description: Environment created content: application/json: schema: - $ref: '#/components/schemas/Environment' - '500': + $ref: "#/components/schemas/Environment" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" get: tags: @@ -610,7 +748,7 @@ paths: type: integer default: 0 responses: - '200': + "200": description: Successful response content: application/json: @@ -620,7 +758,7 @@ paths: environments: type: array items: - $ref: '#/components/schemas/Environment' + $ref: "#/components/schemas/Environment" metadata: type: object properties: @@ -630,12 +768,12 @@ paths: type: integer totalCount: type: integer - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/project/{projectId}/environment/{environmentId}: get: @@ -656,24 +794,24 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Environment' - '404': + $ref: "#/components/schemas/Environment" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" put: tags: @@ -696,26 +834,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/EnvironmentUpdate' + $ref: "#/components/schemas/EnvironmentUpdate" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Environment' - '404': + $ref: "#/components/schemas/Environment" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" delete: tags: @@ -735,20 +873,20 @@ paths: schema: type: string responses: - '204': + "204": description: Successful response - '404': + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/snapshot: post: @@ -761,20 +899,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SnapshotCreate' + $ref: "#/components/schemas/SnapshotCreate" responses: - '201': + "201": description: Snapshot created content: application/json: schema: - $ref: '#/components/schemas/Snapshot' - '500': + $ref: "#/components/schemas/Snapshot" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" get: tags: @@ -794,7 +932,7 @@ paths: type: integer default: 0 responses: - '200': + "200": description: Successful response content: application/json: @@ -804,7 +942,7 @@ paths: snapshots: type: array items: - $ref: '#/components/schemas/Snapshot' + $ref: "#/components/schemas/Snapshot" metadata: type: object properties: @@ -814,12 +952,12 @@ paths: type: integer totalCount: type: integer - '500': + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/snapshot/{id}: get: @@ -835,24 +973,24 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Snapshot' - '404': + $ref: "#/components/schemas/Snapshot" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" put: tags: @@ -870,26 +1008,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SnapshotUpdate' + $ref: "#/components/schemas/SnapshotUpdate" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Snapshot' - '404': + $ref: "#/components/schemas/Snapshot" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" delete: tags: @@ -904,20 +1042,20 @@ paths: schema: type: string responses: - '204': + "204": description: Successful response - '404': + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" /api/v1/task/{id}: get: @@ -933,27 +1071,66 @@ paths: schema: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/Task' - '404': + $ref: "#/components/schemas/Task" + "404": description: Resource not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - '500': + $ref: "#/components/schemas/ErrorResponse" + "500": description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" components: + parameters: + teamId: + name: teamId + in: path + required: true + schema: + type: string + projectId: + name: projectId + in: path + required: true + schema: + type: string + environmentId: + name: environmentId + in: path + required: true + schema: + type: string + schemas: + LockInfo: + type: object + properties: + id: + type: string + operation: + type: string + info: + type: string + who: + type: string + version: + type: string + created: + type: string + format: date-time + path: + type: string + HealthResponse: type: object properties: @@ -1242,8 +1419,15 @@ components: errorMessage: type: string + Payload: + type: string + format: binary + securitySchemes: api_key: type: apiKey in: header - name: x-api-key \ No newline at end of file + name: x-api-key + basic_auth: + type: http + scheme: basic diff --git a/pkg/apis/client.gen.go b/pkg/apis/client.gen.go index b84c28a..3f07f95 100644 --- a/pkg/apis/client.gen.go +++ b/pkg/apis/client.gen.go @@ -192,6 +192,24 @@ type ClientInterface interface { PutApiV1UserIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) PutApiV1UserId(ctx context.Context, id string, body PutApiV1UserIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LockEnvironmentWithBody request with any body + LockEnvironmentWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + LockEnvironment(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body LockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetEnvironmentState request + GetEnvironmentState(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateEnvironmentStateWithBody request with any body + UpdateEnvironmentStateWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateEnvironmentState(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UpdateEnvironmentStateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UnlockEnvironmentWithBody request with any body + UnlockEnvironmentWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UnlockEnvironment(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UnlockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -650,6 +668,90 @@ func (c *Client) PutApiV1UserId(ctx context.Context, id string, body PutApiV1Use return c.Client.Do(req) } +func (c *Client) LockEnvironmentWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLockEnvironmentRequestWithBody(c.Server, teamId, projectId, environmentId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LockEnvironment(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body LockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLockEnvironmentRequest(c.Server, teamId, projectId, environmentId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetEnvironmentState(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetEnvironmentStateRequest(c.Server, teamId, projectId, environmentId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateEnvironmentStateWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateEnvironmentStateRequestWithBody(c.Server, teamId, projectId, environmentId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateEnvironmentState(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UpdateEnvironmentStateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateEnvironmentStateRequest(c.Server, teamId, projectId, environmentId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UnlockEnvironmentWithBody(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUnlockEnvironmentRequestWithBody(c.Server, teamId, projectId, environmentId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UnlockEnvironment(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UnlockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUnlockEnvironmentRequest(c.Server, teamId, projectId, environmentId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + // NewGetHealthRequest generates requests for GetHealth func NewGetHealthRequest(server string) (*http.Request, error) { var err error @@ -1873,6 +1975,237 @@ func NewPutApiV1UserIdRequestWithBody(server string, id string, contentType stri return req, nil } +// NewLockEnvironmentRequest calls the generic LockEnvironment builder with application/json body +func NewLockEnvironmentRequest(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body LockEnvironmentJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLockEnvironmentRequestWithBody(server, teamId, projectId, environmentId, "application/json", bodyReader) +} + +// NewLockEnvironmentRequestWithBody generates requests for LockEnvironment with any type of body +func NewLockEnvironmentRequestWithBody(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "teamId", runtime.ParamLocationPath, teamId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "environmentId", runtime.ParamLocationPath, environmentId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/client/%s/%s/%s/lock", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetEnvironmentStateRequest generates requests for GetEnvironmentState +func NewGetEnvironmentStateRequest(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "teamId", runtime.ParamLocationPath, teamId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "environmentId", runtime.ParamLocationPath, environmentId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/client/%s/%s/%s/state", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateEnvironmentStateRequest calls the generic UpdateEnvironmentState builder with application/json body +func NewUpdateEnvironmentStateRequest(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UpdateEnvironmentStateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateEnvironmentStateRequestWithBody(server, teamId, projectId, environmentId, "application/json", bodyReader) +} + +// NewUpdateEnvironmentStateRequestWithBody generates requests for UpdateEnvironmentState with any type of body +func NewUpdateEnvironmentStateRequestWithBody(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "teamId", runtime.ParamLocationPath, teamId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "environmentId", runtime.ParamLocationPath, environmentId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/client/%s/%s/%s/state", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewUnlockEnvironmentRequest calls the generic UnlockEnvironment builder with application/json body +func NewUnlockEnvironmentRequest(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UnlockEnvironmentJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUnlockEnvironmentRequestWithBody(server, teamId, projectId, environmentId, "application/json", bodyReader) +} + +// NewUnlockEnvironmentRequestWithBody generates requests for UnlockEnvironment with any type of body +func NewUnlockEnvironmentRequestWithBody(server string, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "teamId", runtime.ParamLocationPath, teamId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "environmentId", runtime.ParamLocationPath, environmentId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/client/%s/%s/%s/unlock", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { for _, r := range c.RequestEditors { if err := r(ctx, req); err != nil { @@ -2015,10 +2348,28 @@ type ClientWithResponsesInterface interface { // GetApiV1UserIdWithResponse request GetApiV1UserIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetApiV1UserIdResponse, error) - // PutApiV1UserIdWithBodyWithResponse request with any body - PutApiV1UserIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutApiV1UserIdResponse, error) + // PutApiV1UserIdWithBodyWithResponse request with any body + PutApiV1UserIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutApiV1UserIdResponse, error) + + PutApiV1UserIdWithResponse(ctx context.Context, id string, body PutApiV1UserIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutApiV1UserIdResponse, error) + + // LockEnvironmentWithBodyWithResponse request with any body + LockEnvironmentWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LockEnvironmentResponse, error) + + LockEnvironmentWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body LockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*LockEnvironmentResponse, error) + + // GetEnvironmentStateWithResponse request + GetEnvironmentStateWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, reqEditors ...RequestEditorFn) (*GetEnvironmentStateResponse, error) + + // UpdateEnvironmentStateWithBodyWithResponse request with any body + UpdateEnvironmentStateWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateEnvironmentStateResponse, error) + + UpdateEnvironmentStateWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UpdateEnvironmentStateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateEnvironmentStateResponse, error) + + // UnlockEnvironmentWithBodyWithResponse request with any body + UnlockEnvironmentWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UnlockEnvironmentResponse, error) - PutApiV1UserIdWithResponse(ctx context.Context, id string, body PutApiV1UserIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutApiV1UserIdResponse, error) + UnlockEnvironmentWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UnlockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*UnlockEnvironmentResponse, error) } type GetHealthResponse struct { @@ -2711,6 +3062,101 @@ func (r PutApiV1UserIdResponse) StatusCode() int { return 0 } +type LockEnvironmentResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *LockInfo + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r LockEnvironmentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LockEnvironmentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetEnvironmentStateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Payload + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r GetEnvironmentStateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetEnvironmentStateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateEnvironmentStateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Payload + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r UpdateEnvironmentStateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateEnvironmentStateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UnlockEnvironmentResponse struct { + Body []byte + HTTPResponse *http.Response + JSON404 *ErrorResponse + JSON500 *ErrorResponse +} + +// Status returns HTTPResponse.Status +func (r UnlockEnvironmentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UnlockEnvironmentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + // GetHealthWithResponse request returning *GetHealthResponse func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) { rsp, err := c.GetHealth(ctx, reqEditors...) @@ -3043,6 +3489,66 @@ func (c *ClientWithResponses) PutApiV1UserIdWithResponse(ctx context.Context, id return ParsePutApiV1UserIdResponse(rsp) } +// LockEnvironmentWithBodyWithResponse request with arbitrary body returning *LockEnvironmentResponse +func (c *ClientWithResponses) LockEnvironmentWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LockEnvironmentResponse, error) { + rsp, err := c.LockEnvironmentWithBody(ctx, teamId, projectId, environmentId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLockEnvironmentResponse(rsp) +} + +func (c *ClientWithResponses) LockEnvironmentWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body LockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*LockEnvironmentResponse, error) { + rsp, err := c.LockEnvironment(ctx, teamId, projectId, environmentId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLockEnvironmentResponse(rsp) +} + +// GetEnvironmentStateWithResponse request returning *GetEnvironmentStateResponse +func (c *ClientWithResponses) GetEnvironmentStateWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, reqEditors ...RequestEditorFn) (*GetEnvironmentStateResponse, error) { + rsp, err := c.GetEnvironmentState(ctx, teamId, projectId, environmentId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetEnvironmentStateResponse(rsp) +} + +// UpdateEnvironmentStateWithBodyWithResponse request with arbitrary body returning *UpdateEnvironmentStateResponse +func (c *ClientWithResponses) UpdateEnvironmentStateWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateEnvironmentStateResponse, error) { + rsp, err := c.UpdateEnvironmentStateWithBody(ctx, teamId, projectId, environmentId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateEnvironmentStateResponse(rsp) +} + +func (c *ClientWithResponses) UpdateEnvironmentStateWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UpdateEnvironmentStateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateEnvironmentStateResponse, error) { + rsp, err := c.UpdateEnvironmentState(ctx, teamId, projectId, environmentId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateEnvironmentStateResponse(rsp) +} + +// UnlockEnvironmentWithBodyWithResponse request with arbitrary body returning *UnlockEnvironmentResponse +func (c *ClientWithResponses) UnlockEnvironmentWithBodyWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UnlockEnvironmentResponse, error) { + rsp, err := c.UnlockEnvironmentWithBody(ctx, teamId, projectId, environmentId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUnlockEnvironmentResponse(rsp) +} + +func (c *ClientWithResponses) UnlockEnvironmentWithResponse(ctx context.Context, teamId TeamId, projectId ProjectId, environmentId EnvironmentId, body UnlockEnvironmentJSONRequestBody, reqEditors ...RequestEditorFn) (*UnlockEnvironmentResponse, error) { + rsp, err := c.UnlockEnvironment(ctx, teamId, projectId, environmentId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUnlockEnvironmentResponse(rsp) +} + // ParseGetHealthResponse parses an HTTP response from a GetHealthWithResponse call func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -4078,3 +4584,156 @@ func ParsePutApiV1UserIdResponse(rsp *http.Response) (*PutApiV1UserIdResponse, e return response, nil } + +// ParseLockEnvironmentResponse parses an HTTP response from a LockEnvironmentWithResponse call +func ParseLockEnvironmentResponse(rsp *http.Response) (*LockEnvironmentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LockEnvironmentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LockInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetEnvironmentStateResponse parses an HTTP response from a GetEnvironmentStateWithResponse call +func ParseGetEnvironmentStateResponse(rsp *http.Response) (*GetEnvironmentStateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetEnvironmentStateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Payload + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseUpdateEnvironmentStateResponse parses an HTTP response from a UpdateEnvironmentStateWithResponse call +func ParseUpdateEnvironmentStateResponse(rsp *http.Response) (*UpdateEnvironmentStateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateEnvironmentStateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Payload + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseUnlockEnvironmentResponse parses an HTTP response from a UnlockEnvironmentWithResponse call +func ParseUnlockEnvironmentResponse(rsp *http.Response) (*UnlockEnvironmentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UnlockEnvironmentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} diff --git a/pkg/apis/models.gen.go b/pkg/apis/models.gen.go index df62a2a..a7fc103 100644 --- a/pkg/apis/models.gen.go +++ b/pkg/apis/models.gen.go @@ -14,10 +14,12 @@ import ( "time" "github.com/getkin/kin-openapi/openapi3" + openapi_types "github.com/oapi-codegen/runtime/types" ) const ( - Api_keyScopes = "api_key.Scopes" + Api_keyScopes = "api_key.Scopes" + Basic_authScopes = "basic_auth.Scopes" ) // Environment defines model for Environment. @@ -63,6 +65,20 @@ type HealthResponse struct { Status *string `json:"status,omitempty"` } +// LockInfo defines model for LockInfo. +type LockInfo struct { + Created *time.Time `json:"created,omitempty"` + Id *string `json:"id,omitempty"` + Info *string `json:"info,omitempty"` + Operation *string `json:"operation,omitempty"` + Path *string `json:"path,omitempty"` + Version *string `json:"version,omitempty"` + Who *string `json:"who,omitempty"` +} + +// Payload defines model for Payload. +type Payload = openapi_types.File + // Project defines model for Project. type Project struct { CreatedAt *time.Time `json:"createdAt,omitempty"` @@ -192,6 +208,15 @@ type UserUpdate struct { Role *string `json:"role,omitempty"` } +// EnvironmentId defines model for environmentId. +type EnvironmentId = string + +// ProjectId defines model for projectId. +type ProjectId = string + +// TeamId defines model for teamId. +type TeamId = string + // GetApiV1ProjectParams defines parameters for GetApiV1Project. type GetApiV1ProjectParams struct { Limit *int `form:"limit,omitempty" json:"limit,omitempty"` @@ -252,37 +277,51 @@ type PostApiV1UserJSONRequestBody = UserCreate // PutApiV1UserIdJSONRequestBody defines body for PutApiV1UserId for application/json ContentType. type PutApiV1UserIdJSONRequestBody = UserUpdate +// LockEnvironmentJSONRequestBody defines body for LockEnvironment for application/json ContentType. +type LockEnvironmentJSONRequestBody = LockInfo + +// UpdateEnvironmentStateJSONRequestBody defines body for UpdateEnvironmentState for application/json ContentType. +type UpdateEnvironmentStateJSONRequestBody = Payload + +// UnlockEnvironmentJSONRequestBody defines body for UnlockEnvironment for application/json ContentType. +type UnlockEnvironmentJSONRequestBody = LockInfo + // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "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", + "HC2YkLP30/dTtLpd/RMAAP//EwO5RWVkAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/apis/server.gen.go b/pkg/apis/server.gen.go index 7e98cc1..af4c230 100644 --- a/pkg/apis/server.gen.go +++ b/pkg/apis/server.gen.go @@ -98,6 +98,18 @@ type ServerInterface interface { // Update a user // (PUT /api/v1/user/{id}) PutApiV1UserId(c *fiber.Ctx, id string) error + // Lock the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/lock) + LockEnvironment(c *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error + // Get the state of Terraform environment + // (GET /client/{teamId}/{projectId}/{environmentId}/state) + GetEnvironmentState(c *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error + // Update the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/state) + UpdateEnvironmentState(c *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error + // Unlock the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/unlock) + UnlockEnvironment(c *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error } // ServerInterfaceWrapper converts contexts to parameters. @@ -654,6 +666,142 @@ func (siw *ServerInterfaceWrapper) PutApiV1UserId(c *fiber.Ctx) error { return siw.Handler.PutApiV1UserId(c, id) } +// LockEnvironment operation middleware +func (siw *ServerInterfaceWrapper) LockEnvironment(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "teamId" ------------- + var teamId TeamId + + err = runtime.BindStyledParameterWithOptions("simple", "teamId", c.Params("teamId"), &teamId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter teamId: %w", err).Error()) + } + + // ------------- Path parameter "projectId" ------------- + var projectId ProjectId + + err = runtime.BindStyledParameterWithOptions("simple", "projectId", c.Params("projectId"), &projectId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter projectId: %w", err).Error()) + } + + // ------------- Path parameter "environmentId" ------------- + var environmentId EnvironmentId + + err = runtime.BindStyledParameterWithOptions("simple", "environmentId", c.Params("environmentId"), &environmentId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter environmentId: %w", err).Error()) + } + + c.Context().SetUserValue(Basic_authScopes, []string{}) + + return siw.Handler.LockEnvironment(c, teamId, projectId, environmentId) +} + +// GetEnvironmentState operation middleware +func (siw *ServerInterfaceWrapper) GetEnvironmentState(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "teamId" ------------- + var teamId TeamId + + err = runtime.BindStyledParameterWithOptions("simple", "teamId", c.Params("teamId"), &teamId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter teamId: %w", err).Error()) + } + + // ------------- Path parameter "projectId" ------------- + var projectId ProjectId + + err = runtime.BindStyledParameterWithOptions("simple", "projectId", c.Params("projectId"), &projectId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter projectId: %w", err).Error()) + } + + // ------------- Path parameter "environmentId" ------------- + var environmentId EnvironmentId + + err = runtime.BindStyledParameterWithOptions("simple", "environmentId", c.Params("environmentId"), &environmentId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter environmentId: %w", err).Error()) + } + + c.Context().SetUserValue(Basic_authScopes, []string{}) + + return siw.Handler.GetEnvironmentState(c, teamId, projectId, environmentId) +} + +// UpdateEnvironmentState operation middleware +func (siw *ServerInterfaceWrapper) UpdateEnvironmentState(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "teamId" ------------- + var teamId TeamId + + err = runtime.BindStyledParameterWithOptions("simple", "teamId", c.Params("teamId"), &teamId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter teamId: %w", err).Error()) + } + + // ------------- Path parameter "projectId" ------------- + var projectId ProjectId + + err = runtime.BindStyledParameterWithOptions("simple", "projectId", c.Params("projectId"), &projectId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter projectId: %w", err).Error()) + } + + // ------------- Path parameter "environmentId" ------------- + var environmentId EnvironmentId + + err = runtime.BindStyledParameterWithOptions("simple", "environmentId", c.Params("environmentId"), &environmentId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter environmentId: %w", err).Error()) + } + + c.Context().SetUserValue(Basic_authScopes, []string{}) + + return siw.Handler.UpdateEnvironmentState(c, teamId, projectId, environmentId) +} + +// UnlockEnvironment operation middleware +func (siw *ServerInterfaceWrapper) UnlockEnvironment(c *fiber.Ctx) error { + + var err error + + // ------------- Path parameter "teamId" ------------- + var teamId TeamId + + err = runtime.BindStyledParameterWithOptions("simple", "teamId", c.Params("teamId"), &teamId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter teamId: %w", err).Error()) + } + + // ------------- Path parameter "projectId" ------------- + var projectId ProjectId + + err = runtime.BindStyledParameterWithOptions("simple", "projectId", c.Params("projectId"), &projectId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter projectId: %w", err).Error()) + } + + // ------------- Path parameter "environmentId" ------------- + var environmentId EnvironmentId + + err = runtime.BindStyledParameterWithOptions("simple", "environmentId", c.Params("environmentId"), &environmentId, runtime.BindStyledParameterOptions{Explode: false, Required: true}) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter environmentId: %w", err).Error()) + } + + c.Context().SetUserValue(Basic_authScopes, []string{}) + + return siw.Handler.UnlockEnvironment(c, teamId, projectId, environmentId) +} + // FiberServerOptions provides options for the Fiber server. type FiberServerOptions struct { BaseURL string @@ -731,6 +879,14 @@ func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, option router.Put(options.BaseURL+"/api/v1/user/:id", wrapper.PutApiV1UserId) + router.Post(options.BaseURL+"/client/:teamId/:projectId/:environmentId/lock", wrapper.LockEnvironment) + + router.Get(options.BaseURL+"/client/:teamId/:projectId/:environmentId/state", wrapper.GetEnvironmentState) + + router.Post(options.BaseURL+"/client/:teamId/:projectId/:environmentId/state", wrapper.UpdateEnvironmentState) + + router.Post(options.BaseURL+"/client/:teamId/:projectId/:environmentId/unlock", wrapper.UnlockEnvironment) + } type GetHealthRequestObject struct { @@ -1643,6 +1799,164 @@ func (response PutApiV1UserId500JSONResponse) VisitPutApiV1UserIdResponse(ctx *f return ctx.JSON(&response) } +type LockEnvironmentRequestObject struct { + TeamId TeamId `json:"teamId"` + ProjectId ProjectId `json:"projectId"` + EnvironmentId EnvironmentId `json:"environmentId"` + Body *LockEnvironmentJSONRequestBody +} + +type LockEnvironmentResponseObject interface { + VisitLockEnvironmentResponse(ctx *fiber.Ctx) error +} + +type LockEnvironment200JSONResponse LockInfo + +func (response LockEnvironment200JSONResponse) VisitLockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(200) + + return ctx.JSON(&response) +} + +type LockEnvironment404JSONResponse ErrorResponse + +func (response LockEnvironment404JSONResponse) VisitLockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(404) + + return ctx.JSON(&response) +} + +type LockEnvironment500JSONResponse ErrorResponse + +func (response LockEnvironment500JSONResponse) VisitLockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(500) + + return ctx.JSON(&response) +} + +type GetEnvironmentStateRequestObject struct { + TeamId TeamId `json:"teamId"` + ProjectId ProjectId `json:"projectId"` + EnvironmentId EnvironmentId `json:"environmentId"` +} + +type GetEnvironmentStateResponseObject interface { + VisitGetEnvironmentStateResponse(ctx *fiber.Ctx) error +} + +type GetEnvironmentState200JSONResponse Payload + +func (response GetEnvironmentState200JSONResponse) VisitGetEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(200) + + return ctx.JSON(&response) +} + +type GetEnvironmentState404JSONResponse ErrorResponse + +func (response GetEnvironmentState404JSONResponse) VisitGetEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(404) + + return ctx.JSON(&response) +} + +type GetEnvironmentState500JSONResponse ErrorResponse + +func (response GetEnvironmentState500JSONResponse) VisitGetEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(500) + + return ctx.JSON(&response) +} + +type UpdateEnvironmentStateRequestObject struct { + TeamId TeamId `json:"teamId"` + ProjectId ProjectId `json:"projectId"` + EnvironmentId EnvironmentId `json:"environmentId"` + Body *UpdateEnvironmentStateJSONRequestBody +} + +type UpdateEnvironmentStateResponseObject interface { + VisitUpdateEnvironmentStateResponse(ctx *fiber.Ctx) error +} + +type UpdateEnvironmentState200JSONResponse Payload + +func (response UpdateEnvironmentState200JSONResponse) VisitUpdateEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(200) + + return ctx.JSON(&response) +} + +type UpdateEnvironmentState404JSONResponse ErrorResponse + +func (response UpdateEnvironmentState404JSONResponse) VisitUpdateEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(404) + + return ctx.JSON(&response) +} + +type UpdateEnvironmentState500JSONResponse ErrorResponse + +func (response UpdateEnvironmentState500JSONResponse) VisitUpdateEnvironmentStateResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(500) + + return ctx.JSON(&response) +} + +type UnlockEnvironmentRequestObject struct { + TeamId TeamId `json:"teamId"` + ProjectId ProjectId `json:"projectId"` + EnvironmentId EnvironmentId `json:"environmentId"` + Body *UnlockEnvironmentJSONRequestBody +} + +type UnlockEnvironmentResponseObject interface { + VisitUnlockEnvironmentResponse(ctx *fiber.Ctx) error +} + +type UnlockEnvironment200Response struct { +} + +func (response UnlockEnvironment200Response) VisitUnlockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Status(200) + return nil +} + +type UnlockEnvironment204Response struct { +} + +func (response UnlockEnvironment204Response) VisitUnlockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Status(204) + return nil +} + +type UnlockEnvironment404JSONResponse ErrorResponse + +func (response UnlockEnvironment404JSONResponse) VisitUnlockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(404) + + return ctx.JSON(&response) +} + +type UnlockEnvironment500JSONResponse ErrorResponse + +func (response UnlockEnvironment500JSONResponse) VisitUnlockEnvironmentResponse(ctx *fiber.Ctx) error { + ctx.Response().Header.Set("Content-Type", "application/json") + ctx.Status(500) + + return ctx.JSON(&response) +} + // StrictServerInterface represents all server handlers. type StrictServerInterface interface { // Get system health status @@ -1729,6 +2043,18 @@ type StrictServerInterface interface { // Update a user // (PUT /api/v1/user/{id}) PutApiV1UserId(ctx context.Context, request PutApiV1UserIdRequestObject) (PutApiV1UserIdResponseObject, error) + // Lock the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/lock) + LockEnvironment(ctx context.Context, request LockEnvironmentRequestObject) (LockEnvironmentResponseObject, error) + // Get the state of Terraform environment + // (GET /client/{teamId}/{projectId}/{environmentId}/state) + GetEnvironmentState(ctx context.Context, request GetEnvironmentStateRequestObject) (GetEnvironmentStateResponseObject, error) + // Update the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/state) + UpdateEnvironmentState(ctx context.Context, request UpdateEnvironmentStateRequestObject) (UpdateEnvironmentStateResponseObject, error) + // Unlock the state of Terraform environment + // (POST /client/{teamId}/{projectId}/{environmentId}/unlock) + UnlockEnvironment(ctx context.Context, request UnlockEnvironmentRequestObject) (UnlockEnvironmentResponseObject, error) } type StrictHandlerFunc func(ctx *fiber.Ctx, args interface{}) (interface{}, error) @@ -2551,3 +2877,137 @@ func (sh *strictHandler) PutApiV1UserId(ctx *fiber.Ctx, id string) error { } return nil } + +// LockEnvironment operation middleware +func (sh *strictHandler) LockEnvironment(ctx *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error { + var request LockEnvironmentRequestObject + + request.TeamId = teamId + request.ProjectId = projectId + request.EnvironmentId = environmentId + + var body LockEnvironmentJSONRequestBody + if err := ctx.BodyParser(&body); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + request.Body = &body + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.LockEnvironment(ctx.UserContext(), request.(LockEnvironmentRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "LockEnvironment") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(LockEnvironmentResponseObject); ok { + if err := validResponse.VisitLockEnvironmentResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// GetEnvironmentState operation middleware +func (sh *strictHandler) GetEnvironmentState(ctx *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error { + var request GetEnvironmentStateRequestObject + + request.TeamId = teamId + request.ProjectId = projectId + request.EnvironmentId = environmentId + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.GetEnvironmentState(ctx.UserContext(), request.(GetEnvironmentStateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "GetEnvironmentState") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(GetEnvironmentStateResponseObject); ok { + if err := validResponse.VisitGetEnvironmentStateResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// UpdateEnvironmentState operation middleware +func (sh *strictHandler) UpdateEnvironmentState(ctx *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error { + var request UpdateEnvironmentStateRequestObject + + request.TeamId = teamId + request.ProjectId = projectId + request.EnvironmentId = environmentId + + var body UpdateEnvironmentStateJSONRequestBody + if err := ctx.BodyParser(&body); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + request.Body = &body + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.UpdateEnvironmentState(ctx.UserContext(), request.(UpdateEnvironmentStateRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "UpdateEnvironmentState") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(UpdateEnvironmentStateResponseObject); ok { + if err := validResponse.VisitUpdateEnvironmentStateResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + +// UnlockEnvironment operation middleware +func (sh *strictHandler) UnlockEnvironment(ctx *fiber.Ctx, teamId TeamId, projectId ProjectId, environmentId EnvironmentId) error { + var request UnlockEnvironmentRequestObject + + request.TeamId = teamId + request.ProjectId = projectId + request.EnvironmentId = environmentId + + var body UnlockEnvironmentJSONRequestBody + if err := ctx.BodyParser(&body); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + request.Body = &body + + handler := func(ctx *fiber.Ctx, request interface{}) (interface{}, error) { + return sh.ssi.UnlockEnvironment(ctx.UserContext(), request.(UnlockEnvironmentRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "UnlockEnvironment") + } + + response, err := handler(ctx, request) + + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } else if validResponse, ok := response.(UnlockEnvironmentResponseObject); ok { + if err := validResponse.VisitUnlockEnvironmentResponse(ctx); err != nil { + return fiber.NewError(fiber.StatusBadRequest, err.Error()) + } + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +}