From c2f2a6fb8459ebacb36a0f35a8f6759beb9c26db Mon Sep 17 00:00:00 2001 From: dharsanb <52737410+dharsanb@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:56:26 +0000 Subject: [PATCH] feat: update client --- client/client.gen.go | 519 ++++++++++++++++++++++++++++++++++++++++++- docs/openapi.json | 333 ++++++++++++++++----------- 2 files changed, 722 insertions(+), 130 deletions(-) diff --git a/client/client.gen.go b/client/client.gen.go index 2b8fce8..8f3055a 100644 --- a/client/client.gen.go +++ b/client/client.gen.go @@ -239,6 +239,12 @@ type ActiveResourceResponse struct { UpdatedAt time.Time `json:"updated_at"` } +// ActiveResourceTargetDefinitionRequest An active resource can be pinned to a certain version of the resource definition, then the resource is provisioned with this version. +type ActiveResourceTargetDefinitionRequest struct { + // TargetDefVersionId The Resource Definition Version pinned to this resource to be provisioned from. + TargetDefVersionId *string `json:"target_def_version_id"` +} + // Agent An object containing the details of an Agent. type Agent struct { // CreatedAt Time of the Agent being registered. @@ -306,6 +312,12 @@ type ApplicationResponse struct { OrgId string `json:"org_id"` } +// ArchiveDefinitionVersionRequest defines model for ArchiveDefinitionVersionRequest. +type ArchiveDefinitionVersionRequest struct { + // Archived Indicates whether to set this version archived or non-archived. Optional, true if not specified. + Archived *bool `json:"archived,omitempty"` +} + // ArtefactResponse Artefacts can be registered with Humanitec. Continuous Integration (CI) pipelines notify Humanitec when a new version of an Artefact becomes available. Humanitec tracks the Artefact along with metadata about how it was built. type ArtefactResponse struct { // CreatedAt The time when the Artefact was added to Humanitec. @@ -2247,6 +2259,9 @@ type ResourceDefinitionChangeResponse struct { // // The schema for the `driver_inputs` is defined by the `input_schema` property on the DriverDefinition identified by the `driver_type` property. type ResourceDefinitionResponse struct { + // ActiveVersionId The active Resource Definition Version ID. + ActiveVersionId string `json:"active_version_id"` + // CreatedAt The timestamp of when this record has been created. CreatedAt time.Time `json:"created_at"` @@ -2256,9 +2271,6 @@ type ResourceDefinitionResponse struct { // Criteria (Optional) The criteria to use when looking for a Resource Definition during the deployment. Criteria *[]MatchingCriteriaResponse `json:"criteria,omitempty"` - // CurrentVersionId The Resource Definition Version ID. - CurrentVersionId string `json:"current_version_id"` - // DriverAccount (Optional) Security account required by the driver. DriverAccount *string `json:"driver_account,omitempty"` @@ -3480,6 +3492,12 @@ type PipelineIdPathParam = string // ProfileQidPathParam defines model for profileQidPathParam. type ProfileQidPathParam = string +// ResourceIdPathParam defines model for resourceIdPathParam. +type ResourceIdPathParam = string + +// ResourceTypePathParam defines model for resourceTypePathParam. +type ResourceTypePathParam = string + // RunIdPathParam defines model for runIdPathParam. type RunIdPathParam = string @@ -4068,6 +4086,9 @@ type QueryResourceGraphJSONRequestBody = QueryResourceGraphJSONBody // CreateDependencyGraphJSONRequestBody defines body for CreateDependencyGraph for application/json ContentType. type CreateDependencyGraphJSONRequestBody = CreateDependencyGraphJSONBody +// PinActiveResourceJSONRequestBody defines body for PinActiveResource for application/json ContentType. +type PinActiveResourceJSONRequestBody = ActiveResourceTargetDefinitionRequest + // CreateAutomationRuleJSONRequestBody defines body for CreateAutomationRule for application/json ContentType. type CreateAutomationRuleJSONRequestBody = AutomationRuleRequest @@ -4200,6 +4221,9 @@ type CreateResourceDefinitionCriteriaJSONRequestBody = MatchingCriteriaRuleReque // UpdateResourceDefinitionCriteriaJSONRequestBody defines body for UpdateResourceDefinitionCriteria for application/json ContentType. type UpdateResourceDefinitionCriteriaJSONRequestBody = UpdateResourceDefinitionCriteriaJSONBody +// ArchiveResourceDefinitionVersionJSONRequestBody defines body for ArchiveResourceDefinitionVersion for application/json ContentType. +type ArchiveResourceDefinitionVersionJSONRequestBody = ArchiveDefinitionVersionRequest + // CreateResourceDriverJSONRequestBody defines body for CreateResourceDriver for application/json ContentType. type CreateResourceDriverJSONRequestBody = CreateDriverRequestRequest @@ -5140,6 +5164,11 @@ type ClientInterface interface { // DeleteActiveResource request DeleteActiveResource(ctx context.Context, orgId string, appId string, envId string, pType string, resId string, params *DeleteActiveResourceParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // PinActiveResourceWithBody request with any body + PinActiveResourceWithBody(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PinActiveResource(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, body PinActiveResourceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListAutomationRules request ListAutomationRules(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -5625,6 +5654,14 @@ type ClientInterface interface { // GetResourceDefinitionVersion request GetResourceDefinitionVersion(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*http.Response, error) + // ArchiveResourceDefinitionVersionWithBody request with any body + ArchiveResourceDefinitionVersionWithBody(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ArchiveResourceDefinitionVersion(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, body ArchiveResourceDefinitionVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PromoteResourceDefinitionVersion request + PromoteResourceDefinitionVersion(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListResourceDrivers request ListResourceDrivers(ctx context.Context, orgId string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -6427,6 +6464,30 @@ func (c *Client) DeleteActiveResource(ctx context.Context, orgId string, appId s return c.Client.Do(req) } +func (c *Client) PinActiveResourceWithBody(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPinActiveResourceRequestWithBody(c.Server, orgId, appId, envId, pType, resId, 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) PinActiveResource(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, body PinActiveResourceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPinActiveResourceRequest(c.Server, orgId, appId, envId, pType, resId, 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) ListAutomationRules(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListAutomationRulesRequest(c.Server, orgId, appId, envId) if err != nil { @@ -8539,6 +8600,42 @@ func (c *Client) GetResourceDefinitionVersion(ctx context.Context, orgId OrgIdPa return c.Client.Do(req) } +func (c *Client) ArchiveResourceDefinitionVersionWithBody(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewArchiveResourceDefinitionVersionRequestWithBody(c.Server, orgId, defId, defVersionId, 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) ArchiveResourceDefinitionVersion(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, body ArchiveResourceDefinitionVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewArchiveResourceDefinitionVersionRequest(c.Server, orgId, defId, defVersionId, 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) PromoteResourceDefinitionVersion(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPromoteResourceDefinitionVersionRequest(c.Server, orgId, defId, defVersionId) + 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) ListResourceDrivers(ctx context.Context, orgId string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListResourceDriversRequest(c.Server, orgId) if err != nil { @@ -11211,6 +11308,81 @@ func NewDeleteActiveResourceRequest(server string, orgId string, appId string, e return req, nil } +// NewPinActiveResourceRequest calls the generic PinActiveResource builder with application/json body +func NewPinActiveResourceRequest(server string, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, body PinActiveResourceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPinActiveResourceRequestWithBody(server, orgId, appId, envId, pType, resId, "application/json", bodyReader) +} + +// NewPinActiveResourceRequestWithBody generates requests for PinActiveResource with any type of body +func NewPinActiveResourceRequestWithBody(server string, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgId", runtime.ParamLocationPath, orgId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "appId", runtime.ParamLocationPath, appId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "envId", runtime.ParamLocationPath, envId) + if err != nil { + return nil, err + } + + var pathParam3 string + + pathParam3, err = runtime.StyleParamWithLocation("simple", false, "type", runtime.ParamLocationPath, pType) + if err != nil { + return nil, err + } + + var pathParam4 string + + pathParam4, err = runtime.StyleParamWithLocation("simple", false, "resId", runtime.ParamLocationPath, resId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/orgs/%s/apps/%s/envs/%s/resources/%s/%s/actions/pin", pathParam0, pathParam1, pathParam2, pathParam3, pathParam4) + 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 +} + // NewListAutomationRulesRequest generates requests for ListAutomationRules func NewListAutomationRulesRequest(server string, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam) (*http.Request, error) { var err error @@ -19366,6 +19538,115 @@ func NewGetResourceDefinitionVersionRequest(server string, orgId OrgIdPathParam, return req, nil } +// NewArchiveResourceDefinitionVersionRequest calls the generic ArchiveResourceDefinitionVersion builder with application/json body +func NewArchiveResourceDefinitionVersionRequest(server string, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, body ArchiveResourceDefinitionVersionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewArchiveResourceDefinitionVersionRequestWithBody(server, orgId, defId, defVersionId, "application/json", bodyReader) +} + +// NewArchiveResourceDefinitionVersionRequestWithBody generates requests for ArchiveResourceDefinitionVersion with any type of body +func NewArchiveResourceDefinitionVersionRequestWithBody(server string, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgId", runtime.ParamLocationPath, orgId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "defId", runtime.ParamLocationPath, defId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "defVersionId", runtime.ParamLocationPath, defVersionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/orgs/%s/resources/defs/%s/versions/%s/actions/archive", 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 +} + +// NewPromoteResourceDefinitionVersionRequest generates requests for PromoteResourceDefinitionVersion +func NewPromoteResourceDefinitionVersionRequest(server string, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgId", runtime.ParamLocationPath, orgId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "defId", runtime.ParamLocationPath, defId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "defVersionId", runtime.ParamLocationPath, defVersionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/orgs/%s/resources/defs/%s/versions/%s/actions/promote", 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(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewListResourceDriversRequest generates requests for ListResourceDrivers func NewListResourceDriversRequest(server string, orgId string) (*http.Request, error) { var err error @@ -21231,6 +21512,11 @@ type ClientWithResponsesInterface interface { // DeleteActiveResourceWithResponse request DeleteActiveResourceWithResponse(ctx context.Context, orgId string, appId string, envId string, pType string, resId string, params *DeleteActiveResourceParams, reqEditors ...RequestEditorFn) (*DeleteActiveResourceResponse, error) + // PinActiveResourceWithBodyWithResponse request with any body + PinActiveResourceWithBodyWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PinActiveResourceResponse, error) + + PinActiveResourceWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, body PinActiveResourceJSONRequestBody, reqEditors ...RequestEditorFn) (*PinActiveResourceResponse, error) + // ListAutomationRulesWithResponse request ListAutomationRulesWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, reqEditors ...RequestEditorFn) (*ListAutomationRulesResponse, error) @@ -21716,6 +22002,14 @@ type ClientWithResponsesInterface interface { // GetResourceDefinitionVersionWithResponse request GetResourceDefinitionVersionWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*GetResourceDefinitionVersionResponse, error) + // ArchiveResourceDefinitionVersionWithBodyWithResponse request with any body + ArchiveResourceDefinitionVersionWithBodyWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ArchiveResourceDefinitionVersionResponse, error) + + ArchiveResourceDefinitionVersionWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, body ArchiveResourceDefinitionVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*ArchiveResourceDefinitionVersionResponse, error) + + // PromoteResourceDefinitionVersionWithResponse request + PromoteResourceDefinitionVersionWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*PromoteResourceDefinitionVersionResponse, error) + // ListResourceDriversWithResponse request ListResourceDriversWithResponse(ctx context.Context, orgId string, reqEditors ...RequestEditorFn) (*ListResourceDriversResponse, error) @@ -22750,6 +23044,30 @@ func (r DeleteActiveResourceResponse) StatusCode() int { return 0 } +type PinActiveResourceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ActiveResourceResponse + JSON400 *HumanitecErrorResponse + JSON404 *HumanitecErrorResponse +} + +// Status returns HTTPResponse.Status +func (r PinActiveResourceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PinActiveResourceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListAutomationRulesResponse struct { Body []byte HTTPResponse *http.Response @@ -25895,6 +26213,52 @@ func (r GetResourceDefinitionVersionResponse) StatusCode() int { return 0 } +type ArchiveResourceDefinitionVersionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *HumanitecErrorResponse + JSON404 *HumanitecErrorResponse +} + +// Status returns HTTPResponse.Status +func (r ArchiveResourceDefinitionVersionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ArchiveResourceDefinitionVersionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PromoteResourceDefinitionVersionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *HumanitecErrorResponse + JSON404 *HumanitecErrorResponse +} + +// Status returns HTTPResponse.Status +func (r PromoteResourceDefinitionVersionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PromoteResourceDefinitionVersionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListResourceDriversResponse struct { Body []byte HTTPResponse *http.Response @@ -27187,6 +27551,23 @@ func (c *ClientWithResponses) DeleteActiveResourceWithResponse(ctx context.Conte return ParseDeleteActiveResourceResponse(rsp) } +// PinActiveResourceWithBodyWithResponse request with arbitrary body returning *PinActiveResourceResponse +func (c *ClientWithResponses) PinActiveResourceWithBodyWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PinActiveResourceResponse, error) { + rsp, err := c.PinActiveResourceWithBody(ctx, orgId, appId, envId, pType, resId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePinActiveResourceResponse(rsp) +} + +func (c *ClientWithResponses) PinActiveResourceWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, pType ResourceTypePathParam, resId ResourceIdPathParam, body PinActiveResourceJSONRequestBody, reqEditors ...RequestEditorFn) (*PinActiveResourceResponse, error) { + rsp, err := c.PinActiveResource(ctx, orgId, appId, envId, pType, resId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePinActiveResourceResponse(rsp) +} + // ListAutomationRulesWithResponse request returning *ListAutomationRulesResponse func (c *ClientWithResponses) ListAutomationRulesWithResponse(ctx context.Context, orgId OrgIdPathParam, appId AppIdPathParam, envId EnvIdPathParam, reqEditors ...RequestEditorFn) (*ListAutomationRulesResponse, error) { rsp, err := c.ListAutomationRules(ctx, orgId, appId, envId, reqEditors...) @@ -28728,6 +29109,32 @@ func (c *ClientWithResponses) GetResourceDefinitionVersionWithResponse(ctx conte return ParseGetResourceDefinitionVersionResponse(rsp) } +// ArchiveResourceDefinitionVersionWithBodyWithResponse request with arbitrary body returning *ArchiveResourceDefinitionVersionResponse +func (c *ClientWithResponses) ArchiveResourceDefinitionVersionWithBodyWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ArchiveResourceDefinitionVersionResponse, error) { + rsp, err := c.ArchiveResourceDefinitionVersionWithBody(ctx, orgId, defId, defVersionId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseArchiveResourceDefinitionVersionResponse(rsp) +} + +func (c *ClientWithResponses) ArchiveResourceDefinitionVersionWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, body ArchiveResourceDefinitionVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*ArchiveResourceDefinitionVersionResponse, error) { + rsp, err := c.ArchiveResourceDefinitionVersion(ctx, orgId, defId, defVersionId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseArchiveResourceDefinitionVersionResponse(rsp) +} + +// PromoteResourceDefinitionVersionWithResponse request returning *PromoteResourceDefinitionVersionResponse +func (c *ClientWithResponses) PromoteResourceDefinitionVersionWithResponse(ctx context.Context, orgId OrgIdPathParam, defId DefIdPathParam, defVersionId DefVersionIdPathParam, reqEditors ...RequestEditorFn) (*PromoteResourceDefinitionVersionResponse, error) { + rsp, err := c.PromoteResourceDefinitionVersion(ctx, orgId, defId, defVersionId, reqEditors...) + if err != nil { + return nil, err + } + return ParsePromoteResourceDefinitionVersionResponse(rsp) +} + // ListResourceDriversWithResponse request returning *ListResourceDriversResponse func (c *ClientWithResponses) ListResourceDriversWithResponse(ctx context.Context, orgId string, reqEditors ...RequestEditorFn) (*ListResourceDriversResponse, error) { rsp, err := c.ListResourceDrivers(ctx, orgId, reqEditors...) @@ -30463,6 +30870,46 @@ func ParseDeleteActiveResourceResponse(rsp *http.Response) (*DeleteActiveResourc return response, nil } +// ParsePinActiveResourceResponse parses an HTTP response from a PinActiveResourceWithResponse call +func ParsePinActiveResourceResponse(rsp *http.Response) (*PinActiveResourceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PinActiveResourceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ActiveResourceResponse + 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 == 400: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + // ParseListAutomationRulesResponse parses an HTTP response from a ListAutomationRulesWithResponse call func ParseListAutomationRulesResponse(rsp *http.Response) (*ListAutomationRulesResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -35439,6 +35886,72 @@ func ParseGetResourceDefinitionVersionResponse(rsp *http.Response) (*GetResource return response, nil } +// ParseArchiveResourceDefinitionVersionResponse parses an HTTP response from a ArchiveResourceDefinitionVersionWithResponse call +func ParseArchiveResourceDefinitionVersionResponse(rsp *http.Response) (*ArchiveResourceDefinitionVersionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ArchiveResourceDefinitionVersionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParsePromoteResourceDefinitionVersionResponse parses an HTTP response from a PromoteResourceDefinitionVersionWithResponse call +func ParsePromoteResourceDefinitionVersionResponse(rsp *http.Response) (*PromoteResourceDefinitionVersionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PromoteResourceDefinitionVersionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest HumanitecErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + // ParseListResourceDriversResponse parses an HTTP response from a ListResourceDriversWithResponse call func ParseListResourceDriversResponse(rsp *http.Response) (*ListResourceDriversResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/docs/openapi.json b/docs/openapi.json index edde721..1b212e6 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.0", "info": { "title": "Humanitec API", - "version": "0.26.16", + "version": "0.26.20", "description": "# Introduction\nThe *Humanitec API* allows you to automate and integrate Humanitec into your developer and operational workflows.\nThe API is a REST based API. It is based around a set of concepts:\n\n* Core\n* External Resources\n* Sets and Deltas\n\n## Authentication\n\nAlmost all requests made to the Humanitec API require Authentication. See our [Developer Docs on API Authentication](https://developer.humanitec.com/platform-orchestrator/reference/api-references/#authentication) for instructions.\n\n## Content Types\nThe Humanitec API, unless explicitly specified, only accepts content types of `application/json` and will always return valid `application/json` or an empty response.\n\n## Response Codes\n### Success\nAny response code in the `2xx` range should be regarded as success.\n\n| **Code** | **Meaning** |\n|----------|-------------------------------------|\n| `200` | Success |\n| `201` | Success, a new resource was created |\n| `204` | Success, but no content in response |\n\n_Note: We plan to simplify the interface by replacing 201 with 200 status codes._\n\n### Failure\nAny response code in the `4xx` range should be regarded as an error that can be rectified by the client. `5xx` error codes indicate errors that cannot be corrected by the client.\n\n| **Code** | **Meaning** |\n|----------|-----------------------------------------------------------------------------------------------------------------------|\n| `400` | General error. (Body will contain details) |\n| `401` | Attempt to access protected resource without `Authorization` Header. |\n| `403` | The `Bearer` or `JWT` does not grant access to the requested resource. |\n| `404` | Resource not found. |\n| `405` | Method not allowed |\n| `409` | Conflict. Usually indicated a resource with that ID already exists. |\n| `422` | Unprocessable Entity. The body was not valid JSON, was empty or contained an object different from what was expected. |\n| `429` | Too many requests - request rate limit has been reached. |\n| `500` | Internal Error. If it occurs repeatedly, contact support. |\n", "contact": { "name": "Humanitec Support", @@ -6678,6 +6678,75 @@ } } }, + "/orgs/{orgId}/apps/{appId}/envs/{envId}/resources/{type}/{resId}/actions/pin": { + "post": { + "tags": [ + "public", + "ActiveResource" + ], + "summary": "Pin Active Resource to a target Resource Definition Version.", + "operationId": "pinActiveResource", + "parameters": [ + { + "$ref": "#/components/parameters/orgIdPathParam" + }, + { + "$ref": "#/components/parameters/appIdPathParam" + }, + { + "$ref": "#/components/parameters/envIdPathParam" + }, + { + "$ref": "#/components/parameters/resourceTypePathParam" + }, + { + "$ref": "#/components/parameters/resourceIdPathParam" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ActiveResourceTargetDefinitionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "The updated Active Resource. \n\n", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ActiveResourceResponse" + } + } + } + }, + "400": { + "description": "One or more request parameters is missing or invalid.\n", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + }, + "404": { + "description": "The requested resource could not be found.\n", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + } + } + } + }, "/orgs/{orgId}/resources/account-types": { "get": { "tags": [ @@ -7741,6 +7810,108 @@ } } }, + "/orgs/{orgId}/resources/defs/{defId}/versions/{defVersionId}/actions/archive": { + "post": { + "tags": [ + "public", + "ResourceDefinitionVersion" + ], + "summary": "Mark/unmark the Resource Definition Version as archived.", + "operationId": "archiveResourceDefinitionVersion", + "parameters": [ + { + "$ref": "#/components/parameters/orgIdPathParam" + }, + { + "$ref": "#/components/parameters/defIdPathParam" + }, + { + "$ref": "#/components/parameters/defVersionIdPathParam" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArchiveDefinitionVersionRequest" + } + } + } + }, + "responses": { + "204": { + "description": "The Resource Definition Version's archived status changed." + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + }, + "404": { + "description": "The Resource Definition Version is not found.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + } + } + } + }, + "/orgs/{orgId}/resources/defs/{defId}/versions/{defVersionId}/actions/promote": { + "post": { + "tags": [ + "public", + "ResourceDefinitionVersion" + ], + "summary": "Promote the Resource Definition Version as active.", + "operationId": "promoteResourceDefinitionVersion", + "parameters": [ + { + "$ref": "#/components/parameters/orgIdPathParam" + }, + { + "$ref": "#/components/parameters/defIdPathParam" + }, + { + "$ref": "#/components/parameters/defVersionIdPathParam" + } + ], + "responses": { + "204": { + "description": "The Resource Definition Version became active." + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + }, + "404": { + "description": "The Resource Definition Version is not found.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HumanitecErrorResponse" + } + } + } + } + } + } + }, "/orgs/{orgId}/resources/defs/{defId}/criteria": { "put": { "tags": [ @@ -10454,7 +10625,7 @@ "public", "ValueSetVersion" ], - "summary": "Get a single Value Set Version in an Environment of an App", + "summary": "Get a single Value Set Version in an Environment of an App. The zero version id (00000000-0000-0000-0000-000000000000) will return the latest Value Set Version.", "parameters": [ { "name": "orgId", @@ -16692,127 +16863,6 @@ ], "type": "object" }, - "ActiveResourceRequest": { - "description": "Active Resources represent the concrete resources provisioned for an Environment. They are provisioned on the first deployment after a dependency on a particular resource type is introduced into an Environment. In general, Active Resources are only deleted when their introductory Environment is deleted.\n\nActive Resources are provisioned based on a Resource Definition. The Resource Definition describes how to provision a concrete resource based on a Resource Type and metadata about the Environment (for example the Environment Type or the Application ID). The criteria for how to choose a Resource Definition is known as a Matching Criteria. If the Matching Criteria changes or the Resource Definition is deleted, the concrete resource represented by an Active Resource might be deleted and reprovisioned when a deployment occurs in the Environment.", - "example": { - "app_id": "test-app", - "class": "default", - "def_id": "gcp-dev-postgres", - "def_version_id": "01234567-89ab-cdef-0123-4567890abcdef", - "deploy_id": "172a1013b", - "env_id": "gcp-dev", - "env_type": "development", - "gu_res_id": "7bd3966c9ff8eaa66c5cce855c03d715857c3440", - "org_id": "test-org", - "res_id": "modules.my-module.externals.my-db", - "resource": { - "host": "127.0.0.1", - "name": "db_33c7ef9b_8d90-4c62_a1cf_0cdd30fd29a9", - "port": 5432 - }, - "secret_refs": { - "credentials": "orgs/test-org/resources/7bd3966c9ff8eaa66c5cce855c03d715857c3440/secrets/.credentials" - }, - "type": "postgres", - "updated_at": "2020-06-23T16:53:12Z" - }, - "properties": { - "app_id": { - "description": "The ID of the App the resource is associated with.", - "type": "string" - }, - "class": { - "description": "The Resource Class of the resource", - "type": "string" - }, - "criteria_id": { - "description": "The Matching Criteria ID.", - "type": "string" - }, - "def_id": { - "description": "The Resource Definition that this resource was provisioned from.", - "type": "string" - }, - "def_version_id": { - "description": "The Resource Definition Version that this resource was provisioned from.", - "type": "string" - }, - "deploy_id": { - "description": "The deployment that the resource was last provisioned in.", - "type": "string" - }, - "driver_account": { - "description": "(Optional) Security account required by the driver.", - "type": "string" - }, - "driver_type": { - "description": "The driver to be used to create the resource.", - "type": "string" - }, - "env_id": { - "description": "The ID of the Environment the resource is associated with.", - "type": "string" - }, - "env_type": { - "description": "The Environment Type of the Environment specified by env_id.", - "type": "string" - }, - "gu_res_id": { - "description": "Globally unique resource id", - "type": "string" - }, - "org_id": { - "description": "the ID of the Organization the Active Resource is associated with.", - "type": "string" - }, - "res_id": { - "description": "The ID of the resource", - "type": "string" - }, - "resource": { - "additionalProperties": true, - "description": "The resource provisioning outputs ('values' only).", - "type": "object" - }, - "secret_refs": { - "additionalProperties": true, - "description": "Secret references from the resource provisioning output.", - "type": "object" - }, - "status": { - "description": "Current resource status: 'pending', 'active', or 'deleting'.", - "type": "string" - }, - "type": { - "description": "The Resource Type of the resource", - "type": "string" - }, - "updated_at": { - "description": "The time the resource was last provisioned as part of a deployment.", - "example": "2020-06-22T09:37:23.523Z", - "type": "string", - "format": "date-time" - } - }, - "type": "object", - "required": [ - "org_id", - "app_id", - "env_id", - "env_type", - "res_id", - "def_id", - "type", - "driver_type", - "class", - "status", - "resource", - "updated_at", - "deploy_id", - "gu_res_id", - "def_version_id" - ] - }, "ActiveResourceResponse": { "description": "Active Resources represent the concrete resources provisioned for an Environment. They are provisioned on the first deployment after a dependency on a particular resource type is introduced into an Environment. In general, Active Resources are only deleted when their introductory Environment is deleted.\n\nActive Resources are provisioned based on a Resource Definition. The Resource Definition describes how to provision a concrete resource based on a Resource Type and metadata about the Environment (for example the Environment Type or the Application ID). The criteria for how to choose a Resource Definition is known as a Matching Criteria. If the Matching Criteria changes or the Resource Definition is deleted, the concrete resource represented by an Active Resource might be deleted and reprovisioned when a deployment occurs in the Environment.", "example": { @@ -16939,6 +16989,23 @@ ], "type": "object" }, + "ActiveResourceTargetDefinitionRequest": { + "description": "An active resource can be pinned to a certain version of the resource definition, then the resource is provisioned with this version.", + "example": { + "target_def_version_id": "01234567-89ab-cdef-0123-4567890abcdef" + }, + "properties": { + "target_def_version_id": { + "description": "The Resource Definition Version pinned to this resource to be provisioned from.", + "type": "string", + "nullable": true + } + }, + "type": "object", + "required": [ + "target_def_version_id" + ] + }, "CreateDriverRequestRequest": { "description": "CreateDriverRequest describes the new resource driver registration request.", "example": { @@ -17698,8 +17765,8 @@ "description": "The Resource Definition ID.", "type": "string" }, - "current_version_id": { - "description": "The Resource Definition Version ID.", + "active_version_id": { + "description": "The active Resource Definition Version ID.", "type": "string" }, "is_default": { @@ -17740,7 +17807,7 @@ "is_default", "is_deleted", "driver_type", - "current_version_id" + "active_version_id" ], "type": "object" }, @@ -17872,6 +17939,18 @@ ], "type": "object" }, + "ArchiveDefinitionVersionRequest": { + "example": { + "archive": true + }, + "properties": { + "archived": { + "description": "Indicates whether to set this version archived or non-archived. Optional, true if not specified.", + "type": "boolean" + } + }, + "type": "object" + }, "ResourceProvisionRequestRequest": { "description": "ResourceProvisionRequest is the payload passed to the resource provisioner, specifying the resources to be provisioned.", "example": { @@ -20528,7 +20607,7 @@ { "name": "ActiveResource", "x-displayName": "Active Resources", - "description": "Active Resources represent the concrete resources provisioned for an Environment. They are provisioned on the first deployment after a dependency on a particular resource type is introduced into an Environment. In general, Active Resources are only deleted when their introductory Environment is deleted.\n\nActive Resources are provisioned based on a Resource Definition. The Resource Definition describes how to provision a concrete resource based on a Resource Type and metadata about the Environment (for example the Environment Type or the Application ID). The criteria for how to choose a Resource Definition is known as a Matching Criteria. If the Matching Criteria changes or the Resource Definition is deleted, the concrete resource represented by an Active Resource might be deleted and reprovisioned when a deployment occurs in the Environment.\n\n" + "description": "An active resource can be pinned to a certain version of the resource definition, then the resource is provisioned with this version.\n\n" }, { "name": "Agents",