diff --git a/client.gen.go b/client.gen.go index ddc4d5b..0e8a595 100644 --- a/client.gen.go +++ b/client.gen.go @@ -604,8 +604,10 @@ type ClientInterface interface { // ListUsersByTeam request ListUsersByTeam(ctx context.Context, teamName TeamName, params *ListUsersByTeamParams, reqEditors ...RequestEditorFn) (*http.Response, error) - // UploadImage request - UploadImage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // UploadImageWithBody request with any body + UploadImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UploadImage(ctx context.Context, body UploadImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GetCurrentUser request GetCurrentUser(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2905,8 +2907,20 @@ func (c *Client) ListUsersByTeam(ctx context.Context, teamName TeamName, params return c.Client.Do(req) } -func (c *Client) UploadImage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUploadImageRequest(c.Server) +func (c *Client) UploadImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUploadImageRequestWithBody(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) UploadImage(ctx context.Context, body UploadImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUploadImageRequest(c.Server, body) if err != nil { return nil, err } @@ -11026,8 +11040,19 @@ func NewListUsersByTeamRequest(server string, teamName TeamName, params *ListUse return req, nil } -// NewUploadImageRequest generates requests for UploadImage -func NewUploadImageRequest(server string) (*http.Request, error) { +// NewUploadImageRequest calls the generic UploadImage builder with application/json body +func NewUploadImageRequest(server string, body UploadImageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUploadImageRequestWithBody(server, "application/json", bodyReader) +} + +// NewUploadImageRequestWithBody generates requests for UploadImage with any type of body +func NewUploadImageRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) @@ -11045,11 +11070,13 @@ func NewUploadImageRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } + req.Header.Add("Content-Type", contentType) + return req, nil } @@ -12132,8 +12159,10 @@ type ClientWithResponsesInterface interface { // ListUsersByTeamWithResponse request ListUsersByTeamWithResponse(ctx context.Context, teamName TeamName, params *ListUsersByTeamParams, reqEditors ...RequestEditorFn) (*ListUsersByTeamResponse, error) - // UploadImageWithResponse request - UploadImageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) + // UploadImageWithBodyWithResponse request with any body + UploadImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) + + UploadImageWithResponse(ctx context.Context, body UploadImageJSONRequestBody, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) // GetCurrentUserWithResponse request GetCurrentUserWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetCurrentUserResponse, error) @@ -17754,9 +17783,17 @@ func (c *ClientWithResponses) ListUsersByTeamWithResponse(ctx context.Context, t return ParseListUsersByTeamResponse(rsp) } -// UploadImageWithResponse request returning *UploadImageResponse -func (c *ClientWithResponses) UploadImageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) { - rsp, err := c.UploadImage(ctx, reqEditors...) +// UploadImageWithBodyWithResponse request with arbitrary body returning *UploadImageResponse +func (c *ClientWithResponses) UploadImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) { + rsp, err := c.UploadImageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUploadImageResponse(rsp) +} + +func (c *ClientWithResponses) UploadImageWithResponse(ctx context.Context, body UploadImageJSONRequestBody, reqEditors ...RequestEditorFn) (*UploadImageResponse, error) { + rsp, err := c.UploadImage(ctx, body, reqEditors...) if err != nil { return nil, err } diff --git a/models.gen.go b/models.gen.go index 68de4c6..fb6939a 100644 --- a/models.gen.go +++ b/models.gen.go @@ -63,6 +63,14 @@ const ( ConnectorStatusRevoked ConnectorStatus = "revoked" ) +// Defines values for ContentType. +const ( + ContentTypeImagegif ContentType = "image/gif" + ContentTypeImagejpeg ContentType = "image/jpeg" + ContentTypeImagepng ContentType = "image/png" + ContentTypeImagewebp ContentType = "image/webp" +) + // Defines values for EmailTeamInvitationRequestRole. const ( EmailTeamInvitationRequestRoleAdmin EmailTeamInvitationRequestRole = "admin" @@ -752,6 +760,9 @@ type ConnectorUpdate struct { Name *string `json:"name,omitempty"` } +// ContentType The HTTP Content-Type of the image or asset +type ContentType string + // CreateAddonVersionRequest defines model for CreateAddonVersion_request. type CreateAddonVersionRequest struct { // AddonDeps addon dependencies in the format of ['team_name/type/addon_name@version'] @@ -965,7 +976,10 @@ type GetTeamMemberships200Response struct { // ImageURL defines model for ImageURL. type ImageURL struct { DownloadUrl string `json:"download_url"` - UploadUrl string `json:"upload_url"` + + // RequiredHeaders Required HTTP headers to include for the upload + RequiredHeaders map[string]interface{} `json:"required_headers"` + UploadUrl string `json:"upload_url"` } // Invitation defines model for Invitation. @@ -2593,6 +2607,9 @@ type TeamImage struct { // Name Name of image Name string `json:"name"` + // RequiredHeaders Required HTTP headers to include for the upload + RequiredHeaders map[string]interface{} `json:"required_headers"` + // UploadURL URL to upload image UploadURL *string `json:"upload_url,omitempty"` @@ -2605,6 +2622,9 @@ type TeamImageCreate struct { // Checksum SHA1 checksum of image Checksum string `json:"checksum"` + // ContentType The HTTP Content-Type of the image or asset + ContentType *ContentType `json:"content_type,omitempty"` + // Name Name of image Name string `json:"name"` } @@ -2697,6 +2717,12 @@ type UpdateTeamRequest struct { AdditionalProperties map[string]interface{} `json:"-"` } +// UploadImageRequest defines model for UploadImage_request. +type UploadImageRequest struct { + // ContentType The HTTP Content-Type of the image or asset + ContentType *ContentType `json:"content_type,omitempty"` +} + // UploadPluginUIAssets201Response defines model for UploadPluginUIAssets_201_response. type UploadPluginUIAssets201Response struct { Assets []PluginUIAsset `json:"assets"` @@ -3472,6 +3498,9 @@ type CreateSyncRunProgressJSONRequestBody = CreateSyncRunProgressRequest // IncreaseTeamPluginUsageJSONRequestBody defines body for IncreaseTeamPluginUsage for application/json ContentType. type IncreaseTeamPluginUsageJSONRequestBody = UsageIncrease +// UploadImageJSONRequestBody defines body for UploadImage for application/json ContentType. +type UploadImageJSONRequestBody = UploadImageRequest + // UpdateCurrentUserJSONRequestBody defines body for UpdateCurrentUser for application/json ContentType. type UpdateCurrentUserJSONRequestBody = UpdateCurrentUserRequest diff --git a/spec.json b/spec.json index 25f8fd0..8a1ba91 100644 --- a/spec.json +++ b/spec.json @@ -113,6 +113,16 @@ "description" : "Get a URL to upload image that will be publicly accessible", "operationId" : "UploadImage", "parameters" : [ ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UploadImage_request" + } + } + }, + "required" : false + }, "responses" : { "200" : { "content" : { @@ -6833,6 +6843,12 @@ "required" : [ "message", "status" ], "title" : "Basic Error" }, + "ContentType" : { + "description" : "The HTTP Content-Type of the image or asset", + "enum" : [ "image/jpeg", "image/png", "image/gif", "image/webp" ], + "example" : "image/png", + "type" : "string" + }, "ImageURL" : { "properties" : { "upload_url" : { @@ -6842,9 +6858,17 @@ "download_url" : { "example" : "https://cloudquery.io/api/v1/download/1234567890abcdef1234567890abcdef", "type" : "string" + }, + "required_headers" : { + "additionalProperties" : { + "items" : { + "type" : "string" + } + }, + "description" : "Required HTTP headers to include for the upload" } }, - "required" : [ "download_url", "upload_url" ] + "required" : [ "download_url", "required_headers", "upload_url" ] }, "TeamName" : { "description" : "The unique name for the team.", @@ -8153,6 +8177,9 @@ "minLength" : 40, "pattern" : "^[a-f0-9]+$", "type" : "string" + }, + "content_type" : { + "$ref" : "#/components/schemas/ContentType" } }, "required" : [ "checksum", "name" ], @@ -8177,9 +8204,17 @@ "description" : "URL to upload image", "type" : "string", "x-go-name" : "UploadURL" + }, + "required_headers" : { + "additionalProperties" : { + "items" : { + "type" : "string" + } + }, + "description" : "Required HTTP headers to include for the upload" } }, - "required" : [ "checksum", "name", "url" ] + "required" : [ "checksum", "name", "required_headers", "url" ] }, "AddonOrderID" : { "description" : "ID of the addon order", @@ -10088,6 +10123,13 @@ }, "required" : [ "base_url", "return_url" ] }, + "UploadImage_request" : { + "properties" : { + "content_type" : { + "$ref" : "#/components/schemas/ContentType" + } + } + }, "ListPluginNotificationRequests_200_response" : { "properties" : { "items" : { @@ -10710,7 +10752,8 @@ "format" : "email" }, "subdomain" : { - "description" : "Subdomain to use in the URL" + "description" : "Subdomain to use in the URL", + "pattern" : "^[a-zA-Z0-9-]+$" } }, "required" : [ "email" ] @@ -10724,10 +10767,12 @@ }, "return_to" : { "description" : "Return to this URL after verification", - "format" : "url" + "format" : "url", + "pattern" : "^https:\\/\\/(.*\\.)?cloudquery\\.io(\\/.*)?$" }, "subdomain" : { - "description" : "Subdomain to use in the URL" + "description" : "Subdomain to use in the URL", + "pattern" : "^[a-zA-Z0-9-]+$" } }, "required" : [ "email" ]