From 46da0853b105b14c2b084d5a579fbbdea6255aac Mon Sep 17 00:00:00 2001 From: CloudQuery Bot <102256036+cq-bot@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:54:40 +0200 Subject: [PATCH] fix: Generate CloudQuery Go API Client from `spec.json` (#97) This PR was created by a scheduled workflow to generate the CloudQuery Go API Client from `spec.json` --- client.gen.go | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++ models.gen.go | 39 +++++++++++++ spec.json | 138 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 329 insertions(+), 7 deletions(-) diff --git a/client.gen.go b/client.gen.go index d3f44d7..facc146 100644 --- a/client.gen.go +++ b/client.gen.go @@ -308,6 +308,9 @@ type ClientInterface interface { // GetTeamMemberships request GetTeamMemberships(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // DeleteTeamMembership request + DeleteTeamMembership(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListMonthlyLimitsByTeam request ListMonthlyLimitsByTeam(ctx context.Context, teamName TeamName, params *ListMonthlyLimitsByTeamParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1375,6 +1378,18 @@ func (c *Client) GetTeamMemberships(ctx context.Context, teamName TeamName, para return c.Client.Do(req) } +func (c *Client) DeleteTeamMembership(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteTeamMembershipRequest(c.Server, teamName, email) + 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) ListMonthlyLimitsByTeam(ctx context.Context, teamName TeamName, params *ListMonthlyLimitsByTeamParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListMonthlyLimitsByTeamRequest(c.Server, teamName, params) if err != nil { @@ -4333,6 +4348,17 @@ func NewAuthRegistryRequestRequest(server string, params *AuthRegistryRequestPar req.Header.Set("X-Meta-Plugin-Version", headerParam0) } + if params.XMetaUserTeamName != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "X-Meta-User-Team-Name", runtime.ParamLocationHeader, *params.XMetaUserTeamName) + if err != nil { + return nil, err + } + + req.Header.Set("X-Meta-User-Team-Name", headerParam1) + } + } return req, nil @@ -5428,6 +5454,47 @@ func NewGetTeamMembershipsRequest(server string, teamName TeamName, params *GetT return req, nil } +// NewDeleteTeamMembershipRequest generates requests for DeleteTeamMembership +func NewDeleteTeamMembershipRequest(server string, teamName TeamName, email Email) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "team_name", runtime.ParamLocationPath, teamName) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "email", runtime.ParamLocationPath, email) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/teams/%s/memberships/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewListMonthlyLimitsByTeamRequest generates requests for ListMonthlyLimitsByTeam func NewListMonthlyLimitsByTeamRequest(server string, teamName TeamName, params *ListMonthlyLimitsByTeamParams) (*http.Request, error) { var err error @@ -7341,6 +7408,9 @@ type ClientWithResponsesInterface interface { // GetTeamMembershipsWithResponse request GetTeamMembershipsWithResponse(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*GetTeamMembershipsResponse, error) + // DeleteTeamMembershipWithResponse request + DeleteTeamMembershipWithResponse(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*DeleteTeamMembershipResponse, error) + // ListMonthlyLimitsByTeamWithResponse request ListMonthlyLimitsByTeamWithResponse(ctx context.Context, teamName TeamName, params *ListMonthlyLimitsByTeamParams, reqEditors ...RequestEditorFn) (*ListMonthlyLimitsByTeamResponse, error) @@ -9032,6 +9102,32 @@ func (r GetTeamMembershipsResponse) StatusCode() int { return 0 } +type DeleteTeamMembershipResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *BadRequest + JSON401 *RequiresAuthentication + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r DeleteTeamMembershipResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteTeamMembershipResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListMonthlyLimitsByTeamResponse struct { Body []byte HTTPResponse *http.Response @@ -10535,6 +10631,15 @@ func (c *ClientWithResponses) GetTeamMembershipsWithResponse(ctx context.Context return ParseGetTeamMembershipsResponse(rsp) } +// DeleteTeamMembershipWithResponse request returning *DeleteTeamMembershipResponse +func (c *ClientWithResponses) DeleteTeamMembershipWithResponse(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*DeleteTeamMembershipResponse, error) { + rsp, err := c.DeleteTeamMembership(ctx, teamName, email, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteTeamMembershipResponse(rsp) +} + // ListMonthlyLimitsByTeamWithResponse request returning *ListMonthlyLimitsByTeamResponse func (c *ClientWithResponses) ListMonthlyLimitsByTeamWithResponse(ctx context.Context, teamName TeamName, params *ListMonthlyLimitsByTeamParams, reqEditors ...RequestEditorFn) (*ListMonthlyLimitsByTeamResponse, error) { rsp, err := c.ListMonthlyLimitsByTeam(ctx, teamName, params, reqEditors...) @@ -14078,6 +14183,60 @@ func ParseGetTeamMembershipsResponse(rsp *http.Response) (*GetTeamMembershipsRes return response, nil } +// ParseDeleteTeamMembershipResponse parses an HTTP response from a DeleteTeamMembershipWithResponse call +func ParseDeleteTeamMembershipResponse(rsp *http.Response) (*DeleteTeamMembershipResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteTeamMembershipResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + 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 == 401: + var dest RequiresAuthentication + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + 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 InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseListMonthlyLimitsByTeamResponse parses an HTTP response from a ListMonthlyLimitsByTeamWithResponse call func ParseListMonthlyLimitsByTeamResponse(rsp *http.Response) (*ListMonthlyLimitsByTeamResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/models.gen.go b/models.gen.go index 831bc07..9352750 100644 --- a/models.gen.go +++ b/models.gen.go @@ -1059,12 +1059,24 @@ type ReleaseURL struct { // Sync Managed Sync definition type Sync struct { + // Cpu CPU quota for the sync + CPU string `json:"cpu"` + // CreatedAt Time when the sync was created CreatedAt time.Time `json:"created_at"` // Disabled Whether the sync is disabled Disabled bool `json:"disabled"` + // EnvKeys Environment variable names for the sync + EnvKeys []string `json:"env_keys"` + + // EnvValues Environment variable values for the sync + EnvValues []string `json:"env_values"` + + // Memory Memory quota for the sync + Memory string `json:"memory"` + // Name Unique name for the sync Name string `json:"name"` @@ -1471,6 +1483,9 @@ type AuthRegistryRequestParams struct { // XMetaPluginVersion Plugin version name XMetaPluginVersion *string `json:"X-Meta-Plugin-Version,omitempty"` + + // XMetaUserTeamName User's team name + XMetaUserTeamName *string `json:"X-Meta-User-Team-Name,omitempty"` } // ListTeamsParams defines parameters for ListTeams. @@ -1630,9 +1645,21 @@ type ListSyncsParams struct { // CreateSyncJSONBody defines parameters for CreateSync. type CreateSyncJSONBody struct { + // Cpu CPU quota for the sync + CPU *string `json:"cpu,omitempty"` + // Disabled Whether the sync is disabled Disabled bool `json:"disabled"` + // EnvKeys Environment variable names for the sync + EnvKeys *[]string `json:"env_keys,omitempty"` + + // EnvValues Environment variable values for the sync + EnvValues *[]string `json:"env_values,omitempty"` + + // Memory Memory quota for the sync + Memory *string `json:"memory,omitempty"` + // Name Unique name for the sync Name string `json:"name"` @@ -1643,9 +1670,21 @@ type CreateSyncJSONBody struct { // UpdateSyncJSONBody defines parameters for UpdateSync. type UpdateSyncJSONBody struct { + // Cpu CPU quota for the sync + CPU *string `json:"cpu,omitempty"` + // Disabled Whether the sync is disabled Disabled *bool `json:"disabled,omitempty"` + // EnvKeys Environment variable names for the sync + EnvKeys *[]string `json:"env_keys,omitempty"` + + // EnvValues Environment variable values for the sync + EnvValues *[]string `json:"env_values,omitempty"` + + // Memory Memory quota for the sync + Memory *string `json:"memory,omitempty"` + // Schedule Cron schedule for the sync Schedule *string `json:"schedule,omitempty"` Spec *string `json:"spec,omitempty"` diff --git a/spec.json b/spec.json index 2843e7b..fc08bba 100644 --- a/spec.json +++ b/spec.json @@ -2964,6 +2964,44 @@ ] } }, + "/teams/{team_name}/memberships/{email}": { + "delete": { + "description": "Remove a user from the team", + "operationId": "DeleteTeamMembership", + "parameters": [ + { + "$ref": "#/components/parameters/team_name" + }, + { + "$ref": "#/components/parameters/email" + } + ], + "responses": { + "204": { + "description": "Response" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/RequiresAuthentication" + }, + "403": { + "$ref": "#/components/responses/Forbidden" + }, + "404": { + "$ref": "#/components/responses/NotFound" + }, + "500": { + "$ref": "#/components/responses/InternalError" + } + }, + "tags": [ + "teams", + "users" + ] + } + }, "/teams/{team_name}/monthly-limits": { "get": { "description": "List all monthly limits for the team.", @@ -4403,6 +4441,14 @@ "description": "Plugin version name", "example": "v1.0.0" }, + { + "in": "header", + "name": "X-Meta-User-Team-Name", + "schema": { + "type": "string" + }, + "description": "User's team name" + }, { "in": "query", "name": "account", @@ -4546,7 +4592,33 @@ }, "disabled": { "type": "boolean", - "description": "Whether the sync is disabled" + "description": "Whether the sync is disabled", + "default": false + }, + "env_keys": { + "type": "array", + "description": "Environment variable names for the sync", + "items": { + "type": "string" + } + }, + "env_values": { + "type": "array", + "description": "Environment variable values for the sync", + "items": { + "type": "string" + } + }, + "cpu": { + "type": "string", + "description": "CPU quota for the sync", + "default": "1", + "x-go-name": "CPU" + }, + "memory": { + "type": "string", + "description": "Memory quota for the sync", + "default": "2Gi" } } } @@ -4650,6 +4722,31 @@ "disabled": { "type": "boolean", "description": "Whether the sync is disabled" + }, + "env_keys": { + "type": "array", + "description": "Environment variable names for the sync", + "items": { + "type": "string" + } + }, + "env_values": { + "type": "array", + "description": "Environment variable values for the sync", + "items": { + "type": "string" + } + }, + "cpu": { + "type": "string", + "description": "CPU quota for the sync", + "default": "1", + "x-go-name": "CPU" + }, + "memory": { + "type": "string", + "description": "Memory quota for the sync", + "default": "2Gi" } } } @@ -6935,6 +7032,10 @@ "spec", "disabled", "schedule", + "env_keys", + "env_values", + "cpu", + "memory", "created_at", "updated_at" ], @@ -6955,6 +7056,29 @@ "type": "string", "description": "Cron schedule for the sync" }, + "env_keys": { + "type": "array", + "description": "Environment variable names for the sync", + "items": { + "type": "string" + } + }, + "env_values": { + "type": "array", + "description": "Environment variable values for the sync", + "items": { + "type": "string" + } + }, + "cpu": { + "type": "string", + "description": "CPU quota for the sync", + "x-go-name": "CPU" + }, + "memory": { + "type": "string", + "description": "Memory quota for the sync" + }, "created_at": { "type": "string", "format": "date-time", @@ -7289,20 +7413,20 @@ }, "x-go-name": "AddonOrderID" }, - "addon_team": { + "email": { "in": "path", - "name": "addon_team", + "name": "email", "required": true, "schema": { - "$ref": "#/components/schemas/TeamName" + "$ref": "#/components/schemas/Email" } }, - "email": { + "addon_team": { "in": "path", - "name": "email", + "name": "addon_team", "required": true, "schema": { - "$ref": "#/components/schemas/Email" + "$ref": "#/components/schemas/TeamName" } }, "team_subscription_order_id": {