diff --git a/client.gen.go b/client.gen.go index bb301be..b69dd85 100644 --- a/client.gen.go +++ b/client.gen.go @@ -156,6 +156,11 @@ type ClientInterface interface { // GetPlatformFlags request GetPlatformFlags(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // ReportPlatformDataWithBody request with any body + ReportPlatformDataWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ReportPlatformData(ctx context.Context, body ReportPlatformDataJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListPluginNotificationRequests request ListPluginNotificationRequests(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -955,6 +960,30 @@ func (c *Client) GetPlatformFlags(ctx context.Context, reqEditors ...RequestEdit return c.Client.Do(req) } +func (c *Client) ReportPlatformDataWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReportPlatformDataRequestWithBody(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) ReportPlatformData(ctx context.Context, body ReportPlatformDataJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReportPlatformDataRequest(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 { @@ -4159,6 +4188,46 @@ func NewGetPlatformFlagsRequest(server string) (*http.Request, error) { return req, nil } +// NewReportPlatformDataRequest calls the generic ReportPlatformData builder with application/json body +func NewReportPlatformDataRequest(server string, body ReportPlatformDataJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewReportPlatformDataRequestWithBody(server, "application/json", bodyReader) +} + +// NewReportPlatformDataRequestWithBody generates requests for ReportPlatformData with any type of body +func NewReportPlatformDataRequestWithBody(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/report") + 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 @@ -11981,6 +12050,11 @@ type ClientWithResponsesInterface interface { // GetPlatformFlagsWithResponse request GetPlatformFlagsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetPlatformFlagsResponse, error) + // ReportPlatformDataWithBodyWithResponse request with any body + ReportPlatformDataWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ReportPlatformDataResponse, error) + + ReportPlatformDataWithResponse(ctx context.Context, body ReportPlatformDataJSONRequestBody, reqEditors ...RequestEditorFn) (*ReportPlatformDataResponse, error) + // ListPluginNotificationRequestsWithResponse request ListPluginNotificationRequestsWithResponse(ctx context.Context, params *ListPluginNotificationRequestsParams, reqEditors ...RequestEditorFn) (*ListPluginNotificationRequestsResponse, error) @@ -12934,6 +13008,31 @@ func (r GetPlatformFlagsResponse) StatusCode() int { return 0 } +type ReportPlatformDataResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *BadRequest + JSON404 *NotFound + JSON429 *TooManyRequests + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r ReportPlatformDataResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReportPlatformDataResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListPluginNotificationRequestsResponse struct { Body []byte HTTPResponse *http.Response @@ -16742,6 +16841,23 @@ func (c *ClientWithResponses) GetPlatformFlagsWithResponse(ctx context.Context, return ParseGetPlatformFlagsResponse(rsp) } +// ReportPlatformDataWithBodyWithResponse request with arbitrary body returning *ReportPlatformDataResponse +func (c *ClientWithResponses) ReportPlatformDataWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ReportPlatformDataResponse, error) { + rsp, err := c.ReportPlatformDataWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseReportPlatformDataResponse(rsp) +} + +func (c *ClientWithResponses) ReportPlatformDataWithResponse(ctx context.Context, body ReportPlatformDataJSONRequestBody, reqEditors ...RequestEditorFn) (*ReportPlatformDataResponse, error) { + rsp, err := c.ReportPlatformData(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseReportPlatformDataResponse(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...) @@ -19247,6 +19363,53 @@ func ParseGetPlatformFlagsResponse(rsp *http.Response) (*GetPlatformFlagsRespons return response, nil } +// ParseReportPlatformDataResponse parses an HTTP response from a ReportPlatformDataWithResponse call +func ParseReportPlatformDataResponse(rsp *http.Response) (*ReportPlatformDataResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReportPlatformDataResponse{ + 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 == 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 2bb19bd..a7c1969 100644 --- a/models.gen.go +++ b/models.gen.go @@ -2047,6 +2047,15 @@ type RenewPlatformActivationRequest struct { AdditionalProperties map[string]interface{} `json:"-"` } +// ReportPlatformDataRequest defines model for ReportPlatformData_request. +type ReportPlatformDataRequest struct { + // InstallationID Installation ID of the platform + InstallationID interface{} `json:"installation_id"` + UserAdditions interface{} `json:"user_additions"` + UserRemovals interface{} `json:"user_removals"` + AdditionalProperties map[string]interface{} `json:"-"` +} + // ResetUserPasswordRequest defines model for ResetUserPassword_request. type ResetUserPasswordRequest struct { // Email Email address to reset @@ -3480,6 +3489,9 @@ type ActivatePlatformJSONRequestBody = ActivatePlatformRequest // RenewPlatformActivationJSONRequestBody defines body for RenewPlatformActivation for application/json ContentType. type RenewPlatformActivationJSONRequestBody = RenewPlatformActivationRequest +// ReportPlatformDataJSONRequestBody defines body for ReportPlatformData for application/json ContentType. +type ReportPlatformDataJSONRequestBody = ReportPlatformDataRequest + // CreatePluginNotificationRequestJSONRequestBody defines body for CreatePluginNotificationRequest for application/json ContentType. type CreatePluginNotificationRequestJSONRequestBody = PluginNotificationRequestCreate @@ -4700,6 +4712,98 @@ func (a RenewPlatformActivationRequest) MarshalJSON() ([]byte, error) { return json.Marshal(object) } +// Getter for additional properties for ReportPlatformDataRequest. Returns the specified +// element and whether it was found +func (a ReportPlatformDataRequest) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for ReportPlatformDataRequest +func (a *ReportPlatformDataRequest) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for ReportPlatformDataRequest to handle AdditionalProperties +func (a *ReportPlatformDataRequest) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + 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 raw, found := object["user_additions"]; found { + err = json.Unmarshal(raw, &a.UserAdditions) + if err != nil { + return fmt.Errorf("error reading 'user_additions': %w", err) + } + delete(object, "user_additions") + } + + if raw, found := object["user_removals"]; found { + err = json.Unmarshal(raw, &a.UserRemovals) + if err != nil { + return fmt.Errorf("error reading 'user_removals': %w", err) + } + delete(object, "user_removals") + } + + 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 ReportPlatformDataRequest to handle AdditionalProperties +func (a ReportPlatformDataRequest) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + object["installation_id"], err = json.Marshal(a.InstallationID) + if err != nil { + return nil, fmt.Errorf("error marshaling 'installation_id': %w", err) + } + + object["user_additions"], err = json.Marshal(a.UserAdditions) + if err != nil { + return nil, fmt.Errorf("error marshaling 'user_additions': %w", err) + } + + object["user_removals"], err = json.Marshal(a.UserRemovals) + if err != nil { + return nil, fmt.Errorf("error marshaling 'user_removals': %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 5e72d14..8f0b26f 100644 --- a/spec.json +++ b/spec.json @@ -6534,6 +6534,41 @@ "x-internal" : true } }, + "/platform/report" : { + "post" : { + "description" : "Report platform data", + "operationId" : "ReportPlatformData", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ReportPlatformData_request" + } + } + }, + "required" : true + }, + "responses" : { + "204" : { + "description" : "Success" + }, + "400" : { + "$ref" : "#/components/responses/BadRequest" + }, + "404" : { + "$ref" : "#/components/responses/NotFound" + }, + "429" : { + "$ref" : "#/components/responses/TooManyRequests" + }, + "500" : { + "$ref" : "#/components/responses/InternalError" + } + }, + "tags" : [ "platform" ], + "x-internal" : true + } + }, "/platform/flags" : { "get" : { "description" : "Get platform feature flags", @@ -11444,6 +11479,23 @@ }, "required" : [ "next_check_in_seconds" ] }, + "ReportPlatformData_request" : { + "additionalProperties" : { }, + "properties" : { + "installation_id" : { + "description" : "Installation ID of the platform", + "pattern" : "^[a-z0-9]{64}$", + "x-go-name" : "InstallationID" + }, + "user_additions" : { + "items" : { } + }, + "user_removals" : { + "items" : { } + } + }, + "required" : [ "installation_id", "user_additions", "user_removals" ] + }, "UsageIncrease_tables_inner" : { "properties" : { "name" : {