From 2193d115095762bcf25e23f42b3b7c187a65eeb4 Mon Sep 17 00:00:00 2001 From: cq-bot Date: Fri, 29 Sep 2023 12:31:42 +0000 Subject: [PATCH] fix: Generate CloudQuery Go API Client from `spec.json` --- client.gen.go | 78 ++++++++++++----------------------------------- models.gen.go | 49 +++++++++++++++--------------- spec.json | 84 +++++++++++++++++++-------------------------------- 3 files changed, 75 insertions(+), 136 deletions(-) diff --git a/client.gen.go b/client.gen.go index 308704b..c9c435c 100644 --- a/client.gen.go +++ b/client.gen.go @@ -1152,7 +1152,7 @@ func NewUpdatePluginRequestWithBody(server string, teamName TeamName, pluginKind return nil, err } - req, err := http.NewRequest("PUT", queryURL.String(), body) + req, err := http.NewRequest("PATCH", queryURL.String(), body) if err != nil { return nil, err } @@ -2822,9 +2822,9 @@ func NewListPluginsByTeamRequest(server string, teamName TeamName, params *ListP } - if params.IncludeUnlisted != nil { + if params.IncludePrivate != nil { - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "include_unlisted", runtime.ParamLocationQuery, *params.IncludeUnlisted); err != nil { + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "include_private", runtime.ParamLocationQuery, *params.IncludePrivate); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err @@ -3361,7 +3361,6 @@ type ListPluginsResponse struct { Metadata ListMetadata `json:"metadata"` } JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON500 *InternalError } @@ -3437,7 +3436,7 @@ type GetPluginResponse struct { HTTPResponse *http.Response JSON200 *Plugin JSON401 *RequiresAuthentication - JSON403 *Forbidden + JSON404 *NotFound JSON500 *InternalError } @@ -3463,6 +3462,7 @@ type UpdatePluginResponse struct { JSON200 *Plugin JSON400 *BadRequest JSON403 *Forbidden + JSON404 *NotFound JSON500 *InternalError } @@ -3490,7 +3490,7 @@ type ListPluginVersionsResponse struct { Metadata ListMetadata `json:"metadata"` } JSON401 *RequiresAuthentication - JSON403 *Forbidden + JSON404 *NotFound JSON500 *InternalError } @@ -3542,7 +3542,6 @@ type UpdatePluginVersionResponse struct { JSON200 *PluginVersion JSON400 *BadRequest JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON404 *NotFound JSON500 *InternalError } @@ -3594,7 +3593,6 @@ type DownloadPluginAssetResponse struct { Body []byte HTTPResponse *http.Response JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON404 *NotFound JSON500 *InternalError } @@ -3674,7 +3672,6 @@ type ListPluginVersionDocsResponse struct { Metadata ListMetadata `json:"metadata"` } JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON404 *NotFound JSON500 *InternalError } @@ -3758,7 +3755,6 @@ type ListPluginVersionTablesResponse struct { Metadata ListMetadata `json:"metadata"` } JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON404 *NotFound JSON500 *InternalError } @@ -3813,7 +3809,6 @@ type GetPluginVersionTableResponse struct { HTTPResponse *http.Response JSON200 *PluginTableDetails JSON401 *RequiresAuthentication - JSON403 *Forbidden JSON404 *NotFound JSON500 *InternalError } @@ -4868,13 +4863,6 @@ func ParseListPluginsResponse(rsp *http.Response) (*ListPluginsResponse, error) } 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 == 500: var dest InternalError if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -5016,12 +5004,12 @@ func ParseGetPluginResponse(rsp *http.Response) (*GetPluginResponse, error) { } response.JSON401 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest Forbidden + 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.JSON403 = &dest + response.JSON404 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest InternalError @@ -5070,6 +5058,13 @@ func ParseUpdatePluginResponse(rsp *http.Response) (*UpdatePluginResponse, error } 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 { @@ -5113,12 +5108,12 @@ func ParseListPluginVersionsResponse(rsp *http.Response) (*ListPluginVersionsRes } response.JSON401 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: - var dest Forbidden + 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.JSON403 = &dest + response.JSON404 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest InternalError @@ -5221,13 +5216,6 @@ func ParseUpdatePluginVersionResponse(rsp *http.Response) (*UpdatePluginVersionR } 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 { @@ -5329,13 +5317,6 @@ func ParseDownloadPluginAssetResponse(rsp *http.Response) (*DownloadPluginAssetR } 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 { @@ -5487,13 +5468,6 @@ func ParseListPluginVersionDocsResponse(rsp *http.Response) (*ListPluginVersionD } 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 { @@ -5661,13 +5635,6 @@ func ParseListPluginVersionTablesResponse(rsp *http.Response) (*ListPluginVersio } 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 { @@ -5778,13 +5745,6 @@ func ParseGetPluginVersionTableResponse(rsp *http.Response) (*GetPluginVersionTa } 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 { diff --git a/models.gen.go b/models.gen.go index fecb171..eb876a2 100644 --- a/models.gen.go +++ b/models.gen.go @@ -171,16 +171,16 @@ type Plugin struct { // Kind The kind of plugin, ie. source or destination. Kind PluginKind `json:"kind"` - - // Listed True if the plugin is publicly listed, false otherwise - Listed *bool `json:"listed,omitempty"` - Logo string `json:"logo"` + Logo string `json:"logo"` // Name The unique name for the plugin. Name PluginName `json:"name"` // Official True if the plugin is maintained by CloudQuery, false otherwise - Official bool `json:"official"` + Official bool `json:"official"` + + // Public Whether the plugin is listed in the CloudQuery Hub. If false, the plugin will not be shown in the CloudQuery Hub and will only be visible to members of the plugin's team. + Public *bool `json:"public,omitempty"` Repository *string `json:"repository,omitempty"` ShortDescription string `json:"short_description"` @@ -197,8 +197,7 @@ type PluginCategory string // PluginCreate defines model for PluginCreate. type PluginCreate struct { // Category Supported categories for plugins - Category PluginCategory `json:"category"` - Destination *bool `json:"destination,omitempty"` + Category PluginCategory `json:"category"` // DisplayName The plugin's display name, as shown in the CloudQuery Hub. DisplayName string `json:"display_name"` @@ -211,12 +210,14 @@ type PluginCreate struct { Logo string `json:"logo"` // Name The unique name for the plugin. - Name PluginName `json:"name"` - Repository *string `json:"repository,omitempty"` + Name PluginName `json:"name"` + + // Public Whether the plugin is listed in the CloudQuery Hub. If false, the plugin will not be shown in the CloudQuery Hub and will only be visible to members of the team. + Public bool `json:"public"` + Repository *string `json:"repository,omitempty"` // ShortDescription Short description of the plugin. This will be shown in the CloudQuery Hub. ShortDescription string `json:"short_description"` - Source *bool `json:"source,omitempty"` // TeamName The unique name for the team. TeamName TeamName `json:"team_name"` @@ -363,24 +364,24 @@ type PluginTier string // PluginUpdate defines model for PluginUpdate. type PluginUpdate struct { // Category Supported categories for plugins - Category PluginCategory `json:"category"` + Category *PluginCategory `json:"category,omitempty"` // DisplayName The plugin's display name, as shown in the CloudQuery Hub. - DisplayName string `json:"display_name"` + DisplayName *string `json:"display_name,omitempty"` Homepage *string `json:"homepage,omitempty"` - // Listed If plugin is not listed, it won't be visible or accessible in the registry. - Listed *bool `json:"listed,omitempty"` - // Logo URL to the plugin's logo. This will be shown in the CloudQuery Hub. This must point to https://images.cloudquery.io/... - Logo string `json:"logo"` + Logo *string `json:"logo,omitempty"` + + // Public If plugin is not public, it won't be visible to other teams in the CloudQuery Hub. + Public *bool `json:"public,omitempty"` Repository *string `json:"repository,omitempty"` // ShortDescription Short description of the plugin. This will be shown in the CloudQuery Hub. - ShortDescription string `json:"short_description"` + ShortDescription *string `json:"short_description,omitempty"` // Tier Supported tiers for plugins - Tier PluginTier `json:"tier"` + Tier *PluginTier `json:"tier,omitempty"` } // PluginVersion CloudQuery Plugin Version @@ -409,7 +410,7 @@ type PluginVersion struct { // PublishedAt The date and time the plugin version was set to non-draft (published). PublishedAt *time.Time `json:"published_at,omitempty"` - // Retracted If a plugin version is retracted, assets will still be available for download, but will not be counted as the latest version. + // Retracted If a plugin version is retracted, assets will still be available for download, but the version will be marked as retracted to discourage use. Retracted bool `json:"retracted"` // SupportedTargets The targets supported by this plugin version, formatted as _ @@ -436,7 +437,7 @@ type PluginVersionUpdate struct { // Protocols The supported CloudQuery protocols by this plugin version Protocols *[]int `json:"protocols,omitempty"` - // Retracted If a plugin version is retracted, assets will still be available for download, but will not be counted as the latest version. + // Retracted If a plugin version is retracted, assets will still be available for download, but the version will be marked as retracted to discourage use. Retracted *bool `json:"retracted,omitempty"` SupportedTargets *[]string `json:"supported_targets,omitempty"` } @@ -482,8 +483,8 @@ type APIKeyName = string // IncludeDrafts defines model for include_drafts. type IncludeDrafts = bool -// IncludeUnlisted defines model for include_unlisted. -type IncludeUnlisted = bool +// IncludePrivate defines model for include_private. +type IncludePrivate = bool // Page defines model for page. type Page = int64 @@ -690,8 +691,8 @@ type ListPluginsByTeamParams struct { // PerPage The number of results per page (max 1000). PerPage *PerPage `form:"per_page,omitempty" json:"per_page,omitempty"` - // IncludeUnlisted Whether to include unlisted plugins - IncludeUnlisted *IncludeUnlisted `form:"include_unlisted,omitempty" json:"include_unlisted,omitempty"` + // IncludePrivate Whether to include private plugins + IncludePrivate *IncludePrivate `form:"include_private,omitempty" json:"include_private,omitempty"` } // ListUsersByTeamParams defines parameters for ListUsersByTeam. diff --git a/spec.json b/spec.json index 8a5f21c..e772d54 100644 --- a/spec.json +++ b/spec.json @@ -146,9 +146,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "500": { "$ref": "#/components/responses/InternalError" } @@ -227,8 +224,8 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" + "404": { + "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/InternalError" @@ -239,7 +236,7 @@ "plugins" ] }, - "put": { + "patch": { "description": "Update a plugin", "operationId": "UpdatePlugin", "tags": [ @@ -282,6 +279,9 @@ "403": { "$ref": "#/components/responses/Forbidden" }, + "404": { + "$ref": "#/components/responses/NotFound" + }, "500": { "$ref": "#/components/responses/InternalError" } @@ -382,8 +382,8 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" + "404": { + "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/InternalError" @@ -397,7 +397,7 @@ }, "/plugins/{team_name}/{plugin_kind}/{plugin_name}/versions/{version_name}": { "get": { - "description": "Get details about a given plugin version. Use `latest` as version to get the latest version.", + "description": "Get details about a given plugin version.", "operationId": "GetPluginVersion", "parameters": [ { @@ -599,9 +599,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "404": { "$ref": "#/components/responses/NotFound" }, @@ -667,9 +664,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "404": { "$ref": "#/components/responses/NotFound" }, @@ -872,9 +866,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "404": { "$ref": "#/components/responses/NotFound" }, @@ -1065,9 +1056,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "404": { "$ref": "#/components/responses/NotFound" }, @@ -1116,9 +1104,6 @@ "401": { "$ref": "#/components/responses/RequiresAuthentication" }, - "403": { - "$ref": "#/components/responses/Forbidden" - }, "404": { "$ref": "#/components/responses/NotFound" }, @@ -1402,7 +1387,7 @@ "$ref": "#/components/parameters/per_page" }, { - "$ref": "#/components/parameters/include_unlisted" + "$ref": "#/components/parameters/include_private" } ], "responses": { @@ -2317,8 +2302,8 @@ "tier": { "$ref": "#/components/schemas/PluginTier" }, - "listed": { - "description": "True if the plugin is publicly listed, false otherwise", + "public": { + "description": "Whether the plugin is listed in the CloudQuery Hub. If false, the plugin will not be shown in the CloudQuery Hub and will only be visible to members of the plugin's team.", "type": "boolean" } }, @@ -2357,7 +2342,8 @@ "tier", "display_name", "short_description", - "logo" + "logo", + "public" ], "properties": { "team_name": { @@ -2397,11 +2383,10 @@ "type": "string", "example": "https://github.com/cloudquery/cloudquery" }, - "source": { - "type": "boolean" - }, - "destination": { - "type": "boolean" + "public": { + "type": "boolean", + "description": "Whether the plugin is listed in the CloudQuery Hub. If false, the plugin will not be shown in the CloudQuery Hub and will only be visible to members of the team.", + "example": true }, "logo": { "type": "string", @@ -2436,13 +2421,6 @@ }, "PluginUpdate": { "type": "object", - "required": [ - "category", - "tier", - "display_name", - "short_description", - "logo" - ], "properties": { "category": { "$ref": "#/components/schemas/PluginCategory" @@ -2477,9 +2455,9 @@ "description": "URL to the plugin's logo. This will be shown in the CloudQuery Hub. This must point to https://images.cloudquery.io/...", "example": "https://images.cloudquery.io/logos/aws.png" }, - "listed": { + "public": { "type": "boolean", - "description": "If plugin is not listed, it won't be visible or accessible in the registry." + "description": "If plugin is not public, it won't be visible to other teams in the CloudQuery Hub." } } }, @@ -2529,7 +2507,7 @@ }, "retracted": { "type": "boolean", - "description": "If a plugin version is retracted, assets will still be available for download, but will not be counted as the latest version." + "description": "If a plugin version is retracted, assets will still be available for download, but the version will be marked as retracted to discourage use." }, "protocols": { "type": "array", @@ -2587,7 +2565,7 @@ }, "retracted": { "type": "boolean", - "description": "If a plugin version is retracted, assets will still be available for download, but will not be counted as the latest version." + "description": "If a plugin version is retracted, assets will still be available for download, but the version will be marked as retracted to discourage use." }, "protocols": { "type": "array", @@ -3067,25 +3045,25 @@ }, "description": "Requires authentication" }, - "Forbidden": { + "BadRequest": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BasicError" + "$ref": "#/components/schemas/BadRequestError" } } }, - "description": "Forbidden" + "description": "Bad request" }, - "BadRequest": { + "Forbidden": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BadRequestError" + "$ref": "#/components/schemas/BasicError" } } }, - "description": "Bad request" + "description": "Forbidden" }, "NotFound": { "content": { @@ -3210,10 +3188,10 @@ "type": "string" } }, - "include_unlisted": { - "description": "Whether to include unlisted plugins", + "include_private": { + "description": "Whether to include private plugins", "in": "query", - "name": "include_unlisted", + "name": "include_private", "required": false, "schema": { "type": "boolean"