diff --git a/client.gen.go b/client.gen.go index 1ae90dd..b809063 100644 --- a/client.gen.go +++ b/client.gen.go @@ -219,6 +219,9 @@ type ClientInterface interface { // GetPluginVersionTable request GetPluginVersionTable(ctx context.Context, teamName TeamName, pluginKind PluginKind, pluginName PluginName, versionName VersionName, tableName string, reqEditors ...RequestEditorFn) (*http.Response, error) + // AuthRegistryRequest request + AuthRegistryRequest(ctx context.Context, params *AuthRegistryRequestParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListTeams request ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -935,6 +938,18 @@ func (c *Client) GetPluginVersionTable(ctx context.Context, teamName TeamName, p return c.Client.Do(req) } +func (c *Client) AuthRegistryRequest(ctx context.Context, params *AuthRegistryRequestParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAuthRegistryRequestRequest(c.Server, params) + 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) ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListTeamsRequest(c.Server, params) if err != nil { @@ -3740,6 +3755,86 @@ func NewGetPluginVersionTableRequest(server string, teamName TeamName, pluginKin return req, nil } +// NewAuthRegistryRequestRequest generates requests for AuthRegistryRequest +func NewAuthRegistryRequestRequest(server string, params *AuthRegistryRequestParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/registry/auth") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Account != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "account", runtime.ParamLocationQuery, *params.Account); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Scope != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "scope", runtime.ParamLocationQuery, *params.Scope); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.XPluginVersion != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "X-Plugin-Version", runtime.ParamLocationHeader, *params.XPluginVersion) + if err != nil { + return nil, err + } + + req.Header.Set("X-Plugin-Version", headerParam0) + } + + } + + return req, nil +} + // NewListTeamsRequest generates requests for ListTeams func NewListTeamsRequest(server string, params *ListTeamsParams) (*http.Request, error) { var err error @@ -6102,6 +6197,9 @@ type ClientWithResponsesInterface interface { // GetPluginVersionTableWithResponse request GetPluginVersionTableWithResponse(ctx context.Context, teamName TeamName, pluginKind PluginKind, pluginName PluginName, versionName VersionName, tableName string, reqEditors ...RequestEditorFn) (*GetPluginVersionTableResponse, error) + // AuthRegistryRequestWithResponse request + AuthRegistryRequestWithResponse(ctx context.Context, params *AuthRegistryRequestParams, reqEditors ...RequestEditorFn) (*AuthRegistryRequestResponse, error) + // ListTeamsWithResponse request ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) @@ -7147,6 +7245,32 @@ func (r GetPluginVersionTableResponse) StatusCode() int { return 0 } +type AuthRegistryRequestResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *RegistryAuthToken + JSON400 *BadRequest + JSON401 *RequiresAuthentication + JSON422 *UnprocessableEntity + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r AuthRegistryRequestResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AuthRegistryRequestResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListTeamsResponse struct { Body []byte HTTPResponse *http.Response @@ -7531,6 +7655,7 @@ type EmailTeamInvitationResponse struct { JSON200 *Invitation JSON400 *BadRequest JSON403 *Forbidden + JSON422 *UnprocessableEntity JSON500 *InternalError } @@ -8617,6 +8742,15 @@ func (c *ClientWithResponses) GetPluginVersionTableWithResponse(ctx context.Cont return ParseGetPluginVersionTableResponse(rsp) } +// AuthRegistryRequestWithResponse request returning *AuthRegistryRequestResponse +func (c *ClientWithResponses) AuthRegistryRequestWithResponse(ctx context.Context, params *AuthRegistryRequestParams, reqEditors ...RequestEditorFn) (*AuthRegistryRequestResponse, error) { + rsp, err := c.AuthRegistryRequest(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthRegistryRequestResponse(rsp) +} + // ListTeamsWithResponse request returning *ListTeamsResponse func (c *ClientWithResponses) ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) { rsp, err := c.ListTeams(ctx, params, reqEditors...) @@ -10892,6 +11026,60 @@ func ParseGetPluginVersionTableResponse(rsp *http.Response) (*GetPluginVersionTa return response, nil } +// ParseAuthRegistryRequestResponse parses an HTTP response from a AuthRegistryRequestWithResponse call +func ParseAuthRegistryRequestResponse(rsp *http.Response) (*AuthRegistryRequestResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AuthRegistryRequestResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RegistryAuthToken + 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 == 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 == 422: + var dest UnprocessableEntity + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &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 +} + // ParseListTeamsResponse parses an HTTP response from a ListTeamsWithResponse call func ParseListTeamsResponse(rsp *http.Response) (*ListTeamsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -11691,6 +11879,13 @@ func ParseEmailTeamInvitationResponse(rsp *http.Response) (*EmailTeamInvitationR } response.JSON403 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest UnprocessableEntity + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: var dest InternalError if err := json.Unmarshal(bodyBytes, &dest); err != nil { diff --git a/models.gen.go b/models.gen.go index dca01a8..90d7af4 100644 --- a/models.gen.go +++ b/models.gen.go @@ -10,6 +10,7 @@ import ( ) const ( + BasicAuthScopes = "basicAuth.Scopes" BearerAuthScopes = "bearerAuth.Scopes" ) @@ -1010,6 +1011,12 @@ type PluginVersionUpdate struct { SupportedTargets *[]string `json:"supported_targets,omitempty"` } +// RegistryAuthToken JWT token for the image registry +type RegistryAuthToken struct { + AccessToken string `json:"access_token"` + Token string `json:"token"` +} + // ReleaseURL defines model for ReleaseURL. type ReleaseURL struct { Url string `json:"url"` @@ -1356,6 +1363,18 @@ type CreatePluginVersionTablesJSONBody struct { Tables []PluginTableCreate `json:"tables"` } +// AuthRegistryRequestParams defines parameters for AuthRegistryRequest. +type AuthRegistryRequestParams struct { + // Account Username used for `docker login` + Account *string `form:"account,omitempty" json:"account,omitempty"` + + // Scope Multi-value string containing the repository being access and the operation type (push/pull) + Scope *string `form:"scope,omitempty" json:"scope,omitempty"` + + // XPluginVersion Plugin version name + XPluginVersion *string `json:"X-Plugin-Version,omitempty"` +} + // ListTeamsParams defines parameters for ListTeams. type ListTeamsParams struct { // PerPage The number of results per page (max 1000). diff --git a/spec.json b/spec.json index 6c02d3e..e7bac33 100644 --- a/spec.json +++ b/spec.json @@ -52,6 +52,9 @@ }, { "name": "addons" + }, + { + "name": "registry" } ], "paths": { @@ -3436,6 +3439,9 @@ "403": { "$ref": "#/components/responses/Forbidden" }, + "422": { + "$ref": "#/components/responses/UnprocessableEntity" + }, "500": { "$ref": "#/components/responses/InternalError" } @@ -4095,6 +4101,71 @@ } } } + }, + "/registry/auth": { + "get": { + "description": "Performs authentication and authorization for our image registry.", + "operationId": "AuthRegistryRequest", + "parameters": [ + { + "in": "header", + "name": "X-Plugin-Version", + "schema": { + "type": "string" + }, + "description": "Plugin version name", + "example": "v1.0.0" + }, + { + "in": "query", + "name": "account", + "schema": { + "type": "string" + }, + "description": "Username used for `docker login`" + }, + { + "in": "query", + "name": "scope", + "schema": { + "type": "string" + }, + "description": "Multi-value string containing the repository being access and the operation type (push/pull)" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RegistryAuthToken" + } + } + }, + "description": "Response" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/RequiresAuthentication" + }, + "422": { + "$ref": "#/components/responses/UnprocessableEntity" + }, + "500": { + "$ref": "#/components/responses/InternalError" + } + }, + "tags": [ + "registry" + ], + "security": [ + { + "basicAuth": [] + } + ] + } } }, "components": { @@ -4102,6 +4173,10 @@ "bearerAuth": { "scheme": "bearer", "type": "http" + }, + "basicAuth": { + "scheme": "basic", + "type": "http" } }, "schemas": { @@ -6008,6 +6083,23 @@ "$ref": "#/components/schemas/APIKeyScope" } } + }, + "RegistryAuthToken": { + "type": "object", + "description": "JWT token for the image registry", + "additionalProperties": false, + "properties": { + "access_token": { + "type": "string" + }, + "token": { + "type": "string" + } + }, + "required": [ + "access_token", + "token" + ] } }, "responses": {