From 10b3917a5b8e17819090f27636b64d0ee4d429c9 Mon Sep 17 00:00:00 2001 From: CloudQuery Bot <102256036+cq-bot@users.noreply.github.com> Date: Wed, 6 Nov 2024 04:14:13 -0500 Subject: [PATCH] fix: Generate CloudQuery Go API Client from `spec.json` (#246) This PR was created by a scheduled workflow to generate the CloudQuery Go API Client from `spec.json` --- client.gen.go | 358 ++++++++++++++++++++++++++++++++++++++ models.gen.go | 471 ++++++++++++++++++++++++++++++++++++++++++++++++++ spec.json | 182 +++++++++++++++++++ 3 files changed, 1011 insertions(+) diff --git a/client.gen.go b/client.gen.go index 0f316a5..7ff868a 100644 --- a/client.gen.go +++ b/client.gen.go @@ -143,6 +143,16 @@ type ClientInterface interface { // GetOpenAPIJSON request GetOpenAPIJSON(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // ActivatePlatformWithBody request with any body + ActivatePlatformWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ActivatePlatform(ctx context.Context, body ActivatePlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RenewPlatformActivationWithBody request with any body + RenewPlatformActivationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RenewPlatformActivation(ctx context.Context, body RenewPlatformActivationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListPluginNotificationRequests request ListPluginNotificationRequests(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -879,6 +889,54 @@ func (c *Client) GetOpenAPIJSON(ctx context.Context, reqEditors ...RequestEditor return c.Client.Do(req) } +func (c *Client) ActivatePlatformWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewActivatePlatformRequestWithBody(c.Server, 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) ActivatePlatform(ctx context.Context, body ActivatePlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewActivatePlatformRequest(c.Server, 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) RenewPlatformActivationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRenewPlatformActivationRequestWithBody(c.Server, 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) RenewPlatformActivation(ctx context.Context, body RenewPlatformActivationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRenewPlatformActivationRequest(c.Server, 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) ListPluginNotificationRequests(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListPluginNotificationRequestsRequest(c.Server, params) if err != nil { @@ -3964,6 +4022,86 @@ func NewGetOpenAPIJSONRequest(server string) (*http.Request, error) { return req, nil } +// NewActivatePlatformRequest calls the generic ActivatePlatform builder with application/json body +func NewActivatePlatformRequest(server string, body ActivatePlatformJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewActivatePlatformRequestWithBody(server, "application/json", bodyReader) +} + +// NewActivatePlatformRequestWithBody generates requests for ActivatePlatform with any type of body +func NewActivatePlatformRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/platform/activate") + 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 +} + +// NewRenewPlatformActivationRequest calls the generic RenewPlatformActivation builder with application/json body +func NewRenewPlatformActivationRequest(server string, body RenewPlatformActivationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRenewPlatformActivationRequestWithBody(server, "application/json", bodyReader) +} + +// NewRenewPlatformActivationRequestWithBody generates requests for RenewPlatformActivation with any type of body +func NewRenewPlatformActivationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/platform/activate/renew") + 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 +} + // NewListPluginNotificationRequestsRequest generates requests for ListPluginNotificationRequests func NewListPluginNotificationRequestsRequest(server string, params *ListPluginNotificationRequestsParams) (*http.Request, error) { var err error @@ -11698,6 +11836,16 @@ type ClientWithResponsesInterface interface { // GetOpenAPIJSONWithResponse request GetOpenAPIJSONWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOpenAPIJSONResponse, error) + // ActivatePlatformWithBodyWithResponse request with any body + ActivatePlatformWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ActivatePlatformResponse, error) + + ActivatePlatformWithResponse(ctx context.Context, body ActivatePlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*ActivatePlatformResponse, error) + + // RenewPlatformActivationWithBodyWithResponse request with any body + RenewPlatformActivationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RenewPlatformActivationResponse, error) + + RenewPlatformActivationWithResponse(ctx context.Context, body RenewPlatformActivationJSONRequestBody, reqEditors ...RequestEditorFn) (*RenewPlatformActivationResponse, error) + // ListPluginNotificationRequestsWithResponse request ListPluginNotificationRequestsWithResponse(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*ListPluginNotificationRequestsResponse, error) @@ -12570,6 +12718,60 @@ func (r GetOpenAPIJSONResponse) StatusCode() int { return 0 } +type ActivatePlatformResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ActivatePlatform200Response + JSON205 *ActivatePlatform205Response + JSON400 *BadRequest + JSON404 *NotFound + JSON429 *TooManyRequests + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r ActivatePlatformResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ActivatePlatformResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RenewPlatformActivationResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *RenewPlatformActivation200Response + JSON205 *ActivatePlatform205Response + JSON400 *BadRequest + JSON404 *NotFound + JSON429 *TooManyRequests + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r RenewPlatformActivationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RenewPlatformActivationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListPluginNotificationRequestsResponse struct { Body []byte HTTPResponse *http.Response @@ -16309,6 +16511,40 @@ func (c *ClientWithResponses) GetOpenAPIJSONWithResponse(ctx context.Context, re return ParseGetOpenAPIJSONResponse(rsp) } +// ActivatePlatformWithBodyWithResponse request with arbitrary body returning *ActivatePlatformResponse +func (c *ClientWithResponses) ActivatePlatformWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ActivatePlatformResponse, error) { + rsp, err := c.ActivatePlatformWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseActivatePlatformResponse(rsp) +} + +func (c *ClientWithResponses) ActivatePlatformWithResponse(ctx context.Context, body ActivatePlatformJSONRequestBody, reqEditors ...RequestEditorFn) (*ActivatePlatformResponse, error) { + rsp, err := c.ActivatePlatform(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseActivatePlatformResponse(rsp) +} + +// RenewPlatformActivationWithBodyWithResponse request with arbitrary body returning *RenewPlatformActivationResponse +func (c *ClientWithResponses) RenewPlatformActivationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RenewPlatformActivationResponse, error) { + rsp, err := c.RenewPlatformActivationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRenewPlatformActivationResponse(rsp) +} + +func (c *ClientWithResponses) RenewPlatformActivationWithResponse(ctx context.Context, body RenewPlatformActivationJSONRequestBody, reqEditors ...RequestEditorFn) (*RenewPlatformActivationResponse, error) { + rsp, err := c.RenewPlatformActivation(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRenewPlatformActivationResponse(rsp) +} + // ListPluginNotificationRequestsWithResponse request returning *ListPluginNotificationRequestsResponse func (c *ClientWithResponses) ListPluginNotificationRequestsWithResponse(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*ListPluginNotificationRequestsResponse, error) { rsp, err := c.ListPluginNotificationRequests(ctx, params, reqEditors...) @@ -18643,6 +18879,128 @@ func ParseGetOpenAPIJSONResponse(rsp *http.Response) (*GetOpenAPIJSONResponse, e return response, nil } +// ParseActivatePlatformResponse parses an HTTP response from a ActivatePlatformWithResponse call +func ParseActivatePlatformResponse(rsp *http.Response) (*ActivatePlatformResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ActivatePlatformResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ActivatePlatform200Response + 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 == 205: + var dest ActivatePlatform205Response + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON205 = &dest + + 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 == 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 == 429: + var dest TooManyRequests + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &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 +} + +// ParseRenewPlatformActivationResponse parses an HTTP response from a RenewPlatformActivationWithResponse call +func ParseRenewPlatformActivationResponse(rsp *http.Response) (*RenewPlatformActivationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RenewPlatformActivationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RenewPlatformActivation200Response + 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 == 205: + var dest ActivatePlatform205Response + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON205 = &dest + + 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 == 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 == 429: + var dest TooManyRequests + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &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 +} + // ParseListPluginNotificationRequestsResponse parses an HTTP response from a ListPluginNotificationRequestsWithResponse call func ParseListPluginNotificationRequestsResponse(rsp *http.Response) (*ListPluginNotificationRequestsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/models.gen.go b/models.gen.go index 3f9c47e..8a8c866 100644 --- a/models.gen.go +++ b/models.gen.go @@ -340,6 +340,42 @@ type AcceptTeamInvitationRequest struct { Token openapi_types.UUID `json:"token"` } +// ActivatePlatform200Response defines model for ActivatePlatform_200_response. +type ActivatePlatform200Response struct { + // ActivationID Activation ID for the platform + ActivationID interface{} `json:"activation_id"` + + // NextCheckInSeconds Time in seconds until the next check in + NextCheckInSeconds interface{} `json:"next_check_in_seconds"` + + // TeamName Name of the team that was activated + TeamName interface{} `json:"team_name"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// ActivatePlatform205Response defines model for ActivatePlatform_205_response. +type ActivatePlatform205Response struct { + // ButtonText Text for the button + ButtonText *interface{} `json:"button_text,omitempty"` + + // ButtonURL URL for the button + ButtonURL *interface{} `json:"button_url,omitempty"` + + // Error Error message + Error interface{} `json:"error"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// ActivatePlatformRequest defines model for ActivatePlatform_request. +type ActivatePlatformRequest struct { + // APIKey Team API key to activate platform with + APIKey interface{} `json:"api_key"` + + // InstallationID Installation ID of the platform + InstallationID interface{} `json:"installation_id"` + AdditionalProperties map[string]interface{} `json:"-"` +} + // Addon CloudQuery Addon type Addon struct { // AddonFormat Supported formats for addons @@ -1962,6 +1998,23 @@ type RemoveTeamMembershipRequest struct { Email string `json:"email"` } +// RenewPlatformActivation200Response defines model for RenewPlatformActivation_200_response. +type RenewPlatformActivation200Response struct { + // NextCheckInSeconds Time in seconds until the next check in + NextCheckInSeconds interface{} `json:"next_check_in_seconds"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// RenewPlatformActivationRequest defines model for RenewPlatformActivation_request. +type RenewPlatformActivationRequest struct { + // ActivationID Previous activation ID + ActivationID interface{} `json:"activation_id"` + + // InstallationID Installation ID of the platform + InstallationID interface{} `json:"installation_id"` + AdditionalProperties map[string]interface{} `json:"-"` +} + // ResetUserPasswordRequest defines model for ResetUserPassword_request. type ResetUserPasswordRequest struct { // Email Email address to reset @@ -3362,6 +3415,12 @@ type UpdateAddonVersionJSONRequestBody = AddonVersionUpdate // CreateAddonVersionJSONRequestBody defines body for CreateAddonVersion for application/json ContentType. type CreateAddonVersionJSONRequestBody = CreateAddonVersionRequest +// ActivatePlatformJSONRequestBody defines body for ActivatePlatform for application/json ContentType. +type ActivatePlatformJSONRequestBody = ActivatePlatformRequest + +// RenewPlatformActivationJSONRequestBody defines body for RenewPlatformActivation for application/json ContentType. +type RenewPlatformActivationJSONRequestBody = RenewPlatformActivationRequest + // CreatePluginNotificationRequestJSONRequestBody defines body for CreatePluginNotificationRequest for application/json ContentType. type CreatePluginNotificationRequestJSONRequestBody = PluginNotificationRequestCreate @@ -3524,6 +3583,273 @@ type ResetUserPasswordJSONRequestBody = ResetUserPasswordRequest // VerifyUserEmailJSONRequestBody defines body for VerifyUserEmail for application/json ContentType. type VerifyUserEmailJSONRequestBody = VerifyUserEmailRequest +// Getter for additional properties for ActivatePlatform200Response. Returns the specified +// element and whether it was found +func (a ActivatePlatform200Response) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for ActivatePlatform200Response +func (a *ActivatePlatform200Response) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for ActivatePlatform200Response to handle AdditionalProperties +func (a *ActivatePlatform200Response) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["activation_id"]; found { + err = json.Unmarshal(raw, &a.ActivationID) + if err != nil { + return fmt.Errorf("error reading 'activation_id': %w", err) + } + delete(object, "activation_id") + } + + if raw, found := object["next_check_in_seconds"]; found { + err = json.Unmarshal(raw, &a.NextCheckInSeconds) + if err != nil { + return fmt.Errorf("error reading 'next_check_in_seconds': %w", err) + } + delete(object, "next_check_in_seconds") + } + + if raw, found := object["team_name"]; found { + err = json.Unmarshal(raw, &a.TeamName) + if err != nil { + return fmt.Errorf("error reading 'team_name': %w", err) + } + delete(object, "team_name") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for ActivatePlatform200Response to handle AdditionalProperties +func (a ActivatePlatform200Response) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + object["activation_id"], err = json.Marshal(a.ActivationID) + if err != nil { + return nil, fmt.Errorf("error marshaling 'activation_id': %w", err) + } + + object["next_check_in_seconds"], err = json.Marshal(a.NextCheckInSeconds) + if err != nil { + return nil, fmt.Errorf("error marshaling 'next_check_in_seconds': %w", err) + } + + object["team_name"], err = json.Marshal(a.TeamName) + if err != nil { + return nil, fmt.Errorf("error marshaling 'team_name': %w", err) + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for ActivatePlatform205Response. Returns the specified +// element and whether it was found +func (a ActivatePlatform205Response) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for ActivatePlatform205Response +func (a *ActivatePlatform205Response) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for ActivatePlatform205Response to handle AdditionalProperties +func (a *ActivatePlatform205Response) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["button_text"]; found { + err = json.Unmarshal(raw, &a.ButtonText) + if err != nil { + return fmt.Errorf("error reading 'button_text': %w", err) + } + delete(object, "button_text") + } + + if raw, found := object["button_url"]; found { + err = json.Unmarshal(raw, &a.ButtonURL) + if err != nil { + return fmt.Errorf("error reading 'button_url': %w", err) + } + delete(object, "button_url") + } + + if raw, found := object["error"]; found { + err = json.Unmarshal(raw, &a.Error) + if err != nil { + return fmt.Errorf("error reading 'error': %w", err) + } + delete(object, "error") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for ActivatePlatform205Response to handle AdditionalProperties +func (a ActivatePlatform205Response) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + if a.ButtonText != nil { + object["button_text"], err = json.Marshal(a.ButtonText) + if err != nil { + return nil, fmt.Errorf("error marshaling 'button_text': %w", err) + } + } + + if a.ButtonURL != nil { + object["button_url"], err = json.Marshal(a.ButtonURL) + if err != nil { + return nil, fmt.Errorf("error marshaling 'button_url': %w", err) + } + } + + object["error"], err = json.Marshal(a.Error) + if err != nil { + return nil, fmt.Errorf("error marshaling 'error': %w", err) + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for ActivatePlatformRequest. Returns the specified +// element and whether it was found +func (a ActivatePlatformRequest) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for ActivatePlatformRequest +func (a *ActivatePlatformRequest) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for ActivatePlatformRequest to handle AdditionalProperties +func (a *ActivatePlatformRequest) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["api_key"]; found { + err = json.Unmarshal(raw, &a.APIKey) + if err != nil { + return fmt.Errorf("error reading 'api_key': %w", err) + } + delete(object, "api_key") + } + + if raw, found := object["installation_id"]; found { + err = json.Unmarshal(raw, &a.InstallationID) + if err != nil { + return fmt.Errorf("error reading 'installation_id': %w", err) + } + delete(object, "installation_id") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for ActivatePlatformRequest to handle AdditionalProperties +func (a ActivatePlatformRequest) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + object["api_key"], err = json.Marshal(a.APIKey) + if err != nil { + return nil, fmt.Errorf("error marshaling 'api_key': %w", err) + } + + object["installation_id"], err = json.Marshal(a.InstallationID) + if err != nil { + return nil, fmt.Errorf("error marshaling 'installation_id': %w", err) + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + // Getter for additional properties for ConnectorAuthFinishRequestOAuth. Returns the specified // element and whether it was found func (a ConnectorAuthFinishRequestOAuth) Get(fieldName string) (value interface{}, found bool) { @@ -4170,6 +4496,151 @@ func (a LoginUserRequest) MarshalJSON() ([]byte, error) { return json.Marshal(object) } +// Getter for additional properties for RenewPlatformActivation200Response. Returns the specified +// element and whether it was found +func (a RenewPlatformActivation200Response) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for RenewPlatformActivation200Response +func (a *RenewPlatformActivation200Response) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for RenewPlatformActivation200Response to handle AdditionalProperties +func (a *RenewPlatformActivation200Response) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["next_check_in_seconds"]; found { + err = json.Unmarshal(raw, &a.NextCheckInSeconds) + if err != nil { + return fmt.Errorf("error reading 'next_check_in_seconds': %w", err) + } + delete(object, "next_check_in_seconds") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for RenewPlatformActivation200Response to handle AdditionalProperties +func (a RenewPlatformActivation200Response) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + object["next_check_in_seconds"], err = json.Marshal(a.NextCheckInSeconds) + if err != nil { + return nil, fmt.Errorf("error marshaling 'next_check_in_seconds': %w", err) + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for RenewPlatformActivationRequest. Returns the specified +// element and whether it was found +func (a RenewPlatformActivationRequest) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for RenewPlatformActivationRequest +func (a *RenewPlatformActivationRequest) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for RenewPlatformActivationRequest to handle AdditionalProperties +func (a *RenewPlatformActivationRequest) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["activation_id"]; found { + err = json.Unmarshal(raw, &a.ActivationID) + if err != nil { + return fmt.Errorf("error reading 'activation_id': %w", err) + } + delete(object, "activation_id") + } + + if raw, found := object["installation_id"]; found { + err = json.Unmarshal(raw, &a.InstallationID) + if err != nil { + return fmt.Errorf("error reading 'installation_id': %w", err) + } + delete(object, "installation_id") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for RenewPlatformActivationRequest to handle AdditionalProperties +func (a RenewPlatformActivationRequest) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + object["activation_id"], err = json.Marshal(a.ActivationID) + if err != nil { + return nil, fmt.Errorf("error marshaling 'activation_id': %w", err) + } + + object["installation_id"], err = json.Marshal(a.InstallationID) + if err != nil { + return nil, fmt.Errorf("error marshaling 'installation_id': %w", err) + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + // Getter for additional properties for ResetUserPasswordRequest. Returns the specified // element and whether it was found func (a ResetUserPasswordRequest) Get(fieldName string) (value interface{}, found bool) { diff --git a/spec.json b/spec.json index b3f0d0b..e7fc06e 100644 --- a/spec.json +++ b/spec.json @@ -44,6 +44,8 @@ "name" : "managed-databases" }, { "name" : "analytics" + }, { + "name" : "platform" } ], "paths" : { "/" : { @@ -6386,6 +6388,112 @@ }, "tags" : [ "syncs" ] } + }, + "/platform/activate" : { + "post" : { + "description" : "Activate platform usage by API key", + "operationId" : "ActivatePlatform", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ActivatePlatform_request" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ActivatePlatform_200_response" + } + } + }, + "description" : "Success" + }, + "205" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ActivatePlatform_205_response" + } + } + }, + "description" : "Activation method is no longer valid" + }, + "400" : { + "$ref" : "#/components/responses/BadRequest" + }, + "404" : { + "$ref" : "#/components/responses/NotFound" + }, + "429" : { + "$ref" : "#/components/responses/TooManyRequests" + }, + "500" : { + "$ref" : "#/components/responses/InternalError" + } + }, + "security" : [ ], + "tags" : [ "platform" ], + "x-internal" : true + } + }, + "/platform/activate/renew" : { + "post" : { + "description" : "Renew platform activation", + "operationId" : "RenewPlatformActivation", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/RenewPlatformActivation_request" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/RenewPlatformActivation_200_response" + } + } + }, + "description" : "Success" + }, + "205" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ActivatePlatform_205_response" + } + } + }, + "description" : "Activation method is no longer valid" + }, + "400" : { + "$ref" : "#/components/responses/BadRequest" + }, + "404" : { + "$ref" : "#/components/responses/NotFound" + }, + "429" : { + "$ref" : "#/components/responses/TooManyRequests" + }, + "500" : { + "$ref" : "#/components/responses/InternalError" + } + }, + "security" : [ ], + "tags" : [ "platform" ], + "x-internal" : true + } } }, "components" : { @@ -11098,6 +11206,80 @@ } } }, + "ActivatePlatform_request" : { + "additionalProperties" : { }, + "properties" : { + "api_key" : { + "description" : "Team API key to activate platform with", + "x-go-name" : "APIKey" + }, + "installation_id" : { + "description" : "Installation ID of the platform", + "pattern" : "^[a-z0-9]{64}$", + "x-go-name" : "InstallationID" + } + }, + "required" : [ "api_key", "installation_id" ] + }, + "ActivatePlatform_200_response" : { + "additionalProperties" : { }, + "properties" : { + "activation_id" : { + "description" : "Activation ID for the platform", + "format" : "uuid", + "x-go-name" : "ActivationID" + }, + "team_name" : { + "description" : "Name of the team that was activated" + }, + "next_check_in_seconds" : { + "description" : "Time in seconds until the next check in" + } + }, + "required" : [ "activation_id", "next_check_in_seconds", "team_name" ] + }, + "ActivatePlatform_205_response" : { + "additionalProperties" : { }, + "properties" : { + "error" : { + "description" : "Error message" + }, + "button_text" : { + "description" : "Text for the button" + }, + "button_url" : { + "description" : "URL for the button", + "format" : "url", + "x-go-name" : "ButtonURL" + } + }, + "required" : [ "error" ] + }, + "RenewPlatformActivation_request" : { + "additionalProperties" : { }, + "properties" : { + "installation_id" : { + "description" : "Installation ID of the platform", + "pattern" : "^[a-z0-9]{64}$", + "x-go-name" : "InstallationID" + }, + "activation_id" : { + "description" : "Previous activation ID", + "format" : "uuid", + "x-go-name" : "ActivationID" + } + }, + "required" : [ "activation_id", "installation_id" ] + }, + "RenewPlatformActivation_200_response" : { + "additionalProperties" : { }, + "properties" : { + "next_check_in_seconds" : { + "description" : "Time in seconds until the next check in" + } + }, + "required" : [ "next_check_in_seconds" ] + }, "UsageIncrease_tables_inner" : { "properties" : { "name" : {