diff --git a/.gitignore b/.gitignore index 7963b68..b5fa677 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,6 @@ Temporary Items bin/ k6 + +### Goland ### +.idea/ diff --git a/pkg/harbor/client/artifact/add_label_parameters.go b/pkg/harbor/client/artifact/add_label_parameters.go index d142eef..328dbc7 100644 --- a/pkg/harbor/client/artifact/add_label_parameters.go +++ b/pkg/harbor/client/artifact/add_label_parameters.go @@ -89,7 +89,7 @@ type AddLabelParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/artifact_client.go b/pkg/harbor/client/artifact/artifact_client.go index 0520e73..6f4f7df 100644 --- a/pkg/harbor/client/artifact/artifact_client.go +++ b/pkg/harbor/client/artifact/artifact_client.go @@ -58,6 +58,11 @@ type API interface { Get the vulnerabilities addition of the artifact specified by the reference under the project and repository.*/ GetVulnerabilitiesAddition(ctx context.Context, params *GetVulnerabilitiesAdditionParams) (*GetVulnerabilitiesAdditionOK, error) + /* + ListAccessories lists accessories + + List accessories of the specific artifact*/ + ListAccessories(ctx context.Context, params *ListAccessoriesParams) (*ListAccessoriesOK, error) /* ListArtifacts lists artifacts @@ -341,6 +346,8 @@ func (a *Client) GetAddition(ctx context.Context, params *GetAdditionParams) (*G return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *GetAdditionNotFound: return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetAdditionUnprocessableEntity: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *GetAdditionInternalServerError: return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) } @@ -433,6 +440,48 @@ func (a *Client) GetVulnerabilitiesAddition(ctx context.Context, params *GetVuln panic(msg) } +/* +ListAccessories lists accessories + +List accessories of the specific artifact +*/ +func (a *Client) ListAccessories(ctx context.Context, params *ListAccessoriesParams) (*ListAccessoriesOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listAccessories", + Method: "GET", + PathPattern: "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListAccessoriesReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListAccessoriesOK: + return value, nil + case *ListAccessoriesBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListAccessoriesUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListAccessoriesForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListAccessoriesNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListAccessoriesInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for listAccessories: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* ListArtifacts lists artifacts diff --git a/pkg/harbor/client/artifact/copy_artifact_parameters.go b/pkg/harbor/client/artifact/copy_artifact_parameters.go index 76e6e78..0689c25 100644 --- a/pkg/harbor/client/artifact/copy_artifact_parameters.go +++ b/pkg/harbor/client/artifact/copy_artifact_parameters.go @@ -81,7 +81,7 @@ type CopyArtifactParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/create_tag_parameters.go b/pkg/harbor/client/artifact/create_tag_parameters.go index 8aa53ca..f18ca0d 100644 --- a/pkg/harbor/client/artifact/create_tag_parameters.go +++ b/pkg/harbor/client/artifact/create_tag_parameters.go @@ -83,7 +83,7 @@ type CreateTagParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/delete_artifact_parameters.go b/pkg/harbor/client/artifact/delete_artifact_parameters.go index addd010..40aa844 100644 --- a/pkg/harbor/client/artifact/delete_artifact_parameters.go +++ b/pkg/harbor/client/artifact/delete_artifact_parameters.go @@ -81,7 +81,7 @@ type DeleteArtifactParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/delete_tag_parameters.go b/pkg/harbor/client/artifact/delete_tag_parameters.go index 209fdc1..a2bebb2 100644 --- a/pkg/harbor/client/artifact/delete_tag_parameters.go +++ b/pkg/harbor/client/artifact/delete_tag_parameters.go @@ -81,7 +81,7 @@ type DeleteTagParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/get_addition_parameters.go b/pkg/harbor/client/artifact/get_addition_parameters.go index 5f2a7a0..7f8a065 100644 --- a/pkg/harbor/client/artifact/get_addition_parameters.go +++ b/pkg/harbor/client/artifact/get_addition_parameters.go @@ -87,7 +87,7 @@ type GetAdditionParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/artifact/get_addition_responses.go b/pkg/harbor/client/artifact/get_addition_responses.go index 5b9d35c..2c2abf2 100644 --- a/pkg/harbor/client/artifact/get_addition_responses.go +++ b/pkg/harbor/client/artifact/get_addition_responses.go @@ -53,6 +53,12 @@ func (o *GetAdditionReader) ReadResponse(response runtime.ClientResponse, consum return nil, err } return nil, result + case 422: + result := NewGetAdditionUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 500: result := NewGetAdditionInternalServerError() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -462,6 +468,86 @@ func (o *GetAdditionNotFound) readResponse(response runtime.ClientResponse, cons return nil } +// NewGetAdditionUnprocessableEntity creates a GetAdditionUnprocessableEntity with default headers values +func NewGetAdditionUnprocessableEntity() *GetAdditionUnprocessableEntity { + return &GetAdditionUnprocessableEntity{} +} + +/* +GetAdditionUnprocessableEntity describes a response with status code 422, with default header values. + +Unsupported Type +*/ +type GetAdditionUnprocessableEntity struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get addition unprocessable entity response has a 2xx status code +func (o *GetAdditionUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get addition unprocessable entity response has a 3xx status code +func (o *GetAdditionUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get addition unprocessable entity response has a 4xx status code +func (o *GetAdditionUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get addition unprocessable entity response has a 5xx status code +func (o *GetAdditionUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get addition unprocessable entity response a status code equal to that given +func (o *GetAdditionUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get addition unprocessable entity response +func (o *GetAdditionUnprocessableEntity) Code() int { + return 422 +} + +func (o *GetAdditionUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}][%d] getAdditionUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *GetAdditionUnprocessableEntity) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition}][%d] getAdditionUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *GetAdditionUnprocessableEntity) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetAdditionUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewGetAdditionInternalServerError creates a GetAdditionInternalServerError with default headers values func NewGetAdditionInternalServerError() *GetAdditionInternalServerError { return &GetAdditionInternalServerError{} diff --git a/pkg/harbor/client/artifact/get_artifact_parameters.go b/pkg/harbor/client/artifact/get_artifact_parameters.go index 2b31595..690eccb 100644 --- a/pkg/harbor/client/artifact/get_artifact_parameters.go +++ b/pkg/harbor/client/artifact/get_artifact_parameters.go @@ -67,7 +67,7 @@ type GetArtifactParams struct { A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' - Default: "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" */ XAcceptVulnerabilities *string `js:"xAcceptVulnerabilities"` @@ -109,13 +109,19 @@ type GetArtifactParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` + /* WithAccessory. + + Specify whether the accessories are included of the returning artifacts. + */ + WithAccessory *bool `js:"withAccessory"` + /* WithImmutableStatus. - Specify whether the immutable status is inclued inside the tags of the returning artifacts. Only works when setting "with_tag=true" + Specify whether the immutable status is inclued inside the tags of the returning artifacts. */ WithImmutableStatus *bool `js:"withImmutableStatus"` @@ -125,6 +131,12 @@ type GetArtifactParams struct { */ WithLabel *bool `js:"withLabel"` + /* WithSbomOverview. + + Specify whether the SBOM overview is included in returning artifact, when this option is true, the SBOM overview will be included in the response + */ + WithSbomOverview *bool `js:"withSbomOverview"` + /* WithScanOverview. Specify whether the scan overview is inclued inside the returning artifacts @@ -163,16 +175,20 @@ func (o *GetArtifactParams) WithDefaults() *GetArtifactParams { // All values with no default are reset to their zero value. func (o *GetArtifactParams) SetDefaults() { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) + withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) + withSbomOverviewDefault = bool(false) + withScanOverviewDefault = bool(false) withSignatureDefault = bool(false) @@ -184,8 +200,10 @@ func (o *GetArtifactParams) SetDefaults() { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, + WithSbomOverview: &withSbomOverviewDefault, WithScanOverview: &withScanOverviewDefault, WithSignature: &withSignatureDefault, WithTag: &withTagDefault, @@ -307,6 +325,17 @@ func (o *GetArtifactParams) SetRepositoryName(repositoryName string) { o.RepositoryName = repositoryName } +// WithWithAccessory adds the withAccessory to the get artifact params +func (o *GetArtifactParams) WithWithAccessory(withAccessory *bool) *GetArtifactParams { + o.SetWithAccessory(withAccessory) + return o +} + +// SetWithAccessory adds the withAccessory to the get artifact params +func (o *GetArtifactParams) SetWithAccessory(withAccessory *bool) { + o.WithAccessory = withAccessory +} + // WithWithImmutableStatus adds the withImmutableStatus to the get artifact params func (o *GetArtifactParams) WithWithImmutableStatus(withImmutableStatus *bool) *GetArtifactParams { o.SetWithImmutableStatus(withImmutableStatus) @@ -329,6 +358,17 @@ func (o *GetArtifactParams) SetWithLabel(withLabel *bool) { o.WithLabel = withLabel } +// WithWithSbomOverview adds the withSbomOverview to the get artifact params +func (o *GetArtifactParams) WithWithSbomOverview(withSbomOverview *bool) *GetArtifactParams { + o.SetWithSbomOverview(withSbomOverview) + return o +} + +// SetWithSbomOverview adds the withSbomOverview to the get artifact params +func (o *GetArtifactParams) SetWithSbomOverview(withSbomOverview *bool) { + o.WithSbomOverview = withSbomOverview +} + // WithWithScanOverview adds the withScanOverview to the get artifact params func (o *GetArtifactParams) WithWithScanOverview(withScanOverview *bool) *GetArtifactParams { o.SetWithScanOverview(withScanOverview) @@ -435,6 +475,23 @@ func (o *GetArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R return err } + if o.WithAccessory != nil { + + // query param with_accessory + var qrWithAccessory bool + + if o.WithAccessory != nil { + qrWithAccessory = *o.WithAccessory + } + qWithAccessory := swag.FormatBool(qrWithAccessory) + if qWithAccessory != "" { + + if err := r.SetQueryParam("with_accessory", qWithAccessory); err != nil { + return err + } + } + } + if o.WithImmutableStatus != nil { // query param with_immutable_status @@ -469,6 +526,23 @@ func (o *GetArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R } } + if o.WithSbomOverview != nil { + + // query param with_sbom_overview + var qrWithSbomOverview bool + + if o.WithSbomOverview != nil { + qrWithSbomOverview = *o.WithSbomOverview + } + qWithSbomOverview := swag.FormatBool(qrWithSbomOverview) + if qWithSbomOverview != "" { + + if err := r.SetQueryParam("with_sbom_overview", qWithSbomOverview); err != nil { + return err + } + } + } + if o.WithScanOverview != nil { // query param with_scan_overview diff --git a/pkg/harbor/client/artifact/get_vulnerabilities_addition_parameters.go b/pkg/harbor/client/artifact/get_vulnerabilities_addition_parameters.go index 4e473a2..3f812b7 100644 --- a/pkg/harbor/client/artifact/get_vulnerabilities_addition_parameters.go +++ b/pkg/harbor/client/artifact/get_vulnerabilities_addition_parameters.go @@ -66,7 +66,7 @@ type GetVulnerabilitiesAdditionParams struct { A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' - Default: "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" */ XAcceptVulnerabilities *string `js:"xAcceptVulnerabilities"` @@ -90,7 +90,7 @@ type GetVulnerabilitiesAdditionParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` @@ -112,7 +112,7 @@ func (o *GetVulnerabilitiesAdditionParams) WithDefaults() *GetVulnerabilitiesAdd // All values with no default are reset to their zero value. func (o *GetVulnerabilitiesAdditionParams) SetDefaults() { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") ) val := GetVulnerabilitiesAdditionParams{ diff --git a/pkg/harbor/client/artifact/list_accessories_parameters.go b/pkg/harbor/client/artifact/list_accessories_parameters.go new file mode 100644 index 0000000..da685bc --- /dev/null +++ b/pkg/harbor/client/artifact/list_accessories_parameters.go @@ -0,0 +1,377 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListAccessoriesParams creates a new ListAccessoriesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListAccessoriesParams() *ListAccessoriesParams { + return &ListAccessoriesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListAccessoriesParamsWithTimeout creates a new ListAccessoriesParams object +// with the ability to set a timeout on a request. +func NewListAccessoriesParamsWithTimeout(timeout time.Duration) *ListAccessoriesParams { + return &ListAccessoriesParams{ + timeout: timeout, + } +} + +// NewListAccessoriesParamsWithContext creates a new ListAccessoriesParams object +// with the ability to set a context for a request. +func NewListAccessoriesParamsWithContext(ctx context.Context) *ListAccessoriesParams { + return &ListAccessoriesParams{ + Context: ctx, + } +} + +// NewListAccessoriesParamsWithHTTPClient creates a new ListAccessoriesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListAccessoriesParamsWithHTTPClient(client *http.Client) *ListAccessoriesParams { + return &ListAccessoriesParams{ + HTTPClient: client, + } +} + +/* +ListAccessoriesParams contains all the parameters to send to the API endpoint + + for the list accessories operation. + + Typically these are written to a http.Request. +*/ +type ListAccessoriesParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + /* ProjectName. + + The name of the project + */ + ProjectName string `js:"projectName"` + + /* Q. + + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + */ + Q *string `js:"q"` + + /* Reference. + + The reference of the artifact, can be digest or tag + */ + Reference string `js:"reference"` + + /* RepositoryName. + + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb + */ + RepositoryName string `js:"repositoryName"` + + /* Sort. + + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" + */ + Sort *string `js:"sort"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list accessories params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListAccessoriesParams) WithDefaults() *ListAccessoriesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list accessories params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListAccessoriesParams) SetDefaults() { + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := ListAccessoriesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the list accessories params +func (o *ListAccessoriesParams) WithTimeout(timeout time.Duration) *ListAccessoriesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list accessories params +func (o *ListAccessoriesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list accessories params +func (o *ListAccessoriesParams) WithContext(ctx context.Context) *ListAccessoriesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list accessories params +func (o *ListAccessoriesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list accessories params +func (o *ListAccessoriesParams) WithHTTPClient(client *http.Client) *ListAccessoriesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list accessories params +func (o *ListAccessoriesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the list accessories params +func (o *ListAccessoriesParams) WithXRequestID(xRequestID *string) *ListAccessoriesParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list accessories params +func (o *ListAccessoriesParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the list accessories params +func (o *ListAccessoriesParams) WithPage(page *int64) *ListAccessoriesParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list accessories params +func (o *ListAccessoriesParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list accessories params +func (o *ListAccessoriesParams) WithPageSize(pageSize *int64) *ListAccessoriesParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list accessories params +func (o *ListAccessoriesParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithProjectName adds the projectName to the list accessories params +func (o *ListAccessoriesParams) WithProjectName(projectName string) *ListAccessoriesParams { + o.SetProjectName(projectName) + return o +} + +// SetProjectName adds the projectName to the list accessories params +func (o *ListAccessoriesParams) SetProjectName(projectName string) { + o.ProjectName = projectName +} + +// WithQ adds the q to the list accessories params +func (o *ListAccessoriesParams) WithQ(q *string) *ListAccessoriesParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the list accessories params +func (o *ListAccessoriesParams) SetQ(q *string) { + o.Q = q +} + +// WithReference adds the reference to the list accessories params +func (o *ListAccessoriesParams) WithReference(reference string) *ListAccessoriesParams { + o.SetReference(reference) + return o +} + +// SetReference adds the reference to the list accessories params +func (o *ListAccessoriesParams) SetReference(reference string) { + o.Reference = reference +} + +// WithRepositoryName adds the repositoryName to the list accessories params +func (o *ListAccessoriesParams) WithRepositoryName(repositoryName string) *ListAccessoriesParams { + o.SetRepositoryName(repositoryName) + return o +} + +// SetRepositoryName adds the repositoryName to the list accessories params +func (o *ListAccessoriesParams) SetRepositoryName(repositoryName string) { + o.RepositoryName = repositoryName +} + +// WithSort adds the sort to the list accessories params +func (o *ListAccessoriesParams) WithSort(sort *string) *ListAccessoriesParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the list accessories params +func (o *ListAccessoriesParams) SetSort(sort *string) { + o.Sort = sort +} + +// WriteToRequest writes these params to a swagger request +func (o *ListAccessoriesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + // path param project_name + if err := r.SetPathParam("project_name", o.ProjectName); err != nil { + return err + } + + if o.Q != nil { + + // query param q + var qrQ string + + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + } + + // path param reference + if err := r.SetPathParam("reference", o.Reference); err != nil { + return err + } + + // path param repository_name + if err := r.SetPathParam("repository_name", o.RepositoryName); err != nil { + return err + } + + if o.Sort != nil { + + // query param sort + var qrSort string + + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/artifact/list_accessories_responses.go b/pkg/harbor/client/artifact/list_accessories_responses.go new file mode 100644 index 0000000..1d507e9 --- /dev/null +++ b/pkg/harbor/client/artifact/list_accessories_responses.go @@ -0,0 +1,560 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package artifact + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListAccessoriesReader is a Reader for the ListAccessories structure. +type ListAccessoriesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListAccessoriesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListAccessoriesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListAccessoriesBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListAccessoriesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListAccessoriesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListAccessoriesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListAccessoriesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories] listAccessories", response, response.Code()) + } +} + +// NewListAccessoriesOK creates a ListAccessoriesOK with default headers values +func NewListAccessoriesOK() *ListAccessoriesOK { + return &ListAccessoriesOK{} +} + +/* +ListAccessoriesOK describes a response with status code 200, with default header values. + +Success +*/ +type ListAccessoriesOK struct { + + /* Link refers to the previous page and next page + */ + Link string + + /* The total count of accessories + */ + XTotalCount int64 + + Payload []*models.Accessory +} + +// IsSuccess returns true when this list accessories o k response has a 2xx status code +func (o *ListAccessoriesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list accessories o k response has a 3xx status code +func (o *ListAccessoriesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories o k response has a 4xx status code +func (o *ListAccessoriesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list accessories o k response has a 5xx status code +func (o *ListAccessoriesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list accessories o k response a status code equal to that given +func (o *ListAccessoriesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list accessories o k response +func (o *ListAccessoriesOK) Code() int { + return 200 +} + +func (o *ListAccessoriesOK) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesOK %+v", 200, o.Payload) +} + +func (o *ListAccessoriesOK) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesOK %+v", 200, o.Payload) +} + +func (o *ListAccessoriesOK) GetPayload() []*models.Accessory { + return o.Payload +} + +func (o *ListAccessoriesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesBadRequest creates a ListAccessoriesBadRequest with default headers values +func NewListAccessoriesBadRequest() *ListAccessoriesBadRequest { + return &ListAccessoriesBadRequest{} +} + +/* +ListAccessoriesBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type ListAccessoriesBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list accessories bad request response has a 2xx status code +func (o *ListAccessoriesBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list accessories bad request response has a 3xx status code +func (o *ListAccessoriesBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories bad request response has a 4xx status code +func (o *ListAccessoriesBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list accessories bad request response has a 5xx status code +func (o *ListAccessoriesBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list accessories bad request response a status code equal to that given +func (o *ListAccessoriesBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list accessories bad request response +func (o *ListAccessoriesBadRequest) Code() int { + return 400 +} + +func (o *ListAccessoriesBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesBadRequest %+v", 400, o.Payload) +} + +func (o *ListAccessoriesBadRequest) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesBadRequest %+v", 400, o.Payload) +} + +func (o *ListAccessoriesBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListAccessoriesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesUnauthorized creates a ListAccessoriesUnauthorized with default headers values +func NewListAccessoriesUnauthorized() *ListAccessoriesUnauthorized { + return &ListAccessoriesUnauthorized{} +} + +/* +ListAccessoriesUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListAccessoriesUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list accessories unauthorized response has a 2xx status code +func (o *ListAccessoriesUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list accessories unauthorized response has a 3xx status code +func (o *ListAccessoriesUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories unauthorized response has a 4xx status code +func (o *ListAccessoriesUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list accessories unauthorized response has a 5xx status code +func (o *ListAccessoriesUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list accessories unauthorized response a status code equal to that given +func (o *ListAccessoriesUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list accessories unauthorized response +func (o *ListAccessoriesUnauthorized) Code() int { + return 401 +} + +func (o *ListAccessoriesUnauthorized) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListAccessoriesUnauthorized) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListAccessoriesUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListAccessoriesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesForbidden creates a ListAccessoriesForbidden with default headers values +func NewListAccessoriesForbidden() *ListAccessoriesForbidden { + return &ListAccessoriesForbidden{} +} + +/* +ListAccessoriesForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ListAccessoriesForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list accessories forbidden response has a 2xx status code +func (o *ListAccessoriesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list accessories forbidden response has a 3xx status code +func (o *ListAccessoriesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories forbidden response has a 4xx status code +func (o *ListAccessoriesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list accessories forbidden response has a 5xx status code +func (o *ListAccessoriesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list accessories forbidden response a status code equal to that given +func (o *ListAccessoriesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list accessories forbidden response +func (o *ListAccessoriesForbidden) Code() int { + return 403 +} + +func (o *ListAccessoriesForbidden) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesForbidden %+v", 403, o.Payload) +} + +func (o *ListAccessoriesForbidden) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesForbidden %+v", 403, o.Payload) +} + +func (o *ListAccessoriesForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListAccessoriesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesNotFound creates a ListAccessoriesNotFound with default headers values +func NewListAccessoriesNotFound() *ListAccessoriesNotFound { + return &ListAccessoriesNotFound{} +} + +/* +ListAccessoriesNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ListAccessoriesNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list accessories not found response has a 2xx status code +func (o *ListAccessoriesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list accessories not found response has a 3xx status code +func (o *ListAccessoriesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories not found response has a 4xx status code +func (o *ListAccessoriesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list accessories not found response has a 5xx status code +func (o *ListAccessoriesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list accessories not found response a status code equal to that given +func (o *ListAccessoriesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list accessories not found response +func (o *ListAccessoriesNotFound) Code() int { + return 404 +} + +func (o *ListAccessoriesNotFound) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesNotFound %+v", 404, o.Payload) +} + +func (o *ListAccessoriesNotFound) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesNotFound %+v", 404, o.Payload) +} + +func (o *ListAccessoriesNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListAccessoriesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListAccessoriesInternalServerError creates a ListAccessoriesInternalServerError with default headers values +func NewListAccessoriesInternalServerError() *ListAccessoriesInternalServerError { + return &ListAccessoriesInternalServerError{} +} + +/* +ListAccessoriesInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListAccessoriesInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list accessories internal server error response has a 2xx status code +func (o *ListAccessoriesInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list accessories internal server error response has a 3xx status code +func (o *ListAccessoriesInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list accessories internal server error response has a 4xx status code +func (o *ListAccessoriesInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list accessories internal server error response has a 5xx status code +func (o *ListAccessoriesInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list accessories internal server error response a status code equal to that given +func (o *ListAccessoriesInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list accessories internal server error response +func (o *ListAccessoriesInternalServerError) Code() int { + return 500 +} + +func (o *ListAccessoriesInternalServerError) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListAccessoriesInternalServerError) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories][%d] listAccessoriesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListAccessoriesInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListAccessoriesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/artifact/list_artifacts_parameters.go b/pkg/harbor/client/artifact/list_artifacts_parameters.go index 2cfc8d6..a082774 100644 --- a/pkg/harbor/client/artifact/list_artifacts_parameters.go +++ b/pkg/harbor/client/artifact/list_artifacts_parameters.go @@ -67,7 +67,7 @@ type ListArtifactsParams struct { A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' - Default: "application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" + Default: "application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0" */ XAcceptVulnerabilities *string `js:"xAcceptVulnerabilities"` @@ -109,19 +109,25 @@ type ListArtifactsParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` + /* WithAccessory. + + Specify whether the accessories are included of the returning artifacts. Only works when setting "with_accessory=true" + */ + WithAccessory *bool `js:"withAccessory"` + /* WithImmutableStatus. - Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" + Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_immutable_status=true" */ WithImmutableStatus *bool `js:"withImmutableStatus"` @@ -131,6 +137,12 @@ type ListArtifactsParams struct { */ WithLabel *bool `js:"withLabel"` + /* WithSbomOverview. + + Specify whether the SBOM overview is included in returning artifacts, when this option is true, the SBOM overview will be included in the response + */ + WithSbomOverview *bool `js:"withSbomOverview"` + /* WithScanOverview. Specify whether the scan overview is included inside the returning artifacts @@ -169,16 +181,20 @@ func (o *ListArtifactsParams) WithDefaults() *ListArtifactsParams { // All values with no default are reset to their zero value. func (o *ListArtifactsParams) SetDefaults() { var ( - xAcceptVulnerabilitiesDefault = string("application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") + xAcceptVulnerabilitiesDefault = string("application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0") pageDefault = int64(1) pageSizeDefault = int64(10) + withAccessoryDefault = bool(false) + withImmutableStatusDefault = bool(false) withLabelDefault = bool(false) + withSbomOverviewDefault = bool(false) + withScanOverviewDefault = bool(false) withSignatureDefault = bool(false) @@ -190,8 +206,10 @@ func (o *ListArtifactsParams) SetDefaults() { XAcceptVulnerabilities: &xAcceptVulnerabilitiesDefault, Page: &pageDefault, PageSize: &pageSizeDefault, + WithAccessory: &withAccessoryDefault, WithImmutableStatus: &withImmutableStatusDefault, WithLabel: &withLabelDefault, + WithSbomOverview: &withSbomOverviewDefault, WithScanOverview: &withScanOverviewDefault, WithSignature: &withSignatureDefault, WithTag: &withTagDefault, @@ -324,6 +342,17 @@ func (o *ListArtifactsParams) SetSort(sort *string) { o.Sort = sort } +// WithWithAccessory adds the withAccessory to the list artifacts params +func (o *ListArtifactsParams) WithWithAccessory(withAccessory *bool) *ListArtifactsParams { + o.SetWithAccessory(withAccessory) + return o +} + +// SetWithAccessory adds the withAccessory to the list artifacts params +func (o *ListArtifactsParams) SetWithAccessory(withAccessory *bool) { + o.WithAccessory = withAccessory +} + // WithWithImmutableStatus adds the withImmutableStatus to the list artifacts params func (o *ListArtifactsParams) WithWithImmutableStatus(withImmutableStatus *bool) *ListArtifactsParams { o.SetWithImmutableStatus(withImmutableStatus) @@ -346,6 +375,17 @@ func (o *ListArtifactsParams) SetWithLabel(withLabel *bool) { o.WithLabel = withLabel } +// WithWithSbomOverview adds the withSbomOverview to the list artifacts params +func (o *ListArtifactsParams) WithWithSbomOverview(withSbomOverview *bool) *ListArtifactsParams { + o.SetWithSbomOverview(withSbomOverview) + return o +} + +// SetWithSbomOverview adds the withSbomOverview to the list artifacts params +func (o *ListArtifactsParams) SetWithSbomOverview(withSbomOverview *bool) { + o.WithSbomOverview = withSbomOverview +} + // WithWithScanOverview adds the withScanOverview to the list artifacts params func (o *ListArtifactsParams) WithWithScanOverview(withScanOverview *bool) *ListArtifactsParams { o.SetWithScanOverview(withScanOverview) @@ -481,6 +521,23 @@ func (o *ListArtifactsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } } + if o.WithAccessory != nil { + + // query param with_accessory + var qrWithAccessory bool + + if o.WithAccessory != nil { + qrWithAccessory = *o.WithAccessory + } + qWithAccessory := swag.FormatBool(qrWithAccessory) + if qWithAccessory != "" { + + if err := r.SetQueryParam("with_accessory", qWithAccessory); err != nil { + return err + } + } + } + if o.WithImmutableStatus != nil { // query param with_immutable_status @@ -515,6 +572,23 @@ func (o *ListArtifactsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt } } + if o.WithSbomOverview != nil { + + // query param with_sbom_overview + var qrWithSbomOverview bool + + if o.WithSbomOverview != nil { + qrWithSbomOverview = *o.WithSbomOverview + } + qWithSbomOverview := swag.FormatBool(qrWithSbomOverview) + if qWithSbomOverview != "" { + + if err := r.SetQueryParam("with_sbom_overview", qWithSbomOverview); err != nil { + return err + } + } + } + if o.WithScanOverview != nil { // query param with_scan_overview diff --git a/pkg/harbor/client/artifact/list_tags_parameters.go b/pkg/harbor/client/artifact/list_tags_parameters.go index 23ad9bc..e30cd0b 100644 --- a/pkg/harbor/client/artifact/list_tags_parameters.go +++ b/pkg/harbor/client/artifact/list_tags_parameters.go @@ -106,13 +106,13 @@ type ListTagsParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/artifact/remove_label_parameters.go b/pkg/harbor/client/artifact/remove_label_parameters.go index a3c6493..ddfd4ac 100644 --- a/pkg/harbor/client/artifact/remove_label_parameters.go +++ b/pkg/harbor/client/artifact/remove_label_parameters.go @@ -90,7 +90,7 @@ type RemoveLabelParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/auditlog/list_audit_logs_parameters.go b/pkg/harbor/client/auditlog/list_audit_logs_parameters.go index 19998e9..38f7858 100644 --- a/pkg/harbor/client/auditlog/list_audit_logs_parameters.go +++ b/pkg/harbor/client/auditlog/list_audit_logs_parameters.go @@ -94,7 +94,7 @@ type ListAuditLogsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/configure/get_configurations_responses.go b/pkg/harbor/client/configure/get_configurations_responses.go index 40daa7a..189c2ea 100644 --- a/pkg/harbor/client/configure/get_configurations_responses.go +++ b/pkg/harbor/client/configure/get_configurations_responses.go @@ -128,7 +128,7 @@ func NewGetConfigurationsUnauthorized() *GetConfigurationsUnauthorized { /* GetConfigurationsUnauthorized describes a response with status code 401, with default header values. -User need to log in first.ß +User need to log in first. */ type GetConfigurationsUnauthorized struct { } diff --git a/pkg/harbor/client/configure/update_configurations_parameters.go b/pkg/harbor/client/configure/update_configurations_parameters.go index 1ea615f..820a046 100644 --- a/pkg/harbor/client/configure/update_configurations_parameters.go +++ b/pkg/harbor/client/configure/update_configurations_parameters.go @@ -73,7 +73,7 @@ type UpdateConfigurationsParams struct { The configuration map can contain a subset of the attributes of the schema, which are to be updated. */ - Configurations models.Configurations `js:"configurations"` + Configurations *models.Configurations `js:"configurations"` timeout time.Duration Context context.Context `js:"context"` @@ -140,13 +140,13 @@ func (o *UpdateConfigurationsParams) SetXRequestID(xRequestID *string) { } // WithConfigurations adds the configurations to the update configurations params -func (o *UpdateConfigurationsParams) WithConfigurations(configurations models.Configurations) *UpdateConfigurationsParams { +func (o *UpdateConfigurationsParams) WithConfigurations(configurations *models.Configurations) *UpdateConfigurationsParams { o.SetConfigurations(configurations) return o } // SetConfigurations adds the configurations to the update configurations params -func (o *UpdateConfigurationsParams) SetConfigurations(configurations models.Configurations) { +func (o *UpdateConfigurationsParams) SetConfigurations(configurations *models.Configurations) { o.Configurations = configurations } diff --git a/pkg/harbor/client/gc/create_gc_schedule_parameters.go b/pkg/harbor/client/gc/create_gc_schedule_parameters.go index 5071918..9c5daee 100644 --- a/pkg/harbor/client/gc/create_gc_schedule_parameters.go +++ b/pkg/harbor/client/gc/create_gc_schedule_parameters.go @@ -63,6 +63,12 @@ CreateGCScheduleParams contains all the parameters to send to the API endpoint */ type CreateGCScheduleParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Schedule. Updates of gc's schedule. @@ -122,6 +128,17 @@ func (o *CreateGCScheduleParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the create GC schedule params +func (o *CreateGCScheduleParams) WithXRequestID(xRequestID *string) *CreateGCScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the create GC schedule params +func (o *CreateGCScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithSchedule adds the schedule to the create GC schedule params func (o *CreateGCScheduleParams) WithSchedule(schedule *models.Schedule) *CreateGCScheduleParams { o.SetSchedule(schedule) @@ -140,6 +157,14 @@ func (o *CreateGCScheduleParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Schedule != nil { if err := r.SetBodyParam(o.Schedule); err != nil { return err diff --git a/pkg/harbor/client/gc/gc_client.go b/pkg/harbor/client/gc/gc_client.go index eaf2336..426698f 100644 --- a/pkg/harbor/client/gc/gc_client.go +++ b/pkg/harbor/client/gc/gc_client.go @@ -44,6 +44,11 @@ type API interface { This endpoint is for get schedule of gc job.*/ GetGCSchedule(ctx context.Context, params *GetGCScheduleParams) (*GetGCScheduleOK, error) + /* + StopGC stops the specific GC execution + + Stop the GC execution specified by ID*/ + StopGC(ctx context.Context, params *StopGCParams) (*StopGCOK, error) /* UpdateGCSchedule updates gc s schedule @@ -270,6 +275,46 @@ func (a *Client) GetGCSchedule(ctx context.Context, params *GetGCScheduleParams) panic(msg) } +/* +StopGC stops the specific GC execution + +Stop the GC execution specified by ID +*/ +func (a *Client) StopGC(ctx context.Context, params *StopGCParams) (*StopGCOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "stopGC", + Method: "PUT", + PathPattern: "/system/gc/{gc_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StopGCReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *StopGCOK: + return value, nil + case *StopGCUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopGCForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopGCNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopGCInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for stopGC: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* UpdateGCSchedule updates gc s schedule diff --git a/pkg/harbor/client/gc/get_gc_history_parameters.go b/pkg/harbor/client/gc/get_gc_history_parameters.go index 73cb9e6..971731f 100644 --- a/pkg/harbor/client/gc/get_gc_history_parameters.go +++ b/pkg/harbor/client/gc/get_gc_history_parameters.go @@ -94,7 +94,7 @@ type GetGCHistoryParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/gc/stop_gc_parameters.go b/pkg/harbor/client/gc/stop_gc_parameters.go new file mode 100644 index 0000000..d1fe2a9 --- /dev/null +++ b/pkg/harbor/client/gc/stop_gc_parameters.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewStopGCParams creates a new StopGCParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStopGCParams() *StopGCParams { + return &StopGCParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStopGCParamsWithTimeout creates a new StopGCParams object +// with the ability to set a timeout on a request. +func NewStopGCParamsWithTimeout(timeout time.Duration) *StopGCParams { + return &StopGCParams{ + timeout: timeout, + } +} + +// NewStopGCParamsWithContext creates a new StopGCParams object +// with the ability to set a context for a request. +func NewStopGCParamsWithContext(ctx context.Context) *StopGCParams { + return &StopGCParams{ + Context: ctx, + } +} + +// NewStopGCParamsWithHTTPClient creates a new StopGCParams object +// with the ability to set a custom HTTPClient for a request. +func NewStopGCParamsWithHTTPClient(client *http.Client) *StopGCParams { + return &StopGCParams{ + HTTPClient: client, + } +} + +/* +StopGCParams contains all the parameters to send to the API endpoint + + for the stop GC operation. + + Typically these are written to a http.Request. +*/ +type StopGCParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* GCID. + + The ID of the gc log + + Format: int64 + */ + GCID int64 `js:"gcid"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the stop GC params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopGCParams) WithDefaults() *StopGCParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the stop GC params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopGCParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the stop GC params +func (o *StopGCParams) WithTimeout(timeout time.Duration) *StopGCParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the stop GC params +func (o *StopGCParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the stop GC params +func (o *StopGCParams) WithContext(ctx context.Context) *StopGCParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the stop GC params +func (o *StopGCParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the stop GC params +func (o *StopGCParams) WithHTTPClient(client *http.Client) *StopGCParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the stop GC params +func (o *StopGCParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the stop GC params +func (o *StopGCParams) WithXRequestID(xRequestID *string) *StopGCParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop GC params +func (o *StopGCParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithGCID adds the gCID to the stop GC params +func (o *StopGCParams) WithGCID(gCID int64) *StopGCParams { + o.SetGCID(gCID) + return o +} + +// SetGCID adds the gcId to the stop GC params +func (o *StopGCParams) SetGCID(gCID int64) { + o.GCID = gCID +} + +// WriteToRequest writes these params to a swagger request +func (o *StopGCParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param gc_id + if err := r.SetPathParam("gc_id", swag.FormatInt64(o.GCID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/gc/stop_gc_responses.go b/pkg/harbor/client/gc/stop_gc_responses.go new file mode 100644 index 0000000..5830abb --- /dev/null +++ b/pkg/harbor/client/gc/stop_gc_responses.go @@ -0,0 +1,446 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package gc + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// StopGCReader is a Reader for the StopGC structure. +type StopGCReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StopGCReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStopGCOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewStopGCUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewStopGCForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewStopGCNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewStopGCInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /system/gc/{gc_id}] stopGC", response, response.Code()) + } +} + +// NewStopGCOK creates a StopGCOK with default headers values +func NewStopGCOK() *StopGCOK { + return &StopGCOK{} +} + +/* +StopGCOK describes a response with status code 200, with default header values. + +Success +*/ +type StopGCOK struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string +} + +// IsSuccess returns true when this stop Gc o k response has a 2xx status code +func (o *StopGCOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this stop Gc o k response has a 3xx status code +func (o *StopGCOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop Gc o k response has a 4xx status code +func (o *StopGCOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop Gc o k response has a 5xx status code +func (o *StopGCOK) IsServerError() bool { + return false +} + +// IsCode returns true when this stop Gc o k response a status code equal to that given +func (o *StopGCOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the stop Gc o k response +func (o *StopGCOK) Code() int { + return 200 +} + +func (o *StopGCOK) Error() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcOK ", 200) +} + +func (o *StopGCOK) String() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcOK ", 200) +} + +func (o *StopGCOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + return nil +} + +// NewStopGCUnauthorized creates a StopGCUnauthorized with default headers values +func NewStopGCUnauthorized() *StopGCUnauthorized { + return &StopGCUnauthorized{} +} + +/* +StopGCUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type StopGCUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop Gc unauthorized response has a 2xx status code +func (o *StopGCUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop Gc unauthorized response has a 3xx status code +func (o *StopGCUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop Gc unauthorized response has a 4xx status code +func (o *StopGCUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop Gc unauthorized response has a 5xx status code +func (o *StopGCUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this stop Gc unauthorized response a status code equal to that given +func (o *StopGCUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the stop Gc unauthorized response +func (o *StopGCUnauthorized) Code() int { + return 401 +} + +func (o *StopGCUnauthorized) Error() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcUnauthorized %+v", 401, o.Payload) +} + +func (o *StopGCUnauthorized) String() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcUnauthorized %+v", 401, o.Payload) +} + +func (o *StopGCUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopGCUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopGCForbidden creates a StopGCForbidden with default headers values +func NewStopGCForbidden() *StopGCForbidden { + return &StopGCForbidden{} +} + +/* +StopGCForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type StopGCForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop Gc forbidden response has a 2xx status code +func (o *StopGCForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop Gc forbidden response has a 3xx status code +func (o *StopGCForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop Gc forbidden response has a 4xx status code +func (o *StopGCForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop Gc forbidden response has a 5xx status code +func (o *StopGCForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this stop Gc forbidden response a status code equal to that given +func (o *StopGCForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the stop Gc forbidden response +func (o *StopGCForbidden) Code() int { + return 403 +} + +func (o *StopGCForbidden) Error() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcForbidden %+v", 403, o.Payload) +} + +func (o *StopGCForbidden) String() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcForbidden %+v", 403, o.Payload) +} + +func (o *StopGCForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopGCForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopGCNotFound creates a StopGCNotFound with default headers values +func NewStopGCNotFound() *StopGCNotFound { + return &StopGCNotFound{} +} + +/* +StopGCNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type StopGCNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop Gc not found response has a 2xx status code +func (o *StopGCNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop Gc not found response has a 3xx status code +func (o *StopGCNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop Gc not found response has a 4xx status code +func (o *StopGCNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop Gc not found response has a 5xx status code +func (o *StopGCNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this stop Gc not found response a status code equal to that given +func (o *StopGCNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the stop Gc not found response +func (o *StopGCNotFound) Code() int { + return 404 +} + +func (o *StopGCNotFound) Error() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcNotFound %+v", 404, o.Payload) +} + +func (o *StopGCNotFound) String() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcNotFound %+v", 404, o.Payload) +} + +func (o *StopGCNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopGCNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopGCInternalServerError creates a StopGCInternalServerError with default headers values +func NewStopGCInternalServerError() *StopGCInternalServerError { + return &StopGCInternalServerError{} +} + +/* +StopGCInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type StopGCInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop Gc internal server error response has a 2xx status code +func (o *StopGCInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop Gc internal server error response has a 3xx status code +func (o *StopGCInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop Gc internal server error response has a 4xx status code +func (o *StopGCInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop Gc internal server error response has a 5xx status code +func (o *StopGCInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this stop Gc internal server error response a status code equal to that given +func (o *StopGCInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the stop Gc internal server error response +func (o *StopGCInternalServerError) Code() int { + return 500 +} + +func (o *StopGCInternalServerError) Error() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcInternalServerError %+v", 500, o.Payload) +} + +func (o *StopGCInternalServerError) String() string { + return fmt.Sprintf("[PUT /system/gc/{gc_id}][%d] stopGcInternalServerError %+v", 500, o.Payload) +} + +func (o *StopGCInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopGCInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/gc/update_gc_schedule_parameters.go b/pkg/harbor/client/gc/update_gc_schedule_parameters.go index 8d6c494..277f41f 100644 --- a/pkg/harbor/client/gc/update_gc_schedule_parameters.go +++ b/pkg/harbor/client/gc/update_gc_schedule_parameters.go @@ -63,6 +63,12 @@ UpdateGCScheduleParams contains all the parameters to send to the API endpoint */ type UpdateGCScheduleParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Schedule. Updates of gc's schedule. @@ -122,6 +128,17 @@ func (o *UpdateGCScheduleParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the update GC schedule params +func (o *UpdateGCScheduleParams) WithXRequestID(xRequestID *string) *UpdateGCScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the update GC schedule params +func (o *UpdateGCScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithSchedule adds the schedule to the update GC schedule params func (o *UpdateGCScheduleParams) WithSchedule(schedule *models.Schedule) *UpdateGCScheduleParams { o.SetSchedule(schedule) @@ -140,6 +157,14 @@ func (o *UpdateGCScheduleParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Schedule != nil { if err := r.SetBodyParam(o.Schedule); err != nil { return err diff --git a/pkg/harbor/client/harbor_api_client.go b/pkg/harbor/client/harbor_api_client.go index 0382379..e41fc44 100644 --- a/pkg/harbor/client/harbor_api_client.go +++ b/pkg/harbor/client/harbor_api_client.go @@ -20,14 +20,17 @@ import ( "github.com/goharbor/xk6-harbor/pkg/harbor/client/health" "github.com/goharbor/xk6-harbor/pkg/harbor/client/icon" "github.com/goharbor/xk6-harbor/pkg/harbor/client/immutable" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/jobservice" "github.com/goharbor/xk6-harbor/pkg/harbor/client/label" "github.com/goharbor/xk6-harbor/pkg/harbor/client/ldap" "github.com/goharbor/xk6-harbor/pkg/harbor/client/member" "github.com/goharbor/xk6-harbor/pkg/harbor/client/oidc" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/permissions" "github.com/goharbor/xk6-harbor/pkg/harbor/client/ping" "github.com/goharbor/xk6-harbor/pkg/harbor/client/preheat" "github.com/goharbor/xk6-harbor/pkg/harbor/client/project" "github.com/goharbor/xk6-harbor/pkg/harbor/client/project_metadata" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/purge" "github.com/goharbor/xk6-harbor/pkg/harbor/client/quota" "github.com/goharbor/xk6-harbor/pkg/harbor/client/registry" "github.com/goharbor/xk6-harbor/pkg/harbor/client/replication" @@ -37,8 +40,11 @@ import ( "github.com/goharbor/xk6-harbor/pkg/harbor/client/robotv1" "github.com/goharbor/xk6-harbor/pkg/harbor/client/scan" "github.com/goharbor/xk6-harbor/pkg/harbor/client/scan_all" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/scan_data_export" "github.com/goharbor/xk6-harbor/pkg/harbor/client/scanner" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/schedule" "github.com/goharbor/xk6-harbor/pkg/harbor/client/search" + "github.com/goharbor/xk6-harbor/pkg/harbor/client/securityhub" "github.com/goharbor/xk6-harbor/pkg/harbor/client/statistic" "github.com/goharbor/xk6-harbor/pkg/harbor/client/system_cve_allowlist" "github.com/goharbor/xk6-harbor/pkg/harbor/client/systeminfo" @@ -97,14 +103,17 @@ func New(c Config) *HarborAPI { cli.Health = health.New(transport, strfmt.Default, c.AuthInfo) cli.Icon = icon.New(transport, strfmt.Default, c.AuthInfo) cli.Immutable = immutable.New(transport, strfmt.Default, c.AuthInfo) + cli.Jobservice = jobservice.New(transport, strfmt.Default, c.AuthInfo) cli.Label = label.New(transport, strfmt.Default, c.AuthInfo) cli.Ldap = ldap.New(transport, strfmt.Default, c.AuthInfo) cli.Member = member.New(transport, strfmt.Default, c.AuthInfo) cli.OIDC = oidc.New(transport, strfmt.Default, c.AuthInfo) + cli.Permissions = permissions.New(transport, strfmt.Default, c.AuthInfo) cli.Ping = ping.New(transport, strfmt.Default, c.AuthInfo) cli.Preheat = preheat.New(transport, strfmt.Default, c.AuthInfo) cli.Project = project.New(transport, strfmt.Default, c.AuthInfo) cli.ProjectMetadata = project_metadata.New(transport, strfmt.Default, c.AuthInfo) + cli.Purge = purge.New(transport, strfmt.Default, c.AuthInfo) cli.Quota = quota.New(transport, strfmt.Default, c.AuthInfo) cli.Registry = registry.New(transport, strfmt.Default, c.AuthInfo) cli.Replication = replication.New(transport, strfmt.Default, c.AuthInfo) @@ -114,8 +123,11 @@ func New(c Config) *HarborAPI { cli.Robotv1 = robotv1.New(transport, strfmt.Default, c.AuthInfo) cli.Scan = scan.New(transport, strfmt.Default, c.AuthInfo) cli.ScanAll = scan_all.New(transport, strfmt.Default, c.AuthInfo) + cli.ScanDataExport = scan_data_export.New(transport, strfmt.Default, c.AuthInfo) cli.Scanner = scanner.New(transport, strfmt.Default, c.AuthInfo) + cli.Schedule = schedule.New(transport, strfmt.Default, c.AuthInfo) cli.Search = search.New(transport, strfmt.Default, c.AuthInfo) + cli.Securityhub = securityhub.New(transport, strfmt.Default, c.AuthInfo) cli.Statistic = statistic.New(transport, strfmt.Default, c.AuthInfo) cli.SystemCVEAllowlist = system_cve_allowlist.New(transport, strfmt.Default, c.AuthInfo) cli.Systeminfo = systeminfo.New(transport, strfmt.Default, c.AuthInfo) @@ -135,14 +147,17 @@ type HarborAPI struct { Health health.API Icon icon.API Immutable immutable.API + Jobservice jobservice.API Label label.API Ldap ldap.API Member member.API OIDC oidc.API + Permissions permissions.API Ping ping.API Preheat preheat.API Project project.API ProjectMetadata project_metadata.API + Purge purge.API Quota quota.API Registry registry.API Replication replication.API @@ -152,8 +167,11 @@ type HarborAPI struct { Robotv1 robotv1.API Scan scan.API ScanAll scan_all.API + ScanDataExport scan_data_export.API Scanner scanner.API + Schedule schedule.API Search search.API + Securityhub securityhub.API Statistic statistic.API SystemCVEAllowlist system_cve_allowlist.API Systeminfo systeminfo.API diff --git a/pkg/harbor/client/health/health_client.go b/pkg/harbor/client/health/health_client.go index 7c6e7a7..e73bc75 100644 --- a/pkg/harbor/client/health/health_client.go +++ b/pkg/harbor/client/health/health_client.go @@ -21,7 +21,7 @@ type API interface { /* GetHealth checks the status of harbor components - Check the status of Harbor components*/ + Check the status of Harbor components. This path does not require authentication.*/ GetHealth(ctx context.Context, params *GetHealthParams) (*GetHealthOK, error) } @@ -46,7 +46,7 @@ type Client struct { /* GetHealth checks the status of harbor components -Check the status of Harbor components +Check the status of Harbor components. This path does not require authentication. */ func (a *Client) GetHealth(ctx context.Context, params *GetHealthParams) (*GetHealthOK, error) { diff --git a/pkg/harbor/client/immutable/list_immu_rules_parameters.go b/pkg/harbor/client/immutable/list_immu_rules_parameters.go index e250200..de4402a 100644 --- a/pkg/harbor/client/immutable/list_immu_rules_parameters.go +++ b/pkg/harbor/client/immutable/list_immu_rules_parameters.go @@ -106,7 +106,7 @@ type ListImmuRulesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/jobservice/action_get_job_log_parameters.go b/pkg/harbor/client/jobservice/action_get_job_log_parameters.go new file mode 100644 index 0000000..7cd3ae3 --- /dev/null +++ b/pkg/harbor/client/jobservice/action_get_job_log_parameters.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewActionGetJobLogParams creates a new ActionGetJobLogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewActionGetJobLogParams() *ActionGetJobLogParams { + return &ActionGetJobLogParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewActionGetJobLogParamsWithTimeout creates a new ActionGetJobLogParams object +// with the ability to set a timeout on a request. +func NewActionGetJobLogParamsWithTimeout(timeout time.Duration) *ActionGetJobLogParams { + return &ActionGetJobLogParams{ + timeout: timeout, + } +} + +// NewActionGetJobLogParamsWithContext creates a new ActionGetJobLogParams object +// with the ability to set a context for a request. +func NewActionGetJobLogParamsWithContext(ctx context.Context) *ActionGetJobLogParams { + return &ActionGetJobLogParams{ + Context: ctx, + } +} + +// NewActionGetJobLogParamsWithHTTPClient creates a new ActionGetJobLogParams object +// with the ability to set a custom HTTPClient for a request. +func NewActionGetJobLogParamsWithHTTPClient(client *http.Client) *ActionGetJobLogParams { + return &ActionGetJobLogParams{ + HTTPClient: client, + } +} + +/* +ActionGetJobLogParams contains all the parameters to send to the API endpoint + + for the action get job log operation. + + Typically these are written to a http.Request. +*/ +type ActionGetJobLogParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* JobID. + + The id of the job. + */ + JobID string `js:"jobID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the action get job log params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ActionGetJobLogParams) WithDefaults() *ActionGetJobLogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the action get job log params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ActionGetJobLogParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the action get job log params +func (o *ActionGetJobLogParams) WithTimeout(timeout time.Duration) *ActionGetJobLogParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the action get job log params +func (o *ActionGetJobLogParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the action get job log params +func (o *ActionGetJobLogParams) WithContext(ctx context.Context) *ActionGetJobLogParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the action get job log params +func (o *ActionGetJobLogParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the action get job log params +func (o *ActionGetJobLogParams) WithHTTPClient(client *http.Client) *ActionGetJobLogParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the action get job log params +func (o *ActionGetJobLogParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the action get job log params +func (o *ActionGetJobLogParams) WithXRequestID(xRequestID *string) *ActionGetJobLogParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the action get job log params +func (o *ActionGetJobLogParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithJobID adds the jobID to the action get job log params +func (o *ActionGetJobLogParams) WithJobID(jobID string) *ActionGetJobLogParams { + o.SetJobID(jobID) + return o +} + +// SetJobID adds the jobId to the action get job log params +func (o *ActionGetJobLogParams) SetJobID(jobID string) { + o.JobID = jobID +} + +// WriteToRequest writes these params to a swagger request +func (o *ActionGetJobLogParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param job_id + if err := r.SetPathParam("job_id", o.JobID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/action_get_job_log_responses.go b/pkg/harbor/client/jobservice/action_get_job_log_responses.go new file mode 100644 index 0000000..b77abc1 --- /dev/null +++ b/pkg/harbor/client/jobservice/action_get_job_log_responses.go @@ -0,0 +1,457 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ActionGetJobLogReader is a Reader for the ActionGetJobLog structure. +type ActionGetJobLogReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ActionGetJobLogReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewActionGetJobLogOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewActionGetJobLogUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewActionGetJobLogForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewActionGetJobLogNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewActionGetJobLogInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /jobservice/jobs/{job_id}/log] actionGetJobLog", response, response.Code()) + } +} + +// NewActionGetJobLogOK creates a ActionGetJobLogOK with default headers values +func NewActionGetJobLogOK() *ActionGetJobLogOK { + return &ActionGetJobLogOK{} +} + +/* +ActionGetJobLogOK describes a response with status code 200, with default header values. + +Get job log successfully. +*/ +type ActionGetJobLogOK struct { + + /* The content type of response body + */ + ContentType string + + Payload string +} + +// IsSuccess returns true when this action get job log o k response has a 2xx status code +func (o *ActionGetJobLogOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this action get job log o k response has a 3xx status code +func (o *ActionGetJobLogOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action get job log o k response has a 4xx status code +func (o *ActionGetJobLogOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this action get job log o k response has a 5xx status code +func (o *ActionGetJobLogOK) IsServerError() bool { + return false +} + +// IsCode returns true when this action get job log o k response a status code equal to that given +func (o *ActionGetJobLogOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the action get job log o k response +func (o *ActionGetJobLogOK) Code() int { + return 200 +} + +func (o *ActionGetJobLogOK) Error() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogOK %+v", 200, o.Payload) +} + +func (o *ActionGetJobLogOK) String() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogOK %+v", 200, o.Payload) +} + +func (o *ActionGetJobLogOK) GetPayload() string { + return o.Payload +} + +func (o *ActionGetJobLogOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Content-Type + hdrContentType := response.GetHeader("Content-Type") + + if hdrContentType != "" { + o.ContentType = hdrContentType + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionGetJobLogUnauthorized creates a ActionGetJobLogUnauthorized with default headers values +func NewActionGetJobLogUnauthorized() *ActionGetJobLogUnauthorized { + return &ActionGetJobLogUnauthorized{} +} + +/* +ActionGetJobLogUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ActionGetJobLogUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action get job log unauthorized response has a 2xx status code +func (o *ActionGetJobLogUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action get job log unauthorized response has a 3xx status code +func (o *ActionGetJobLogUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action get job log unauthorized response has a 4xx status code +func (o *ActionGetJobLogUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this action get job log unauthorized response has a 5xx status code +func (o *ActionGetJobLogUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this action get job log unauthorized response a status code equal to that given +func (o *ActionGetJobLogUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the action get job log unauthorized response +func (o *ActionGetJobLogUnauthorized) Code() int { + return 401 +} + +func (o *ActionGetJobLogUnauthorized) Error() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogUnauthorized %+v", 401, o.Payload) +} + +func (o *ActionGetJobLogUnauthorized) String() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogUnauthorized %+v", 401, o.Payload) +} + +func (o *ActionGetJobLogUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionGetJobLogUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionGetJobLogForbidden creates a ActionGetJobLogForbidden with default headers values +func NewActionGetJobLogForbidden() *ActionGetJobLogForbidden { + return &ActionGetJobLogForbidden{} +} + +/* +ActionGetJobLogForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ActionGetJobLogForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action get job log forbidden response has a 2xx status code +func (o *ActionGetJobLogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action get job log forbidden response has a 3xx status code +func (o *ActionGetJobLogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action get job log forbidden response has a 4xx status code +func (o *ActionGetJobLogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this action get job log forbidden response has a 5xx status code +func (o *ActionGetJobLogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this action get job log forbidden response a status code equal to that given +func (o *ActionGetJobLogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the action get job log forbidden response +func (o *ActionGetJobLogForbidden) Code() int { + return 403 +} + +func (o *ActionGetJobLogForbidden) Error() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogForbidden %+v", 403, o.Payload) +} + +func (o *ActionGetJobLogForbidden) String() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogForbidden %+v", 403, o.Payload) +} + +func (o *ActionGetJobLogForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionGetJobLogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionGetJobLogNotFound creates a ActionGetJobLogNotFound with default headers values +func NewActionGetJobLogNotFound() *ActionGetJobLogNotFound { + return &ActionGetJobLogNotFound{} +} + +/* +ActionGetJobLogNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ActionGetJobLogNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action get job log not found response has a 2xx status code +func (o *ActionGetJobLogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action get job log not found response has a 3xx status code +func (o *ActionGetJobLogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action get job log not found response has a 4xx status code +func (o *ActionGetJobLogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this action get job log not found response has a 5xx status code +func (o *ActionGetJobLogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this action get job log not found response a status code equal to that given +func (o *ActionGetJobLogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the action get job log not found response +func (o *ActionGetJobLogNotFound) Code() int { + return 404 +} + +func (o *ActionGetJobLogNotFound) Error() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogNotFound %+v", 404, o.Payload) +} + +func (o *ActionGetJobLogNotFound) String() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogNotFound %+v", 404, o.Payload) +} + +func (o *ActionGetJobLogNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionGetJobLogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionGetJobLogInternalServerError creates a ActionGetJobLogInternalServerError with default headers values +func NewActionGetJobLogInternalServerError() *ActionGetJobLogInternalServerError { + return &ActionGetJobLogInternalServerError{} +} + +/* +ActionGetJobLogInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ActionGetJobLogInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action get job log internal server error response has a 2xx status code +func (o *ActionGetJobLogInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action get job log internal server error response has a 3xx status code +func (o *ActionGetJobLogInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action get job log internal server error response has a 4xx status code +func (o *ActionGetJobLogInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this action get job log internal server error response has a 5xx status code +func (o *ActionGetJobLogInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this action get job log internal server error response a status code equal to that given +func (o *ActionGetJobLogInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the action get job log internal server error response +func (o *ActionGetJobLogInternalServerError) Code() int { + return 500 +} + +func (o *ActionGetJobLogInternalServerError) Error() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogInternalServerError %+v", 500, o.Payload) +} + +func (o *ActionGetJobLogInternalServerError) String() string { + return fmt.Sprintf("[GET /jobservice/jobs/{job_id}/log][%d] actionGetJobLogInternalServerError %+v", 500, o.Payload) +} + +func (o *ActionGetJobLogInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionGetJobLogInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/jobservice/action_pending_jobs_parameters.go b/pkg/harbor/client/jobservice/action_pending_jobs_parameters.go new file mode 100644 index 0000000..9a6ec9e --- /dev/null +++ b/pkg/harbor/client/jobservice/action_pending_jobs_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// NewActionPendingJobsParams creates a new ActionPendingJobsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewActionPendingJobsParams() *ActionPendingJobsParams { + return &ActionPendingJobsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewActionPendingJobsParamsWithTimeout creates a new ActionPendingJobsParams object +// with the ability to set a timeout on a request. +func NewActionPendingJobsParamsWithTimeout(timeout time.Duration) *ActionPendingJobsParams { + return &ActionPendingJobsParams{ + timeout: timeout, + } +} + +// NewActionPendingJobsParamsWithContext creates a new ActionPendingJobsParams object +// with the ability to set a context for a request. +func NewActionPendingJobsParamsWithContext(ctx context.Context) *ActionPendingJobsParams { + return &ActionPendingJobsParams{ + Context: ctx, + } +} + +// NewActionPendingJobsParamsWithHTTPClient creates a new ActionPendingJobsParams object +// with the ability to set a custom HTTPClient for a request. +func NewActionPendingJobsParamsWithHTTPClient(client *http.Client) *ActionPendingJobsParams { + return &ActionPendingJobsParams{ + HTTPClient: client, + } +} + +/* +ActionPendingJobsParams contains all the parameters to send to the API endpoint + + for the action pending jobs operation. + + Typically these are written to a http.Request. +*/ +type ActionPendingJobsParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + // ActionRequest. + ActionRequest *models.ActionRequest `js:"actionRequest"` + + /* JobType. + + The type of the job. 'all' stands for all job types + */ + JobType string `js:"jobType"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the action pending jobs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ActionPendingJobsParams) WithDefaults() *ActionPendingJobsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the action pending jobs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ActionPendingJobsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the action pending jobs params +func (o *ActionPendingJobsParams) WithTimeout(timeout time.Duration) *ActionPendingJobsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the action pending jobs params +func (o *ActionPendingJobsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the action pending jobs params +func (o *ActionPendingJobsParams) WithContext(ctx context.Context) *ActionPendingJobsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the action pending jobs params +func (o *ActionPendingJobsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the action pending jobs params +func (o *ActionPendingJobsParams) WithHTTPClient(client *http.Client) *ActionPendingJobsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the action pending jobs params +func (o *ActionPendingJobsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the action pending jobs params +func (o *ActionPendingJobsParams) WithXRequestID(xRequestID *string) *ActionPendingJobsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the action pending jobs params +func (o *ActionPendingJobsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithActionRequest adds the actionRequest to the action pending jobs params +func (o *ActionPendingJobsParams) WithActionRequest(actionRequest *models.ActionRequest) *ActionPendingJobsParams { + o.SetActionRequest(actionRequest) + return o +} + +// SetActionRequest adds the actionRequest to the action pending jobs params +func (o *ActionPendingJobsParams) SetActionRequest(actionRequest *models.ActionRequest) { + o.ActionRequest = actionRequest +} + +// WithJobType adds the jobType to the action pending jobs params +func (o *ActionPendingJobsParams) WithJobType(jobType string) *ActionPendingJobsParams { + o.SetJobType(jobType) + return o +} + +// SetJobType adds the jobType to the action pending jobs params +func (o *ActionPendingJobsParams) SetJobType(jobType string) { + o.JobType = jobType +} + +// WriteToRequest writes these params to a swagger request +func (o *ActionPendingJobsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.ActionRequest != nil { + if err := r.SetBodyParam(o.ActionRequest); err != nil { + return err + } + } + + // path param job_type + if err := r.SetPathParam("job_type", o.JobType); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/action_pending_jobs_responses.go b/pkg/harbor/client/jobservice/action_pending_jobs_responses.go new file mode 100644 index 0000000..bc1f08d --- /dev/null +++ b/pkg/harbor/client/jobservice/action_pending_jobs_responses.go @@ -0,0 +1,521 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ActionPendingJobsReader is a Reader for the ActionPendingJobs structure. +type ActionPendingJobsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ActionPendingJobsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewActionPendingJobsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewActionPendingJobsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewActionPendingJobsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewActionPendingJobsNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewActionPendingJobsUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewActionPendingJobsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /jobservice/queues/{job_type}] actionPendingJobs", response, response.Code()) + } +} + +// NewActionPendingJobsOK creates a ActionPendingJobsOK with default headers values +func NewActionPendingJobsOK() *ActionPendingJobsOK { + return &ActionPendingJobsOK{} +} + +/* +ActionPendingJobsOK describes a response with status code 200, with default header values. + +take action to the jobs in the queue successfully. +*/ +type ActionPendingJobsOK struct { +} + +// IsSuccess returns true when this action pending jobs o k response has a 2xx status code +func (o *ActionPendingJobsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this action pending jobs o k response has a 3xx status code +func (o *ActionPendingJobsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs o k response has a 4xx status code +func (o *ActionPendingJobsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this action pending jobs o k response has a 5xx status code +func (o *ActionPendingJobsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this action pending jobs o k response a status code equal to that given +func (o *ActionPendingJobsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the action pending jobs o k response +func (o *ActionPendingJobsOK) Code() int { + return 200 +} + +func (o *ActionPendingJobsOK) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsOK ", 200) +} + +func (o *ActionPendingJobsOK) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsOK ", 200) +} + +func (o *ActionPendingJobsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewActionPendingJobsUnauthorized creates a ActionPendingJobsUnauthorized with default headers values +func NewActionPendingJobsUnauthorized() *ActionPendingJobsUnauthorized { + return &ActionPendingJobsUnauthorized{} +} + +/* +ActionPendingJobsUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ActionPendingJobsUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action pending jobs unauthorized response has a 2xx status code +func (o *ActionPendingJobsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action pending jobs unauthorized response has a 3xx status code +func (o *ActionPendingJobsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs unauthorized response has a 4xx status code +func (o *ActionPendingJobsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this action pending jobs unauthorized response has a 5xx status code +func (o *ActionPendingJobsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this action pending jobs unauthorized response a status code equal to that given +func (o *ActionPendingJobsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the action pending jobs unauthorized response +func (o *ActionPendingJobsUnauthorized) Code() int { + return 401 +} + +func (o *ActionPendingJobsUnauthorized) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsUnauthorized %+v", 401, o.Payload) +} + +func (o *ActionPendingJobsUnauthorized) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsUnauthorized %+v", 401, o.Payload) +} + +func (o *ActionPendingJobsUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionPendingJobsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionPendingJobsForbidden creates a ActionPendingJobsForbidden with default headers values +func NewActionPendingJobsForbidden() *ActionPendingJobsForbidden { + return &ActionPendingJobsForbidden{} +} + +/* +ActionPendingJobsForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ActionPendingJobsForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action pending jobs forbidden response has a 2xx status code +func (o *ActionPendingJobsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action pending jobs forbidden response has a 3xx status code +func (o *ActionPendingJobsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs forbidden response has a 4xx status code +func (o *ActionPendingJobsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this action pending jobs forbidden response has a 5xx status code +func (o *ActionPendingJobsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this action pending jobs forbidden response a status code equal to that given +func (o *ActionPendingJobsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the action pending jobs forbidden response +func (o *ActionPendingJobsForbidden) Code() int { + return 403 +} + +func (o *ActionPendingJobsForbidden) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsForbidden %+v", 403, o.Payload) +} + +func (o *ActionPendingJobsForbidden) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsForbidden %+v", 403, o.Payload) +} + +func (o *ActionPendingJobsForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionPendingJobsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionPendingJobsNotFound creates a ActionPendingJobsNotFound with default headers values +func NewActionPendingJobsNotFound() *ActionPendingJobsNotFound { + return &ActionPendingJobsNotFound{} +} + +/* +ActionPendingJobsNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ActionPendingJobsNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action pending jobs not found response has a 2xx status code +func (o *ActionPendingJobsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action pending jobs not found response has a 3xx status code +func (o *ActionPendingJobsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs not found response has a 4xx status code +func (o *ActionPendingJobsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this action pending jobs not found response has a 5xx status code +func (o *ActionPendingJobsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this action pending jobs not found response a status code equal to that given +func (o *ActionPendingJobsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the action pending jobs not found response +func (o *ActionPendingJobsNotFound) Code() int { + return 404 +} + +func (o *ActionPendingJobsNotFound) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsNotFound %+v", 404, o.Payload) +} + +func (o *ActionPendingJobsNotFound) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsNotFound %+v", 404, o.Payload) +} + +func (o *ActionPendingJobsNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionPendingJobsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionPendingJobsUnprocessableEntity creates a ActionPendingJobsUnprocessableEntity with default headers values +func NewActionPendingJobsUnprocessableEntity() *ActionPendingJobsUnprocessableEntity { + return &ActionPendingJobsUnprocessableEntity{} +} + +/* +ActionPendingJobsUnprocessableEntity describes a response with status code 422, with default header values. + +Unsupported Type +*/ +type ActionPendingJobsUnprocessableEntity struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action pending jobs unprocessable entity response has a 2xx status code +func (o *ActionPendingJobsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action pending jobs unprocessable entity response has a 3xx status code +func (o *ActionPendingJobsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs unprocessable entity response has a 4xx status code +func (o *ActionPendingJobsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this action pending jobs unprocessable entity response has a 5xx status code +func (o *ActionPendingJobsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this action pending jobs unprocessable entity response a status code equal to that given +func (o *ActionPendingJobsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the action pending jobs unprocessable entity response +func (o *ActionPendingJobsUnprocessableEntity) Code() int { + return 422 +} + +func (o *ActionPendingJobsUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *ActionPendingJobsUnprocessableEntity) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *ActionPendingJobsUnprocessableEntity) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionPendingJobsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewActionPendingJobsInternalServerError creates a ActionPendingJobsInternalServerError with default headers values +func NewActionPendingJobsInternalServerError() *ActionPendingJobsInternalServerError { + return &ActionPendingJobsInternalServerError{} +} + +/* +ActionPendingJobsInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ActionPendingJobsInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this action pending jobs internal server error response has a 2xx status code +func (o *ActionPendingJobsInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this action pending jobs internal server error response has a 3xx status code +func (o *ActionPendingJobsInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this action pending jobs internal server error response has a 4xx status code +func (o *ActionPendingJobsInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this action pending jobs internal server error response has a 5xx status code +func (o *ActionPendingJobsInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this action pending jobs internal server error response a status code equal to that given +func (o *ActionPendingJobsInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the action pending jobs internal server error response +func (o *ActionPendingJobsInternalServerError) Code() int { + return 500 +} + +func (o *ActionPendingJobsInternalServerError) Error() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsInternalServerError %+v", 500, o.Payload) +} + +func (o *ActionPendingJobsInternalServerError) String() string { + return fmt.Sprintf("[PUT /jobservice/queues/{job_type}][%d] actionPendingJobsInternalServerError %+v", 500, o.Payload) +} + +func (o *ActionPendingJobsInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ActionPendingJobsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/jobservice/get_worker_pools_parameters.go b/pkg/harbor/client/jobservice/get_worker_pools_parameters.go new file mode 100644 index 0000000..e5c2d1b --- /dev/null +++ b/pkg/harbor/client/jobservice/get_worker_pools_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetWorkerPoolsParams creates a new GetWorkerPoolsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetWorkerPoolsParams() *GetWorkerPoolsParams { + return &GetWorkerPoolsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetWorkerPoolsParamsWithTimeout creates a new GetWorkerPoolsParams object +// with the ability to set a timeout on a request. +func NewGetWorkerPoolsParamsWithTimeout(timeout time.Duration) *GetWorkerPoolsParams { + return &GetWorkerPoolsParams{ + timeout: timeout, + } +} + +// NewGetWorkerPoolsParamsWithContext creates a new GetWorkerPoolsParams object +// with the ability to set a context for a request. +func NewGetWorkerPoolsParamsWithContext(ctx context.Context) *GetWorkerPoolsParams { + return &GetWorkerPoolsParams{ + Context: ctx, + } +} + +// NewGetWorkerPoolsParamsWithHTTPClient creates a new GetWorkerPoolsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetWorkerPoolsParamsWithHTTPClient(client *http.Client) *GetWorkerPoolsParams { + return &GetWorkerPoolsParams{ + HTTPClient: client, + } +} + +/* +GetWorkerPoolsParams contains all the parameters to send to the API endpoint + + for the get worker pools operation. + + Typically these are written to a http.Request. +*/ +type GetWorkerPoolsParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get worker pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkerPoolsParams) WithDefaults() *GetWorkerPoolsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get worker pools params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkerPoolsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get worker pools params +func (o *GetWorkerPoolsParams) WithTimeout(timeout time.Duration) *GetWorkerPoolsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get worker pools params +func (o *GetWorkerPoolsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get worker pools params +func (o *GetWorkerPoolsParams) WithContext(ctx context.Context) *GetWorkerPoolsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get worker pools params +func (o *GetWorkerPoolsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get worker pools params +func (o *GetWorkerPoolsParams) WithHTTPClient(client *http.Client) *GetWorkerPoolsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get worker pools params +func (o *GetWorkerPoolsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get worker pools params +func (o *GetWorkerPoolsParams) WithXRequestID(xRequestID *string) *GetWorkerPoolsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get worker pools params +func (o *GetWorkerPoolsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetWorkerPoolsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/get_worker_pools_responses.go b/pkg/harbor/client/jobservice/get_worker_pools_responses.go new file mode 100644 index 0000000..3a4d0cc --- /dev/null +++ b/pkg/harbor/client/jobservice/get_worker_pools_responses.go @@ -0,0 +1,359 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetWorkerPoolsReader is a Reader for the GetWorkerPools structure. +type GetWorkerPoolsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetWorkerPoolsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetWorkerPoolsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetWorkerPoolsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetWorkerPoolsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetWorkerPoolsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /jobservice/pools] getWorkerPools", response, response.Code()) + } +} + +// NewGetWorkerPoolsOK creates a GetWorkerPoolsOK with default headers values +func NewGetWorkerPoolsOK() *GetWorkerPoolsOK { + return &GetWorkerPoolsOK{} +} + +/* +GetWorkerPoolsOK describes a response with status code 200, with default header values. + +Get worker pools successfully. +*/ +type GetWorkerPoolsOK struct { + Payload []*models.WorkerPool +} + +// IsSuccess returns true when this get worker pools o k response has a 2xx status code +func (o *GetWorkerPoolsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get worker pools o k response has a 3xx status code +func (o *GetWorkerPoolsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get worker pools o k response has a 4xx status code +func (o *GetWorkerPoolsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get worker pools o k response has a 5xx status code +func (o *GetWorkerPoolsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get worker pools o k response a status code equal to that given +func (o *GetWorkerPoolsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get worker pools o k response +func (o *GetWorkerPoolsOK) Code() int { + return 200 +} + +func (o *GetWorkerPoolsOK) Error() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsOK %+v", 200, o.Payload) +} + +func (o *GetWorkerPoolsOK) String() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsOK %+v", 200, o.Payload) +} + +func (o *GetWorkerPoolsOK) GetPayload() []*models.WorkerPool { + return o.Payload +} + +func (o *GetWorkerPoolsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkerPoolsUnauthorized creates a GetWorkerPoolsUnauthorized with default headers values +func NewGetWorkerPoolsUnauthorized() *GetWorkerPoolsUnauthorized { + return &GetWorkerPoolsUnauthorized{} +} + +/* +GetWorkerPoolsUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetWorkerPoolsUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get worker pools unauthorized response has a 2xx status code +func (o *GetWorkerPoolsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get worker pools unauthorized response has a 3xx status code +func (o *GetWorkerPoolsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get worker pools unauthorized response has a 4xx status code +func (o *GetWorkerPoolsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get worker pools unauthorized response has a 5xx status code +func (o *GetWorkerPoolsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get worker pools unauthorized response a status code equal to that given +func (o *GetWorkerPoolsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get worker pools unauthorized response +func (o *GetWorkerPoolsUnauthorized) Code() int { + return 401 +} + +func (o *GetWorkerPoolsUnauthorized) Error() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsUnauthorized %+v", 401, o.Payload) +} + +func (o *GetWorkerPoolsUnauthorized) String() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsUnauthorized %+v", 401, o.Payload) +} + +func (o *GetWorkerPoolsUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkerPoolsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkerPoolsForbidden creates a GetWorkerPoolsForbidden with default headers values +func NewGetWorkerPoolsForbidden() *GetWorkerPoolsForbidden { + return &GetWorkerPoolsForbidden{} +} + +/* +GetWorkerPoolsForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetWorkerPoolsForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get worker pools forbidden response has a 2xx status code +func (o *GetWorkerPoolsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get worker pools forbidden response has a 3xx status code +func (o *GetWorkerPoolsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get worker pools forbidden response has a 4xx status code +func (o *GetWorkerPoolsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get worker pools forbidden response has a 5xx status code +func (o *GetWorkerPoolsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get worker pools forbidden response a status code equal to that given +func (o *GetWorkerPoolsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get worker pools forbidden response +func (o *GetWorkerPoolsForbidden) Code() int { + return 403 +} + +func (o *GetWorkerPoolsForbidden) Error() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsForbidden %+v", 403, o.Payload) +} + +func (o *GetWorkerPoolsForbidden) String() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsForbidden %+v", 403, o.Payload) +} + +func (o *GetWorkerPoolsForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkerPoolsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkerPoolsInternalServerError creates a GetWorkerPoolsInternalServerError with default headers values +func NewGetWorkerPoolsInternalServerError() *GetWorkerPoolsInternalServerError { + return &GetWorkerPoolsInternalServerError{} +} + +/* +GetWorkerPoolsInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetWorkerPoolsInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get worker pools internal server error response has a 2xx status code +func (o *GetWorkerPoolsInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get worker pools internal server error response has a 3xx status code +func (o *GetWorkerPoolsInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get worker pools internal server error response has a 4xx status code +func (o *GetWorkerPoolsInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get worker pools internal server error response has a 5xx status code +func (o *GetWorkerPoolsInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get worker pools internal server error response a status code equal to that given +func (o *GetWorkerPoolsInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get worker pools internal server error response +func (o *GetWorkerPoolsInternalServerError) Code() int { + return 500 +} + +func (o *GetWorkerPoolsInternalServerError) Error() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsInternalServerError %+v", 500, o.Payload) +} + +func (o *GetWorkerPoolsInternalServerError) String() string { + return fmt.Sprintf("[GET /jobservice/pools][%d] getWorkerPoolsInternalServerError %+v", 500, o.Payload) +} + +func (o *GetWorkerPoolsInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkerPoolsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/jobservice/get_workers_parameters.go b/pkg/harbor/client/jobservice/get_workers_parameters.go new file mode 100644 index 0000000..2b0241e --- /dev/null +++ b/pkg/harbor/client/jobservice/get_workers_parameters.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetWorkersParams creates a new GetWorkersParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetWorkersParams() *GetWorkersParams { + return &GetWorkersParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetWorkersParamsWithTimeout creates a new GetWorkersParams object +// with the ability to set a timeout on a request. +func NewGetWorkersParamsWithTimeout(timeout time.Duration) *GetWorkersParams { + return &GetWorkersParams{ + timeout: timeout, + } +} + +// NewGetWorkersParamsWithContext creates a new GetWorkersParams object +// with the ability to set a context for a request. +func NewGetWorkersParamsWithContext(ctx context.Context) *GetWorkersParams { + return &GetWorkersParams{ + Context: ctx, + } +} + +// NewGetWorkersParamsWithHTTPClient creates a new GetWorkersParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetWorkersParamsWithHTTPClient(client *http.Client) *GetWorkersParams { + return &GetWorkersParams{ + HTTPClient: client, + } +} + +/* +GetWorkersParams contains all the parameters to send to the API endpoint + + for the get workers operation. + + Typically these are written to a http.Request. +*/ +type GetWorkersParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* PoolID. + + The name of the pool. 'all' stands for all pools + */ + PoolID string `js:"poolID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get workers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkersParams) WithDefaults() *GetWorkersParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get workers params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetWorkersParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get workers params +func (o *GetWorkersParams) WithTimeout(timeout time.Duration) *GetWorkersParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get workers params +func (o *GetWorkersParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get workers params +func (o *GetWorkersParams) WithContext(ctx context.Context) *GetWorkersParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get workers params +func (o *GetWorkersParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get workers params +func (o *GetWorkersParams) WithHTTPClient(client *http.Client) *GetWorkersParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get workers params +func (o *GetWorkersParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get workers params +func (o *GetWorkersParams) WithXRequestID(xRequestID *string) *GetWorkersParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get workers params +func (o *GetWorkersParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPoolID adds the poolID to the get workers params +func (o *GetWorkersParams) WithPoolID(poolID string) *GetWorkersParams { + o.SetPoolID(poolID) + return o +} + +// SetPoolID adds the poolId to the get workers params +func (o *GetWorkersParams) SetPoolID(poolID string) { + o.PoolID = poolID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetWorkersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param pool_id + if err := r.SetPathParam("pool_id", o.PoolID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/get_workers_responses.go b/pkg/harbor/client/jobservice/get_workers_responses.go new file mode 100644 index 0000000..3d94bbd --- /dev/null +++ b/pkg/harbor/client/jobservice/get_workers_responses.go @@ -0,0 +1,445 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetWorkersReader is a Reader for the GetWorkers structure. +type GetWorkersReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetWorkersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetWorkersOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetWorkersUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetWorkersForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetWorkersNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetWorkersInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /jobservice/pools/{pool_id}/workers] getWorkers", response, response.Code()) + } +} + +// NewGetWorkersOK creates a GetWorkersOK with default headers values +func NewGetWorkersOK() *GetWorkersOK { + return &GetWorkersOK{} +} + +/* +GetWorkersOK describes a response with status code 200, with default header values. + +Get workers successfully. +*/ +type GetWorkersOK struct { + Payload []*models.Worker +} + +// IsSuccess returns true when this get workers o k response has a 2xx status code +func (o *GetWorkersOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get workers o k response has a 3xx status code +func (o *GetWorkersOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers o k response has a 4xx status code +func (o *GetWorkersOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get workers o k response has a 5xx status code +func (o *GetWorkersOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers o k response a status code equal to that given +func (o *GetWorkersOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get workers o k response +func (o *GetWorkersOK) Code() int { + return 200 +} + +func (o *GetWorkersOK) Error() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersOK %+v", 200, o.Payload) +} + +func (o *GetWorkersOK) String() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersOK %+v", 200, o.Payload) +} + +func (o *GetWorkersOK) GetPayload() []*models.Worker { + return o.Payload +} + +func (o *GetWorkersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkersUnauthorized creates a GetWorkersUnauthorized with default headers values +func NewGetWorkersUnauthorized() *GetWorkersUnauthorized { + return &GetWorkersUnauthorized{} +} + +/* +GetWorkersUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetWorkersUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get workers unauthorized response has a 2xx status code +func (o *GetWorkersUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers unauthorized response has a 3xx status code +func (o *GetWorkersUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers unauthorized response has a 4xx status code +func (o *GetWorkersUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get workers unauthorized response has a 5xx status code +func (o *GetWorkersUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers unauthorized response a status code equal to that given +func (o *GetWorkersUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get workers unauthorized response +func (o *GetWorkersUnauthorized) Code() int { + return 401 +} + +func (o *GetWorkersUnauthorized) Error() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersUnauthorized %+v", 401, o.Payload) +} + +func (o *GetWorkersUnauthorized) String() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersUnauthorized %+v", 401, o.Payload) +} + +func (o *GetWorkersUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkersUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkersForbidden creates a GetWorkersForbidden with default headers values +func NewGetWorkersForbidden() *GetWorkersForbidden { + return &GetWorkersForbidden{} +} + +/* +GetWorkersForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetWorkersForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get workers forbidden response has a 2xx status code +func (o *GetWorkersForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers forbidden response has a 3xx status code +func (o *GetWorkersForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers forbidden response has a 4xx status code +func (o *GetWorkersForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get workers forbidden response has a 5xx status code +func (o *GetWorkersForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers forbidden response a status code equal to that given +func (o *GetWorkersForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get workers forbidden response +func (o *GetWorkersForbidden) Code() int { + return 403 +} + +func (o *GetWorkersForbidden) Error() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersForbidden %+v", 403, o.Payload) +} + +func (o *GetWorkersForbidden) String() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersForbidden %+v", 403, o.Payload) +} + +func (o *GetWorkersForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkersForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkersNotFound creates a GetWorkersNotFound with default headers values +func NewGetWorkersNotFound() *GetWorkersNotFound { + return &GetWorkersNotFound{} +} + +/* +GetWorkersNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetWorkersNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get workers not found response has a 2xx status code +func (o *GetWorkersNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers not found response has a 3xx status code +func (o *GetWorkersNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers not found response has a 4xx status code +func (o *GetWorkersNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get workers not found response has a 5xx status code +func (o *GetWorkersNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get workers not found response a status code equal to that given +func (o *GetWorkersNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get workers not found response +func (o *GetWorkersNotFound) Code() int { + return 404 +} + +func (o *GetWorkersNotFound) Error() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersNotFound %+v", 404, o.Payload) +} + +func (o *GetWorkersNotFound) String() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersNotFound %+v", 404, o.Payload) +} + +func (o *GetWorkersNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkersNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWorkersInternalServerError creates a GetWorkersInternalServerError with default headers values +func NewGetWorkersInternalServerError() *GetWorkersInternalServerError { + return &GetWorkersInternalServerError{} +} + +/* +GetWorkersInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetWorkersInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get workers internal server error response has a 2xx status code +func (o *GetWorkersInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get workers internal server error response has a 3xx status code +func (o *GetWorkersInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get workers internal server error response has a 4xx status code +func (o *GetWorkersInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get workers internal server error response has a 5xx status code +func (o *GetWorkersInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get workers internal server error response a status code equal to that given +func (o *GetWorkersInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get workers internal server error response +func (o *GetWorkersInternalServerError) Code() int { + return 500 +} + +func (o *GetWorkersInternalServerError) Error() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersInternalServerError %+v", 500, o.Payload) +} + +func (o *GetWorkersInternalServerError) String() string { + return fmt.Sprintf("[GET /jobservice/pools/{pool_id}/workers][%d] getWorkersInternalServerError %+v", 500, o.Payload) +} + +func (o *GetWorkersInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetWorkersInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/jobservice/jobservice_client.go b/pkg/harbor/client/jobservice/jobservice_client.go new file mode 100644 index 0000000..679d8d1 --- /dev/null +++ b/pkg/harbor/client/jobservice/jobservice_client.go @@ -0,0 +1,309 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the jobservice client +type API interface { + /* + ActionGetJobLog gets job log by job id + + Get job log by job id, it is only used by administrator*/ + ActionGetJobLog(ctx context.Context, params *ActionGetJobLogParams) (*ActionGetJobLogOK, error) + /* + ActionPendingJobs stops and clean pause resume pending jobs in the queue + + stop and clean, pause, resume pending jobs in the queue*/ + ActionPendingJobs(ctx context.Context, params *ActionPendingJobsParams) (*ActionPendingJobsOK, error) + /* + GetWorkerPools gets worker pools + + Get worker pools*/ + GetWorkerPools(ctx context.Context, params *GetWorkerPoolsParams) (*GetWorkerPoolsOK, error) + /* + GetWorkers gets workers + + Get workers in current pool*/ + GetWorkers(ctx context.Context, params *GetWorkersParams) (*GetWorkersOK, error) + /* + ListJobQueues lists job queues + + list job queue*/ + ListJobQueues(ctx context.Context, params *ListJobQueuesParams) (*ListJobQueuesOK, error) + /* + StopRunningJob stops running job + + Stop running job*/ + StopRunningJob(ctx context.Context, params *StopRunningJobParams) (*StopRunningJobOK, error) +} + +// New creates a new jobservice API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for jobservice API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +ActionGetJobLog gets job log by job id + +Get job log by job id, it is only used by administrator +*/ +func (a *Client) ActionGetJobLog(ctx context.Context, params *ActionGetJobLogParams) (*ActionGetJobLogOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "actionGetJobLog", + Method: "GET", + PathPattern: "/jobservice/jobs/{job_id}/log", + ProducesMediaTypes: []string{"text/plain"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ActionGetJobLogReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ActionGetJobLogOK: + return value, nil + case *ActionGetJobLogUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionGetJobLogForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionGetJobLogNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionGetJobLogInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for actionGetJobLog: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +ActionPendingJobs stops and clean pause resume pending jobs in the queue + +stop and clean, pause, resume pending jobs in the queue +*/ +func (a *Client) ActionPendingJobs(ctx context.Context, params *ActionPendingJobsParams) (*ActionPendingJobsOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "actionPendingJobs", + Method: "PUT", + PathPattern: "/jobservice/queues/{job_type}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ActionPendingJobsReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ActionPendingJobsOK: + return value, nil + case *ActionPendingJobsUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionPendingJobsForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionPendingJobsNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionPendingJobsUnprocessableEntity: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ActionPendingJobsInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for actionPendingJobs: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetWorkerPools gets worker pools + +Get worker pools +*/ +func (a *Client) GetWorkerPools(ctx context.Context, params *GetWorkerPoolsParams) (*GetWorkerPoolsOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getWorkerPools", + Method: "GET", + PathPattern: "/jobservice/pools", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetWorkerPoolsReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetWorkerPoolsOK: + return value, nil + case *GetWorkerPoolsUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetWorkerPoolsForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetWorkerPoolsInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getWorkerPools: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetWorkers gets workers + +Get workers in current pool +*/ +func (a *Client) GetWorkers(ctx context.Context, params *GetWorkersParams) (*GetWorkersOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getWorkers", + Method: "GET", + PathPattern: "/jobservice/pools/{pool_id}/workers", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetWorkersReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetWorkersOK: + return value, nil + case *GetWorkersUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetWorkersForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetWorkersNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetWorkersInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getWorkers: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +ListJobQueues lists job queues + +list job queue +*/ +func (a *Client) ListJobQueues(ctx context.Context, params *ListJobQueuesParams) (*ListJobQueuesOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listJobQueues", + Method: "GET", + PathPattern: "/jobservice/queues", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListJobQueuesReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListJobQueuesOK: + return value, nil + case *ListJobQueuesUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListJobQueuesForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListJobQueuesNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListJobQueuesInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for listJobQueues: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +StopRunningJob stops running job + +Stop running job +*/ +func (a *Client) StopRunningJob(ctx context.Context, params *StopRunningJobParams) (*StopRunningJobOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "stopRunningJob", + Method: "PUT", + PathPattern: "/jobservice/jobs/{job_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StopRunningJobReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *StopRunningJobOK: + return value, nil + case *StopRunningJobUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopRunningJobForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopRunningJobNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopRunningJobInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for stopRunningJob: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/jobservice/list_job_queues_parameters.go b/pkg/harbor/client/jobservice/list_job_queues_parameters.go new file mode 100644 index 0000000..2708372 --- /dev/null +++ b/pkg/harbor/client/jobservice/list_job_queues_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListJobQueuesParams creates a new ListJobQueuesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListJobQueuesParams() *ListJobQueuesParams { + return &ListJobQueuesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListJobQueuesParamsWithTimeout creates a new ListJobQueuesParams object +// with the ability to set a timeout on a request. +func NewListJobQueuesParamsWithTimeout(timeout time.Duration) *ListJobQueuesParams { + return &ListJobQueuesParams{ + timeout: timeout, + } +} + +// NewListJobQueuesParamsWithContext creates a new ListJobQueuesParams object +// with the ability to set a context for a request. +func NewListJobQueuesParamsWithContext(ctx context.Context) *ListJobQueuesParams { + return &ListJobQueuesParams{ + Context: ctx, + } +} + +// NewListJobQueuesParamsWithHTTPClient creates a new ListJobQueuesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListJobQueuesParamsWithHTTPClient(client *http.Client) *ListJobQueuesParams { + return &ListJobQueuesParams{ + HTTPClient: client, + } +} + +/* +ListJobQueuesParams contains all the parameters to send to the API endpoint + + for the list job queues operation. + + Typically these are written to a http.Request. +*/ +type ListJobQueuesParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list job queues params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListJobQueuesParams) WithDefaults() *ListJobQueuesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list job queues params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListJobQueuesParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list job queues params +func (o *ListJobQueuesParams) WithTimeout(timeout time.Duration) *ListJobQueuesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list job queues params +func (o *ListJobQueuesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list job queues params +func (o *ListJobQueuesParams) WithContext(ctx context.Context) *ListJobQueuesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list job queues params +func (o *ListJobQueuesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list job queues params +func (o *ListJobQueuesParams) WithHTTPClient(client *http.Client) *ListJobQueuesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list job queues params +func (o *ListJobQueuesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the list job queues params +func (o *ListJobQueuesParams) WithXRequestID(xRequestID *string) *ListJobQueuesParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list job queues params +func (o *ListJobQueuesParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListJobQueuesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/list_job_queues_responses.go b/pkg/harbor/client/jobservice/list_job_queues_responses.go new file mode 100644 index 0000000..e3de768 --- /dev/null +++ b/pkg/harbor/client/jobservice/list_job_queues_responses.go @@ -0,0 +1,445 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListJobQueuesReader is a Reader for the ListJobQueues structure. +type ListJobQueuesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListJobQueuesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListJobQueuesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewListJobQueuesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListJobQueuesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListJobQueuesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListJobQueuesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /jobservice/queues] listJobQueues", response, response.Code()) + } +} + +// NewListJobQueuesOK creates a ListJobQueuesOK with default headers values +func NewListJobQueuesOK() *ListJobQueuesOK { + return &ListJobQueuesOK{} +} + +/* +ListJobQueuesOK describes a response with status code 200, with default header values. + +List job queue successfully. +*/ +type ListJobQueuesOK struct { + Payload []*models.JobQueue +} + +// IsSuccess returns true when this list job queues o k response has a 2xx status code +func (o *ListJobQueuesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list job queues o k response has a 3xx status code +func (o *ListJobQueuesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list job queues o k response has a 4xx status code +func (o *ListJobQueuesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list job queues o k response has a 5xx status code +func (o *ListJobQueuesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list job queues o k response a status code equal to that given +func (o *ListJobQueuesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list job queues o k response +func (o *ListJobQueuesOK) Code() int { + return 200 +} + +func (o *ListJobQueuesOK) Error() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesOK %+v", 200, o.Payload) +} + +func (o *ListJobQueuesOK) String() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesOK %+v", 200, o.Payload) +} + +func (o *ListJobQueuesOK) GetPayload() []*models.JobQueue { + return o.Payload +} + +func (o *ListJobQueuesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListJobQueuesUnauthorized creates a ListJobQueuesUnauthorized with default headers values +func NewListJobQueuesUnauthorized() *ListJobQueuesUnauthorized { + return &ListJobQueuesUnauthorized{} +} + +/* +ListJobQueuesUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListJobQueuesUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list job queues unauthorized response has a 2xx status code +func (o *ListJobQueuesUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list job queues unauthorized response has a 3xx status code +func (o *ListJobQueuesUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list job queues unauthorized response has a 4xx status code +func (o *ListJobQueuesUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list job queues unauthorized response has a 5xx status code +func (o *ListJobQueuesUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list job queues unauthorized response a status code equal to that given +func (o *ListJobQueuesUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list job queues unauthorized response +func (o *ListJobQueuesUnauthorized) Code() int { + return 401 +} + +func (o *ListJobQueuesUnauthorized) Error() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListJobQueuesUnauthorized) String() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListJobQueuesUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListJobQueuesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListJobQueuesForbidden creates a ListJobQueuesForbidden with default headers values +func NewListJobQueuesForbidden() *ListJobQueuesForbidden { + return &ListJobQueuesForbidden{} +} + +/* +ListJobQueuesForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ListJobQueuesForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list job queues forbidden response has a 2xx status code +func (o *ListJobQueuesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list job queues forbidden response has a 3xx status code +func (o *ListJobQueuesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list job queues forbidden response has a 4xx status code +func (o *ListJobQueuesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list job queues forbidden response has a 5xx status code +func (o *ListJobQueuesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list job queues forbidden response a status code equal to that given +func (o *ListJobQueuesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list job queues forbidden response +func (o *ListJobQueuesForbidden) Code() int { + return 403 +} + +func (o *ListJobQueuesForbidden) Error() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesForbidden %+v", 403, o.Payload) +} + +func (o *ListJobQueuesForbidden) String() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesForbidden %+v", 403, o.Payload) +} + +func (o *ListJobQueuesForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListJobQueuesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListJobQueuesNotFound creates a ListJobQueuesNotFound with default headers values +func NewListJobQueuesNotFound() *ListJobQueuesNotFound { + return &ListJobQueuesNotFound{} +} + +/* +ListJobQueuesNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ListJobQueuesNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list job queues not found response has a 2xx status code +func (o *ListJobQueuesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list job queues not found response has a 3xx status code +func (o *ListJobQueuesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list job queues not found response has a 4xx status code +func (o *ListJobQueuesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list job queues not found response has a 5xx status code +func (o *ListJobQueuesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list job queues not found response a status code equal to that given +func (o *ListJobQueuesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list job queues not found response +func (o *ListJobQueuesNotFound) Code() int { + return 404 +} + +func (o *ListJobQueuesNotFound) Error() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesNotFound %+v", 404, o.Payload) +} + +func (o *ListJobQueuesNotFound) String() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesNotFound %+v", 404, o.Payload) +} + +func (o *ListJobQueuesNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListJobQueuesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListJobQueuesInternalServerError creates a ListJobQueuesInternalServerError with default headers values +func NewListJobQueuesInternalServerError() *ListJobQueuesInternalServerError { + return &ListJobQueuesInternalServerError{} +} + +/* +ListJobQueuesInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListJobQueuesInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list job queues internal server error response has a 2xx status code +func (o *ListJobQueuesInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list job queues internal server error response has a 3xx status code +func (o *ListJobQueuesInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list job queues internal server error response has a 4xx status code +func (o *ListJobQueuesInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list job queues internal server error response has a 5xx status code +func (o *ListJobQueuesInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list job queues internal server error response a status code equal to that given +func (o *ListJobQueuesInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list job queues internal server error response +func (o *ListJobQueuesInternalServerError) Code() int { + return 500 +} + +func (o *ListJobQueuesInternalServerError) Error() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListJobQueuesInternalServerError) String() string { + return fmt.Sprintf("[GET /jobservice/queues][%d] listJobQueuesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListJobQueuesInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListJobQueuesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/jobservice/stop_running_job_parameters.go b/pkg/harbor/client/jobservice/stop_running_job_parameters.go new file mode 100644 index 0000000..8ce969b --- /dev/null +++ b/pkg/harbor/client/jobservice/stop_running_job_parameters.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewStopRunningJobParams creates a new StopRunningJobParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStopRunningJobParams() *StopRunningJobParams { + return &StopRunningJobParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStopRunningJobParamsWithTimeout creates a new StopRunningJobParams object +// with the ability to set a timeout on a request. +func NewStopRunningJobParamsWithTimeout(timeout time.Duration) *StopRunningJobParams { + return &StopRunningJobParams{ + timeout: timeout, + } +} + +// NewStopRunningJobParamsWithContext creates a new StopRunningJobParams object +// with the ability to set a context for a request. +func NewStopRunningJobParamsWithContext(ctx context.Context) *StopRunningJobParams { + return &StopRunningJobParams{ + Context: ctx, + } +} + +// NewStopRunningJobParamsWithHTTPClient creates a new StopRunningJobParams object +// with the ability to set a custom HTTPClient for a request. +func NewStopRunningJobParamsWithHTTPClient(client *http.Client) *StopRunningJobParams { + return &StopRunningJobParams{ + HTTPClient: client, + } +} + +/* +StopRunningJobParams contains all the parameters to send to the API endpoint + + for the stop running job operation. + + Typically these are written to a http.Request. +*/ +type StopRunningJobParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* JobID. + + The id of the job. + */ + JobID string `js:"jobID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the stop running job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopRunningJobParams) WithDefaults() *StopRunningJobParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the stop running job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopRunningJobParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the stop running job params +func (o *StopRunningJobParams) WithTimeout(timeout time.Duration) *StopRunningJobParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the stop running job params +func (o *StopRunningJobParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the stop running job params +func (o *StopRunningJobParams) WithContext(ctx context.Context) *StopRunningJobParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the stop running job params +func (o *StopRunningJobParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the stop running job params +func (o *StopRunningJobParams) WithHTTPClient(client *http.Client) *StopRunningJobParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the stop running job params +func (o *StopRunningJobParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the stop running job params +func (o *StopRunningJobParams) WithXRequestID(xRequestID *string) *StopRunningJobParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop running job params +func (o *StopRunningJobParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithJobID adds the jobID to the stop running job params +func (o *StopRunningJobParams) WithJobID(jobID string) *StopRunningJobParams { + o.SetJobID(jobID) + return o +} + +// SetJobID adds the jobId to the stop running job params +func (o *StopRunningJobParams) SetJobID(jobID string) { + o.JobID = jobID +} + +// WriteToRequest writes these params to a swagger request +func (o *StopRunningJobParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param job_id + if err := r.SetPathParam("job_id", o.JobID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/jobservice/stop_running_job_responses.go b/pkg/harbor/client/jobservice/stop_running_job_responses.go new file mode 100644 index 0000000..a58135b --- /dev/null +++ b/pkg/harbor/client/jobservice/stop_running_job_responses.go @@ -0,0 +1,435 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package jobservice + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// StopRunningJobReader is a Reader for the StopRunningJob structure. +type StopRunningJobReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StopRunningJobReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStopRunningJobOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewStopRunningJobUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewStopRunningJobForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewStopRunningJobNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewStopRunningJobInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /jobservice/jobs/{job_id}] stopRunningJob", response, response.Code()) + } +} + +// NewStopRunningJobOK creates a StopRunningJobOK with default headers values +func NewStopRunningJobOK() *StopRunningJobOK { + return &StopRunningJobOK{} +} + +/* +StopRunningJobOK describes a response with status code 200, with default header values. + +Stop worker successfully. +*/ +type StopRunningJobOK struct { +} + +// IsSuccess returns true when this stop running job o k response has a 2xx status code +func (o *StopRunningJobOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this stop running job o k response has a 3xx status code +func (o *StopRunningJobOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop running job o k response has a 4xx status code +func (o *StopRunningJobOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop running job o k response has a 5xx status code +func (o *StopRunningJobOK) IsServerError() bool { + return false +} + +// IsCode returns true when this stop running job o k response a status code equal to that given +func (o *StopRunningJobOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the stop running job o k response +func (o *StopRunningJobOK) Code() int { + return 200 +} + +func (o *StopRunningJobOK) Error() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobOK ", 200) +} + +func (o *StopRunningJobOK) String() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobOK ", 200) +} + +func (o *StopRunningJobOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewStopRunningJobUnauthorized creates a StopRunningJobUnauthorized with default headers values +func NewStopRunningJobUnauthorized() *StopRunningJobUnauthorized { + return &StopRunningJobUnauthorized{} +} + +/* +StopRunningJobUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type StopRunningJobUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop running job unauthorized response has a 2xx status code +func (o *StopRunningJobUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop running job unauthorized response has a 3xx status code +func (o *StopRunningJobUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop running job unauthorized response has a 4xx status code +func (o *StopRunningJobUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop running job unauthorized response has a 5xx status code +func (o *StopRunningJobUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this stop running job unauthorized response a status code equal to that given +func (o *StopRunningJobUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the stop running job unauthorized response +func (o *StopRunningJobUnauthorized) Code() int { + return 401 +} + +func (o *StopRunningJobUnauthorized) Error() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobUnauthorized %+v", 401, o.Payload) +} + +func (o *StopRunningJobUnauthorized) String() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobUnauthorized %+v", 401, o.Payload) +} + +func (o *StopRunningJobUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopRunningJobUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopRunningJobForbidden creates a StopRunningJobForbidden with default headers values +func NewStopRunningJobForbidden() *StopRunningJobForbidden { + return &StopRunningJobForbidden{} +} + +/* +StopRunningJobForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type StopRunningJobForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop running job forbidden response has a 2xx status code +func (o *StopRunningJobForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop running job forbidden response has a 3xx status code +func (o *StopRunningJobForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop running job forbidden response has a 4xx status code +func (o *StopRunningJobForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop running job forbidden response has a 5xx status code +func (o *StopRunningJobForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this stop running job forbidden response a status code equal to that given +func (o *StopRunningJobForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the stop running job forbidden response +func (o *StopRunningJobForbidden) Code() int { + return 403 +} + +func (o *StopRunningJobForbidden) Error() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobForbidden %+v", 403, o.Payload) +} + +func (o *StopRunningJobForbidden) String() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobForbidden %+v", 403, o.Payload) +} + +func (o *StopRunningJobForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopRunningJobForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopRunningJobNotFound creates a StopRunningJobNotFound with default headers values +func NewStopRunningJobNotFound() *StopRunningJobNotFound { + return &StopRunningJobNotFound{} +} + +/* +StopRunningJobNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type StopRunningJobNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop running job not found response has a 2xx status code +func (o *StopRunningJobNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop running job not found response has a 3xx status code +func (o *StopRunningJobNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop running job not found response has a 4xx status code +func (o *StopRunningJobNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop running job not found response has a 5xx status code +func (o *StopRunningJobNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this stop running job not found response a status code equal to that given +func (o *StopRunningJobNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the stop running job not found response +func (o *StopRunningJobNotFound) Code() int { + return 404 +} + +func (o *StopRunningJobNotFound) Error() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobNotFound %+v", 404, o.Payload) +} + +func (o *StopRunningJobNotFound) String() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobNotFound %+v", 404, o.Payload) +} + +func (o *StopRunningJobNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopRunningJobNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopRunningJobInternalServerError creates a StopRunningJobInternalServerError with default headers values +func NewStopRunningJobInternalServerError() *StopRunningJobInternalServerError { + return &StopRunningJobInternalServerError{} +} + +/* +StopRunningJobInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type StopRunningJobInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop running job internal server error response has a 2xx status code +func (o *StopRunningJobInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop running job internal server error response has a 3xx status code +func (o *StopRunningJobInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop running job internal server error response has a 4xx status code +func (o *StopRunningJobInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop running job internal server error response has a 5xx status code +func (o *StopRunningJobInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this stop running job internal server error response a status code equal to that given +func (o *StopRunningJobInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the stop running job internal server error response +func (o *StopRunningJobInternalServerError) Code() int { + return 500 +} + +func (o *StopRunningJobInternalServerError) Error() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobInternalServerError %+v", 500, o.Payload) +} + +func (o *StopRunningJobInternalServerError) String() string { + return fmt.Sprintf("[PUT /jobservice/jobs/{job_id}][%d] stopRunningJobInternalServerError %+v", 500, o.Payload) +} + +func (o *StopRunningJobInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopRunningJobInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/label/create_label_parameters.go b/pkg/harbor/client/label/create_label_parameters.go index 8ea126b..4b67883 100644 --- a/pkg/harbor/client/label/create_label_parameters.go +++ b/pkg/harbor/client/label/create_label_parameters.go @@ -63,6 +63,12 @@ CreateLabelParams contains all the parameters to send to the API endpoint */ type CreateLabelParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Label. The json object of label. @@ -122,6 +128,17 @@ func (o *CreateLabelParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the create label params +func (o *CreateLabelParams) WithXRequestID(xRequestID *string) *CreateLabelParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the create label params +func (o *CreateLabelParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithLabel adds the label to the create label params func (o *CreateLabelParams) WithLabel(label *models.Label) *CreateLabelParams { o.SetLabel(label) @@ -140,6 +157,14 @@ func (o *CreateLabelParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Label != nil { if err := r.SetBodyParam(o.Label); err != nil { return err diff --git a/pkg/harbor/client/label/list_labels_parameters.go b/pkg/harbor/client/label/list_labels_parameters.go index 405260a..70cc588 100644 --- a/pkg/harbor/client/label/list_labels_parameters.go +++ b/pkg/harbor/client/label/list_labels_parameters.go @@ -114,7 +114,7 @@ type ListLabelsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/ldap/import_ldap_user_parameters.go b/pkg/harbor/client/ldap/import_ldap_user_parameters.go index a817722..67cbdb8 100644 --- a/pkg/harbor/client/ldap/import_ldap_user_parameters.go +++ b/pkg/harbor/client/ldap/import_ldap_user_parameters.go @@ -63,6 +63,12 @@ ImportLdapUserParams contains all the parameters to send to the API endpoint */ type ImportLdapUserParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* UIDList. The uid listed for importing. This list will check users validity of ldap service based on configuration from the system. @@ -122,6 +128,17 @@ func (o *ImportLdapUserParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the import ldap user params +func (o *ImportLdapUserParams) WithXRequestID(xRequestID *string) *ImportLdapUserParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the import ldap user params +func (o *ImportLdapUserParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithUIDList adds the uIDList to the import ldap user params func (o *ImportLdapUserParams) WithUIDList(uIDList *models.LdapImportUsers) *ImportLdapUserParams { o.SetUIDList(uIDList) @@ -140,6 +157,14 @@ func (o *ImportLdapUserParams) WriteToRequest(r runtime.ClientRequest, reg strfm return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.UIDList != nil { if err := r.SetBodyParam(o.UIDList); err != nil { return err diff --git a/pkg/harbor/client/ldap/ping_ldap_parameters.go b/pkg/harbor/client/ldap/ping_ldap_parameters.go index 384b638..22f0a8d 100644 --- a/pkg/harbor/client/ldap/ping_ldap_parameters.go +++ b/pkg/harbor/client/ldap/ping_ldap_parameters.go @@ -63,6 +63,12 @@ PingLdapParams contains all the parameters to send to the API endpoint */ type PingLdapParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Ldapconf. ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system. @@ -122,6 +128,17 @@ func (o *PingLdapParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the ping ldap params +func (o *PingLdapParams) WithXRequestID(xRequestID *string) *PingLdapParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the ping ldap params +func (o *PingLdapParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithLdapconf adds the ldapconf to the ping ldap params func (o *PingLdapParams) WithLdapconf(ldapconf *models.LdapConf) *PingLdapParams { o.SetLdapconf(ldapconf) @@ -140,6 +157,14 @@ func (o *PingLdapParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regi return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Ldapconf != nil { if err := r.SetBodyParam(o.Ldapconf); err != nil { return err diff --git a/pkg/harbor/client/ldap/search_ldap_group_parameters.go b/pkg/harbor/client/ldap/search_ldap_group_parameters.go index 83ead2c..67546fb 100644 --- a/pkg/harbor/client/ldap/search_ldap_group_parameters.go +++ b/pkg/harbor/client/ldap/search_ldap_group_parameters.go @@ -61,6 +61,12 @@ SearchLdapGroupParams contains all the parameters to send to the API endpoint */ type SearchLdapGroupParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Groupdn. The LDAP group DN @@ -126,6 +132,17 @@ func (o *SearchLdapGroupParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the search ldap group params +func (o *SearchLdapGroupParams) WithXRequestID(xRequestID *string) *SearchLdapGroupParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the search ldap group params +func (o *SearchLdapGroupParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithGroupdn adds the groupdn to the search ldap group params func (o *SearchLdapGroupParams) WithGroupdn(groupdn *string) *SearchLdapGroupParams { o.SetGroupdn(groupdn) @@ -156,6 +173,14 @@ func (o *SearchLdapGroupParams) WriteToRequest(r runtime.ClientRequest, reg strf } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.Groupdn != nil { // query param groupdn diff --git a/pkg/harbor/client/ldap/search_ldap_user_parameters.go b/pkg/harbor/client/ldap/search_ldap_user_parameters.go index 508f27b..06d0673 100644 --- a/pkg/harbor/client/ldap/search_ldap_user_parameters.go +++ b/pkg/harbor/client/ldap/search_ldap_user_parameters.go @@ -61,6 +61,12 @@ SearchLdapUserParams contains all the parameters to send to the API endpoint */ type SearchLdapUserParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Username. Registered user ID @@ -120,6 +126,17 @@ func (o *SearchLdapUserParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the search ldap user params +func (o *SearchLdapUserParams) WithXRequestID(xRequestID *string) *SearchLdapUserParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the search ldap user params +func (o *SearchLdapUserParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithUsername adds the username to the search ldap user params func (o *SearchLdapUserParams) WithUsername(username *string) *SearchLdapUserParams { o.SetUsername(username) @@ -139,6 +156,14 @@ func (o *SearchLdapUserParams) WriteToRequest(r runtime.ClientRequest, reg strfm } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.Username != nil { // query param username diff --git a/pkg/harbor/client/oidc/ping_oidc_parameters.go b/pkg/harbor/client/oidc/ping_oidc_parameters.go index add1210..fc77cd0 100644 --- a/pkg/harbor/client/oidc/ping_oidc_parameters.go +++ b/pkg/harbor/client/oidc/ping_oidc_parameters.go @@ -61,6 +61,12 @@ PingOIDCParams contains all the parameters to send to the API endpoint */ type PingOIDCParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Endpoint. Request body for OIDC endpoint to be tested. @@ -120,6 +126,17 @@ func (o *PingOIDCParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the ping OIDC params +func (o *PingOIDCParams) WithXRequestID(xRequestID *string) *PingOIDCParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the ping OIDC params +func (o *PingOIDCParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithEndpoint adds the endpoint to the ping OIDC params func (o *PingOIDCParams) WithEndpoint(endpoint PingOIDCBody) *PingOIDCParams { o.SetEndpoint(endpoint) @@ -138,6 +155,14 @@ func (o *PingOIDCParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regi return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if err := r.SetBodyParam(o.Endpoint); err != nil { return err } diff --git a/pkg/harbor/client/permissions/get_permissions_parameters.go b/pkg/harbor/client/permissions/get_permissions_parameters.go new file mode 100644 index 0000000..9436502 --- /dev/null +++ b/pkg/harbor/client/permissions/get_permissions_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetPermissionsParams creates a new GetPermissionsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPermissionsParams() *GetPermissionsParams { + return &GetPermissionsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPermissionsParamsWithTimeout creates a new GetPermissionsParams object +// with the ability to set a timeout on a request. +func NewGetPermissionsParamsWithTimeout(timeout time.Duration) *GetPermissionsParams { + return &GetPermissionsParams{ + timeout: timeout, + } +} + +// NewGetPermissionsParamsWithContext creates a new GetPermissionsParams object +// with the ability to set a context for a request. +func NewGetPermissionsParamsWithContext(ctx context.Context) *GetPermissionsParams { + return &GetPermissionsParams{ + Context: ctx, + } +} + +// NewGetPermissionsParamsWithHTTPClient creates a new GetPermissionsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPermissionsParamsWithHTTPClient(client *http.Client) *GetPermissionsParams { + return &GetPermissionsParams{ + HTTPClient: client, + } +} + +/* +GetPermissionsParams contains all the parameters to send to the API endpoint + + for the get permissions operation. + + Typically these are written to a http.Request. +*/ +type GetPermissionsParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get permissions params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPermissionsParams) WithDefaults() *GetPermissionsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get permissions params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPermissionsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get permissions params +func (o *GetPermissionsParams) WithTimeout(timeout time.Duration) *GetPermissionsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get permissions params +func (o *GetPermissionsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get permissions params +func (o *GetPermissionsParams) WithContext(ctx context.Context) *GetPermissionsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get permissions params +func (o *GetPermissionsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get permissions params +func (o *GetPermissionsParams) WithHTTPClient(client *http.Client) *GetPermissionsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get permissions params +func (o *GetPermissionsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get permissions params +func (o *GetPermissionsParams) WithXRequestID(xRequestID *string) *GetPermissionsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get permissions params +func (o *GetPermissionsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPermissionsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/permissions/get_permissions_responses.go b/pkg/harbor/client/permissions/get_permissions_responses.go new file mode 100644 index 0000000..bdb5ee5 --- /dev/null +++ b/pkg/harbor/client/permissions/get_permissions_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetPermissionsReader is a Reader for the GetPermissions structure. +type GetPermissionsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPermissionsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPermissionsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetPermissionsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetPermissionsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetPermissionsNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetPermissionsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /permissions] getPermissions", response, response.Code()) + } +} + +// NewGetPermissionsOK creates a GetPermissionsOK with default headers values +func NewGetPermissionsOK() *GetPermissionsOK { + return &GetPermissionsOK{} +} + +/* +GetPermissionsOK describes a response with status code 200, with default header values. + +Get permissions successfully. +*/ +type GetPermissionsOK struct { + Payload *models.Permissions +} + +// IsSuccess returns true when this get permissions o k response has a 2xx status code +func (o *GetPermissionsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get permissions o k response has a 3xx status code +func (o *GetPermissionsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get permissions o k response has a 4xx status code +func (o *GetPermissionsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get permissions o k response has a 5xx status code +func (o *GetPermissionsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get permissions o k response a status code equal to that given +func (o *GetPermissionsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get permissions o k response +func (o *GetPermissionsOK) Code() int { + return 200 +} + +func (o *GetPermissionsOK) Error() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsOK %+v", 200, o.Payload) +} + +func (o *GetPermissionsOK) String() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsOK %+v", 200, o.Payload) +} + +func (o *GetPermissionsOK) GetPayload() *models.Permissions { + return o.Payload +} + +func (o *GetPermissionsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Permissions) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPermissionsUnauthorized creates a GetPermissionsUnauthorized with default headers values +func NewGetPermissionsUnauthorized() *GetPermissionsUnauthorized { + return &GetPermissionsUnauthorized{} +} + +/* +GetPermissionsUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetPermissionsUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get permissions unauthorized response has a 2xx status code +func (o *GetPermissionsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get permissions unauthorized response has a 3xx status code +func (o *GetPermissionsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get permissions unauthorized response has a 4xx status code +func (o *GetPermissionsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get permissions unauthorized response has a 5xx status code +func (o *GetPermissionsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get permissions unauthorized response a status code equal to that given +func (o *GetPermissionsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get permissions unauthorized response +func (o *GetPermissionsUnauthorized) Code() int { + return 401 +} + +func (o *GetPermissionsUnauthorized) Error() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPermissionsUnauthorized) String() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPermissionsUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPermissionsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPermissionsForbidden creates a GetPermissionsForbidden with default headers values +func NewGetPermissionsForbidden() *GetPermissionsForbidden { + return &GetPermissionsForbidden{} +} + +/* +GetPermissionsForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetPermissionsForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get permissions forbidden response has a 2xx status code +func (o *GetPermissionsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get permissions forbidden response has a 3xx status code +func (o *GetPermissionsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get permissions forbidden response has a 4xx status code +func (o *GetPermissionsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get permissions forbidden response has a 5xx status code +func (o *GetPermissionsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get permissions forbidden response a status code equal to that given +func (o *GetPermissionsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get permissions forbidden response +func (o *GetPermissionsForbidden) Code() int { + return 403 +} + +func (o *GetPermissionsForbidden) Error() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsForbidden %+v", 403, o.Payload) +} + +func (o *GetPermissionsForbidden) String() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsForbidden %+v", 403, o.Payload) +} + +func (o *GetPermissionsForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPermissionsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPermissionsNotFound creates a GetPermissionsNotFound with default headers values +func NewGetPermissionsNotFound() *GetPermissionsNotFound { + return &GetPermissionsNotFound{} +} + +/* +GetPermissionsNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetPermissionsNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get permissions not found response has a 2xx status code +func (o *GetPermissionsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get permissions not found response has a 3xx status code +func (o *GetPermissionsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get permissions not found response has a 4xx status code +func (o *GetPermissionsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get permissions not found response has a 5xx status code +func (o *GetPermissionsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get permissions not found response a status code equal to that given +func (o *GetPermissionsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get permissions not found response +func (o *GetPermissionsNotFound) Code() int { + return 404 +} + +func (o *GetPermissionsNotFound) Error() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsNotFound %+v", 404, o.Payload) +} + +func (o *GetPermissionsNotFound) String() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsNotFound %+v", 404, o.Payload) +} + +func (o *GetPermissionsNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPermissionsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPermissionsInternalServerError creates a GetPermissionsInternalServerError with default headers values +func NewGetPermissionsInternalServerError() *GetPermissionsInternalServerError { + return &GetPermissionsInternalServerError{} +} + +/* +GetPermissionsInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetPermissionsInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get permissions internal server error response has a 2xx status code +func (o *GetPermissionsInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get permissions internal server error response has a 3xx status code +func (o *GetPermissionsInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get permissions internal server error response has a 4xx status code +func (o *GetPermissionsInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get permissions internal server error response has a 5xx status code +func (o *GetPermissionsInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get permissions internal server error response a status code equal to that given +func (o *GetPermissionsInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get permissions internal server error response +func (o *GetPermissionsInternalServerError) Code() int { + return 500 +} + +func (o *GetPermissionsInternalServerError) Error() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPermissionsInternalServerError) String() string { + return fmt.Sprintf("[GET /permissions][%d] getPermissionsInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPermissionsInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPermissionsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/permissions/permissions_client.go b/pkg/harbor/client/permissions/permissions_client.go new file mode 100644 index 0000000..87acf03 --- /dev/null +++ b/pkg/harbor/client/permissions/permissions_client.go @@ -0,0 +1,85 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the permissions client +type API interface { + /* + GetPermissions gets system or project level permissions info + + This endpoint is for retrieving resource and action info that only provides for admin user(system admin and project admin). + */ + GetPermissions(ctx context.Context, params *GetPermissionsParams) (*GetPermissionsOK, error) +} + +// New creates a new permissions API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for permissions API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +GetPermissions gets system or project level permissions info + +This endpoint is for retrieving resource and action info that only provides for admin user(system admin and project admin). +*/ +func (a *Client) GetPermissions(ctx context.Context, params *GetPermissionsParams) (*GetPermissionsOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getPermissions", + Method: "GET", + PathPattern: "/permissions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetPermissionsReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetPermissionsOK: + return value, nil + case *GetPermissionsUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPermissionsForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPermissionsNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPermissionsInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getPermissions: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/ping/ping_client.go b/pkg/harbor/client/ping/ping_client.go index 1d3803b..3cb7c0a 100644 --- a/pkg/harbor/client/ping/ping_client.go +++ b/pkg/harbor/client/ping/ping_client.go @@ -19,9 +19,9 @@ import ( // API is the interface of the ping client type API interface { /* - GetPing pings harbor to check if it s alive + GetPing pings harbor to check if the API server is alive - This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components.*/ + This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. This path does not require any authentication.*/ GetPing(ctx context.Context, params *GetPingParams) (*GetPingOK, error) } @@ -44,9 +44,9 @@ type Client struct { } /* -GetPing pings harbor to check if it s alive +GetPing pings harbor to check if the API server is alive -This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. +This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. This path does not require any authentication. */ func (a *Client) GetPing(ctx context.Context, params *GetPingParams) (*GetPingOK, error) { diff --git a/pkg/harbor/client/preheat/list_executions_parameters.go b/pkg/harbor/client/preheat/list_executions_parameters.go index c149640..b4932ce 100644 --- a/pkg/harbor/client/preheat/list_executions_parameters.go +++ b/pkg/harbor/client/preheat/list_executions_parameters.go @@ -106,7 +106,7 @@ type ListExecutionsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/preheat/list_instances_parameters.go b/pkg/harbor/client/preheat/list_instances_parameters.go index 8f87898..520ba5e 100644 --- a/pkg/harbor/client/preheat/list_instances_parameters.go +++ b/pkg/harbor/client/preheat/list_instances_parameters.go @@ -94,7 +94,7 @@ type ListInstancesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/preheat/list_policies_parameters.go b/pkg/harbor/client/preheat/list_policies_parameters.go index c271af5..51fcecc 100644 --- a/pkg/harbor/client/preheat/list_policies_parameters.go +++ b/pkg/harbor/client/preheat/list_policies_parameters.go @@ -100,7 +100,7 @@ type ListPoliciesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/preheat/list_tasks_parameters.go b/pkg/harbor/client/preheat/list_tasks_parameters.go index c5b7a86..93c8b2a 100644 --- a/pkg/harbor/client/preheat/list_tasks_parameters.go +++ b/pkg/harbor/client/preheat/list_tasks_parameters.go @@ -112,7 +112,7 @@ type ListTasksParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/project/get_logs_parameters.go b/pkg/harbor/client/project/get_logs_parameters.go index 07b05db..642d587 100644 --- a/pkg/harbor/client/project/get_logs_parameters.go +++ b/pkg/harbor/client/project/get_logs_parameters.go @@ -100,7 +100,7 @@ type GetLogsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/project/list_projects_parameters.go b/pkg/harbor/client/project/list_projects_parameters.go index 78ea831..2c2f83d 100644 --- a/pkg/harbor/client/project/list_projects_parameters.go +++ b/pkg/harbor/client/project/list_projects_parameters.go @@ -101,8 +101,6 @@ type ListProjectsParams struct { /* Public. The project is public or private. - - Format: int32 */ Public *bool `js:"public"` @@ -114,7 +112,7 @@ type ListProjectsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/project/list_scanner_candidates_of_project_parameters.go b/pkg/harbor/client/project/list_scanner_candidates_of_project_parameters.go index 2681a01..cab7a4a 100644 --- a/pkg/harbor/client/project/list_scanner_candidates_of_project_parameters.go +++ b/pkg/harbor/client/project/list_scanner_candidates_of_project_parameters.go @@ -106,7 +106,7 @@ type ListScannerCandidatesOfProjectParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/purge/create_purge_schedule_parameters.go b/pkg/harbor/client/purge/create_purge_schedule_parameters.go new file mode 100644 index 0000000..683283b --- /dev/null +++ b/pkg/harbor/client/purge/create_purge_schedule_parameters.go @@ -0,0 +1,182 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// NewCreatePurgeScheduleParams creates a new CreatePurgeScheduleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewCreatePurgeScheduleParams() *CreatePurgeScheduleParams { + return &CreatePurgeScheduleParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCreatePurgeScheduleParamsWithTimeout creates a new CreatePurgeScheduleParams object +// with the ability to set a timeout on a request. +func NewCreatePurgeScheduleParamsWithTimeout(timeout time.Duration) *CreatePurgeScheduleParams { + return &CreatePurgeScheduleParams{ + timeout: timeout, + } +} + +// NewCreatePurgeScheduleParamsWithContext creates a new CreatePurgeScheduleParams object +// with the ability to set a context for a request. +func NewCreatePurgeScheduleParamsWithContext(ctx context.Context) *CreatePurgeScheduleParams { + return &CreatePurgeScheduleParams{ + Context: ctx, + } +} + +// NewCreatePurgeScheduleParamsWithHTTPClient creates a new CreatePurgeScheduleParams object +// with the ability to set a custom HTTPClient for a request. +func NewCreatePurgeScheduleParamsWithHTTPClient(client *http.Client) *CreatePurgeScheduleParams { + return &CreatePurgeScheduleParams{ + HTTPClient: client, + } +} + +/* +CreatePurgeScheduleParams contains all the parameters to send to the API endpoint + + for the create purge schedule operation. + + Typically these are written to a http.Request. +*/ +type CreatePurgeScheduleParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Schedule. + + The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + + */ + Schedule *models.Schedule `js:"schedule"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the create purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreatePurgeScheduleParams) WithDefaults() *CreatePurgeScheduleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreatePurgeScheduleParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the create purge schedule params +func (o *CreatePurgeScheduleParams) WithTimeout(timeout time.Duration) *CreatePurgeScheduleParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create purge schedule params +func (o *CreatePurgeScheduleParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create purge schedule params +func (o *CreatePurgeScheduleParams) WithContext(ctx context.Context) *CreatePurgeScheduleParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create purge schedule params +func (o *CreatePurgeScheduleParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create purge schedule params +func (o *CreatePurgeScheduleParams) WithHTTPClient(client *http.Client) *CreatePurgeScheduleParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create purge schedule params +func (o *CreatePurgeScheduleParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the create purge schedule params +func (o *CreatePurgeScheduleParams) WithXRequestID(xRequestID *string) *CreatePurgeScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the create purge schedule params +func (o *CreatePurgeScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithSchedule adds the schedule to the create purge schedule params +func (o *CreatePurgeScheduleParams) WithSchedule(schedule *models.Schedule) *CreatePurgeScheduleParams { + o.SetSchedule(schedule) + return o +} + +// SetSchedule adds the schedule to the create purge schedule params +func (o *CreatePurgeScheduleParams) SetSchedule(schedule *models.Schedule) { + o.Schedule = schedule +} + +// WriteToRequest writes these params to a swagger request +func (o *CreatePurgeScheduleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.Schedule != nil { + if err := r.SetBodyParam(o.Schedule); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/create_purge_schedule_responses.go b/pkg/harbor/client/purge/create_purge_schedule_responses.go new file mode 100644 index 0000000..86a16ef --- /dev/null +++ b/pkg/harbor/client/purge/create_purge_schedule_responses.go @@ -0,0 +1,457 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// CreatePurgeScheduleReader is a Reader for the CreatePurgeSchedule structure. +type CreatePurgeScheduleReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreatePurgeScheduleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewCreatePurgeScheduleCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewCreatePurgeScheduleBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewCreatePurgeScheduleUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewCreatePurgeScheduleForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewCreatePurgeScheduleInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /system/purgeaudit/schedule] createPurgeSchedule", response, response.Code()) + } +} + +// NewCreatePurgeScheduleCreated creates a CreatePurgeScheduleCreated with default headers values +func NewCreatePurgeScheduleCreated() *CreatePurgeScheduleCreated { + return &CreatePurgeScheduleCreated{} +} + +/* +CreatePurgeScheduleCreated describes a response with status code 201, with default header values. + +Created +*/ +type CreatePurgeScheduleCreated struct { + + /* The location of the resource + */ + Location string + + /* The ID of the corresponding request for the response + */ + XRequestID string +} + +// IsSuccess returns true when this create purge schedule created response has a 2xx status code +func (o *CreatePurgeScheduleCreated) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create purge schedule created response has a 3xx status code +func (o *CreatePurgeScheduleCreated) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create purge schedule created response has a 4xx status code +func (o *CreatePurgeScheduleCreated) IsClientError() bool { + return false +} + +// IsServerError returns true when this create purge schedule created response has a 5xx status code +func (o *CreatePurgeScheduleCreated) IsServerError() bool { + return false +} + +// IsCode returns true when this create purge schedule created response a status code equal to that given +func (o *CreatePurgeScheduleCreated) IsCode(code int) bool { + return code == 201 +} + +// Code gets the status code for the create purge schedule created response +func (o *CreatePurgeScheduleCreated) Code() int { + return 201 +} + +func (o *CreatePurgeScheduleCreated) Error() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleCreated ", 201) +} + +func (o *CreatePurgeScheduleCreated) String() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleCreated ", 201) +} + +func (o *CreatePurgeScheduleCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Location + hdrLocation := response.GetHeader("Location") + + if hdrLocation != "" { + o.Location = hdrLocation + } + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + return nil +} + +// NewCreatePurgeScheduleBadRequest creates a CreatePurgeScheduleBadRequest with default headers values +func NewCreatePurgeScheduleBadRequest() *CreatePurgeScheduleBadRequest { + return &CreatePurgeScheduleBadRequest{} +} + +/* +CreatePurgeScheduleBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type CreatePurgeScheduleBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this create purge schedule bad request response has a 2xx status code +func (o *CreatePurgeScheduleBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create purge schedule bad request response has a 3xx status code +func (o *CreatePurgeScheduleBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create purge schedule bad request response has a 4xx status code +func (o *CreatePurgeScheduleBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this create purge schedule bad request response has a 5xx status code +func (o *CreatePurgeScheduleBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this create purge schedule bad request response a status code equal to that given +func (o *CreatePurgeScheduleBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the create purge schedule bad request response +func (o *CreatePurgeScheduleBadRequest) Code() int { + return 400 +} + +func (o *CreatePurgeScheduleBadRequest) Error() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleBadRequest %+v", 400, o.Payload) +} + +func (o *CreatePurgeScheduleBadRequest) String() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleBadRequest %+v", 400, o.Payload) +} + +func (o *CreatePurgeScheduleBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *CreatePurgeScheduleBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePurgeScheduleUnauthorized creates a CreatePurgeScheduleUnauthorized with default headers values +func NewCreatePurgeScheduleUnauthorized() *CreatePurgeScheduleUnauthorized { + return &CreatePurgeScheduleUnauthorized{} +} + +/* +CreatePurgeScheduleUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type CreatePurgeScheduleUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this create purge schedule unauthorized response has a 2xx status code +func (o *CreatePurgeScheduleUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create purge schedule unauthorized response has a 3xx status code +func (o *CreatePurgeScheduleUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create purge schedule unauthorized response has a 4xx status code +func (o *CreatePurgeScheduleUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this create purge schedule unauthorized response has a 5xx status code +func (o *CreatePurgeScheduleUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this create purge schedule unauthorized response a status code equal to that given +func (o *CreatePurgeScheduleUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the create purge schedule unauthorized response +func (o *CreatePurgeScheduleUnauthorized) Code() int { + return 401 +} + +func (o *CreatePurgeScheduleUnauthorized) Error() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *CreatePurgeScheduleUnauthorized) String() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *CreatePurgeScheduleUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *CreatePurgeScheduleUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePurgeScheduleForbidden creates a CreatePurgeScheduleForbidden with default headers values +func NewCreatePurgeScheduleForbidden() *CreatePurgeScheduleForbidden { + return &CreatePurgeScheduleForbidden{} +} + +/* +CreatePurgeScheduleForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type CreatePurgeScheduleForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this create purge schedule forbidden response has a 2xx status code +func (o *CreatePurgeScheduleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create purge schedule forbidden response has a 3xx status code +func (o *CreatePurgeScheduleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create purge schedule forbidden response has a 4xx status code +func (o *CreatePurgeScheduleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create purge schedule forbidden response has a 5xx status code +func (o *CreatePurgeScheduleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create purge schedule forbidden response a status code equal to that given +func (o *CreatePurgeScheduleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the create purge schedule forbidden response +func (o *CreatePurgeScheduleForbidden) Code() int { + return 403 +} + +func (o *CreatePurgeScheduleForbidden) Error() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *CreatePurgeScheduleForbidden) String() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *CreatePurgeScheduleForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *CreatePurgeScheduleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePurgeScheduleInternalServerError creates a CreatePurgeScheduleInternalServerError with default headers values +func NewCreatePurgeScheduleInternalServerError() *CreatePurgeScheduleInternalServerError { + return &CreatePurgeScheduleInternalServerError{} +} + +/* +CreatePurgeScheduleInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type CreatePurgeScheduleInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this create purge schedule internal server error response has a 2xx status code +func (o *CreatePurgeScheduleInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create purge schedule internal server error response has a 3xx status code +func (o *CreatePurgeScheduleInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create purge schedule internal server error response has a 4xx status code +func (o *CreatePurgeScheduleInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this create purge schedule internal server error response has a 5xx status code +func (o *CreatePurgeScheduleInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this create purge schedule internal server error response a status code equal to that given +func (o *CreatePurgeScheduleInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the create purge schedule internal server error response +func (o *CreatePurgeScheduleInternalServerError) Code() int { + return 500 +} + +func (o *CreatePurgeScheduleInternalServerError) Error() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *CreatePurgeScheduleInternalServerError) String() string { + return fmt.Sprintf("[POST /system/purgeaudit/schedule][%d] createPurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *CreatePurgeScheduleInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *CreatePurgeScheduleInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_history_parameters.go b/pkg/harbor/client/purge/get_purge_history_parameters.go new file mode 100644 index 0000000..b31691a --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_history_parameters.go @@ -0,0 +1,311 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetPurgeHistoryParams creates a new GetPurgeHistoryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPurgeHistoryParams() *GetPurgeHistoryParams { + return &GetPurgeHistoryParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPurgeHistoryParamsWithTimeout creates a new GetPurgeHistoryParams object +// with the ability to set a timeout on a request. +func NewGetPurgeHistoryParamsWithTimeout(timeout time.Duration) *GetPurgeHistoryParams { + return &GetPurgeHistoryParams{ + timeout: timeout, + } +} + +// NewGetPurgeHistoryParamsWithContext creates a new GetPurgeHistoryParams object +// with the ability to set a context for a request. +func NewGetPurgeHistoryParamsWithContext(ctx context.Context) *GetPurgeHistoryParams { + return &GetPurgeHistoryParams{ + Context: ctx, + } +} + +// NewGetPurgeHistoryParamsWithHTTPClient creates a new GetPurgeHistoryParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPurgeHistoryParamsWithHTTPClient(client *http.Client) *GetPurgeHistoryParams { + return &GetPurgeHistoryParams{ + HTTPClient: client, + } +} + +/* +GetPurgeHistoryParams contains all the parameters to send to the API endpoint + + for the get purge history operation. + + Typically these are written to a http.Request. +*/ +type GetPurgeHistoryParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + /* Q. + + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + */ + Q *string `js:"q"` + + /* Sort. + + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" + */ + Sort *string `js:"sort"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get purge history params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeHistoryParams) WithDefaults() *GetPurgeHistoryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get purge history params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeHistoryParams) SetDefaults() { + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := GetPurgeHistoryParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the get purge history params +func (o *GetPurgeHistoryParams) WithTimeout(timeout time.Duration) *GetPurgeHistoryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get purge history params +func (o *GetPurgeHistoryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get purge history params +func (o *GetPurgeHistoryParams) WithContext(ctx context.Context) *GetPurgeHistoryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get purge history params +func (o *GetPurgeHistoryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get purge history params +func (o *GetPurgeHistoryParams) WithHTTPClient(client *http.Client) *GetPurgeHistoryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get purge history params +func (o *GetPurgeHistoryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get purge history params +func (o *GetPurgeHistoryParams) WithXRequestID(xRequestID *string) *GetPurgeHistoryParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get purge history params +func (o *GetPurgeHistoryParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the get purge history params +func (o *GetPurgeHistoryParams) WithPage(page *int64) *GetPurgeHistoryParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the get purge history params +func (o *GetPurgeHistoryParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the get purge history params +func (o *GetPurgeHistoryParams) WithPageSize(pageSize *int64) *GetPurgeHistoryParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the get purge history params +func (o *GetPurgeHistoryParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithQ adds the q to the get purge history params +func (o *GetPurgeHistoryParams) WithQ(q *string) *GetPurgeHistoryParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the get purge history params +func (o *GetPurgeHistoryParams) SetQ(q *string) { + o.Q = q +} + +// WithSort adds the sort to the get purge history params +func (o *GetPurgeHistoryParams) WithSort(sort *string) *GetPurgeHistoryParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the get purge history params +func (o *GetPurgeHistoryParams) SetSort(sort *string) { + o.Sort = sort +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPurgeHistoryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + if o.Q != nil { + + // query param q + var qrQ string + + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + } + + if o.Sort != nil { + + // query param sort + var qrSort string + + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_history_responses.go b/pkg/harbor/client/purge/get_purge_history_responses.go new file mode 100644 index 0000000..1a41a66 --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_history_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetPurgeHistoryReader is a Reader for the GetPurgeHistory structure. +type GetPurgeHistoryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPurgeHistoryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPurgeHistoryOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetPurgeHistoryUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetPurgeHistoryForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetPurgeHistoryInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /system/purgeaudit] getPurgeHistory", response, response.Code()) + } +} + +// NewGetPurgeHistoryOK creates a GetPurgeHistoryOK with default headers values +func NewGetPurgeHistoryOK() *GetPurgeHistoryOK { + return &GetPurgeHistoryOK{} +} + +/* +GetPurgeHistoryOK describes a response with status code 200, with default header values. + +Get purge job results successfully. +*/ +type GetPurgeHistoryOK struct { + + /* Link refers to the previous page and next page + */ + Link string + + /* The total count of history + */ + XTotalCount int64 + + Payload []*models.ExecHistory +} + +// IsSuccess returns true when this get purge history o k response has a 2xx status code +func (o *GetPurgeHistoryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get purge history o k response has a 3xx status code +func (o *GetPurgeHistoryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge history o k response has a 4xx status code +func (o *GetPurgeHistoryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge history o k response has a 5xx status code +func (o *GetPurgeHistoryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge history o k response a status code equal to that given +func (o *GetPurgeHistoryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get purge history o k response +func (o *GetPurgeHistoryOK) Code() int { + return 200 +} + +func (o *GetPurgeHistoryOK) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryOK %+v", 200, o.Payload) +} + +func (o *GetPurgeHistoryOK) String() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryOK %+v", 200, o.Payload) +} + +func (o *GetPurgeHistoryOK) GetPayload() []*models.ExecHistory { + return o.Payload +} + +func (o *GetPurgeHistoryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeHistoryUnauthorized creates a GetPurgeHistoryUnauthorized with default headers values +func NewGetPurgeHistoryUnauthorized() *GetPurgeHistoryUnauthorized { + return &GetPurgeHistoryUnauthorized{} +} + +/* +GetPurgeHistoryUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetPurgeHistoryUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge history unauthorized response has a 2xx status code +func (o *GetPurgeHistoryUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge history unauthorized response has a 3xx status code +func (o *GetPurgeHistoryUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge history unauthorized response has a 4xx status code +func (o *GetPurgeHistoryUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge history unauthorized response has a 5xx status code +func (o *GetPurgeHistoryUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge history unauthorized response a status code equal to that given +func (o *GetPurgeHistoryUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get purge history unauthorized response +func (o *GetPurgeHistoryUnauthorized) Code() int { + return 401 +} + +func (o *GetPurgeHistoryUnauthorized) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeHistoryUnauthorized) String() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeHistoryUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeHistoryUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeHistoryForbidden creates a GetPurgeHistoryForbidden with default headers values +func NewGetPurgeHistoryForbidden() *GetPurgeHistoryForbidden { + return &GetPurgeHistoryForbidden{} +} + +/* +GetPurgeHistoryForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetPurgeHistoryForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge history forbidden response has a 2xx status code +func (o *GetPurgeHistoryForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge history forbidden response has a 3xx status code +func (o *GetPurgeHistoryForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge history forbidden response has a 4xx status code +func (o *GetPurgeHistoryForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge history forbidden response has a 5xx status code +func (o *GetPurgeHistoryForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge history forbidden response a status code equal to that given +func (o *GetPurgeHistoryForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get purge history forbidden response +func (o *GetPurgeHistoryForbidden) Code() int { + return 403 +} + +func (o *GetPurgeHistoryForbidden) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeHistoryForbidden) String() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeHistoryForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeHistoryForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeHistoryInternalServerError creates a GetPurgeHistoryInternalServerError with default headers values +func NewGetPurgeHistoryInternalServerError() *GetPurgeHistoryInternalServerError { + return &GetPurgeHistoryInternalServerError{} +} + +/* +GetPurgeHistoryInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetPurgeHistoryInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge history internal server error response has a 2xx status code +func (o *GetPurgeHistoryInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge history internal server error response has a 3xx status code +func (o *GetPurgeHistoryInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge history internal server error response has a 4xx status code +func (o *GetPurgeHistoryInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge history internal server error response has a 5xx status code +func (o *GetPurgeHistoryInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get purge history internal server error response a status code equal to that given +func (o *GetPurgeHistoryInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get purge history internal server error response +func (o *GetPurgeHistoryInternalServerError) Code() int { + return 500 +} + +func (o *GetPurgeHistoryInternalServerError) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeHistoryInternalServerError) String() string { + return fmt.Sprintf("[GET /system/purgeaudit][%d] getPurgeHistoryInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeHistoryInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeHistoryInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_job_log_parameters.go b/pkg/harbor/client/purge/get_purge_job_log_parameters.go new file mode 100644 index 0000000..0854849 --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_job_log_parameters.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetPurgeJobLogParams creates a new GetPurgeJobLogParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPurgeJobLogParams() *GetPurgeJobLogParams { + return &GetPurgeJobLogParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPurgeJobLogParamsWithTimeout creates a new GetPurgeJobLogParams object +// with the ability to set a timeout on a request. +func NewGetPurgeJobLogParamsWithTimeout(timeout time.Duration) *GetPurgeJobLogParams { + return &GetPurgeJobLogParams{ + timeout: timeout, + } +} + +// NewGetPurgeJobLogParamsWithContext creates a new GetPurgeJobLogParams object +// with the ability to set a context for a request. +func NewGetPurgeJobLogParamsWithContext(ctx context.Context) *GetPurgeJobLogParams { + return &GetPurgeJobLogParams{ + Context: ctx, + } +} + +// NewGetPurgeJobLogParamsWithHTTPClient creates a new GetPurgeJobLogParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPurgeJobLogParamsWithHTTPClient(client *http.Client) *GetPurgeJobLogParams { + return &GetPurgeJobLogParams{ + HTTPClient: client, + } +} + +/* +GetPurgeJobLogParams contains all the parameters to send to the API endpoint + + for the get purge job log operation. + + Typically these are written to a http.Request. +*/ +type GetPurgeJobLogParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* PurgeID. + + The ID of the purge log + + Format: int64 + */ + PurgeID int64 `js:"purgeID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get purge job log params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeJobLogParams) WithDefaults() *GetPurgeJobLogParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get purge job log params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeJobLogParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get purge job log params +func (o *GetPurgeJobLogParams) WithTimeout(timeout time.Duration) *GetPurgeJobLogParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get purge job log params +func (o *GetPurgeJobLogParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get purge job log params +func (o *GetPurgeJobLogParams) WithContext(ctx context.Context) *GetPurgeJobLogParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get purge job log params +func (o *GetPurgeJobLogParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get purge job log params +func (o *GetPurgeJobLogParams) WithHTTPClient(client *http.Client) *GetPurgeJobLogParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get purge job log params +func (o *GetPurgeJobLogParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get purge job log params +func (o *GetPurgeJobLogParams) WithXRequestID(xRequestID *string) *GetPurgeJobLogParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get purge job log params +func (o *GetPurgeJobLogParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPurgeID adds the purgeID to the get purge job log params +func (o *GetPurgeJobLogParams) WithPurgeID(purgeID int64) *GetPurgeJobLogParams { + o.SetPurgeID(purgeID) + return o +} + +// SetPurgeID adds the purgeId to the get purge job log params +func (o *GetPurgeJobLogParams) SetPurgeID(purgeID int64) { + o.PurgeID = purgeID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPurgeJobLogParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param purge_id + if err := r.SetPathParam("purge_id", swag.FormatInt64(o.PurgeID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_job_log_responses.go b/pkg/harbor/client/purge/get_purge_job_log_responses.go new file mode 100644 index 0000000..8ca4126 --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_job_log_responses.go @@ -0,0 +1,531 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetPurgeJobLogReader is a Reader for the GetPurgeJobLog structure. +type GetPurgeJobLogReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPurgeJobLogReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPurgeJobLogOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewGetPurgeJobLogBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewGetPurgeJobLogUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetPurgeJobLogForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetPurgeJobLogNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetPurgeJobLogInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /system/purgeaudit/{purge_id}/log] getPurgeJobLog", response, response.Code()) + } +} + +// NewGetPurgeJobLogOK creates a GetPurgeJobLogOK with default headers values +func NewGetPurgeJobLogOK() *GetPurgeJobLogOK { + return &GetPurgeJobLogOK{} +} + +/* +GetPurgeJobLogOK describes a response with status code 200, with default header values. + +Get successfully. +*/ +type GetPurgeJobLogOK struct { + Payload string +} + +// IsSuccess returns true when this get purge job log o k response has a 2xx status code +func (o *GetPurgeJobLogOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get purge job log o k response has a 3xx status code +func (o *GetPurgeJobLogOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log o k response has a 4xx status code +func (o *GetPurgeJobLogOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge job log o k response has a 5xx status code +func (o *GetPurgeJobLogOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job log o k response a status code equal to that given +func (o *GetPurgeJobLogOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get purge job log o k response +func (o *GetPurgeJobLogOK) Code() int { + return 200 +} + +func (o *GetPurgeJobLogOK) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogOK %+v", 200, o.Payload) +} + +func (o *GetPurgeJobLogOK) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogOK %+v", 200, o.Payload) +} + +func (o *GetPurgeJobLogOK) GetPayload() string { + return o.Payload +} + +func (o *GetPurgeJobLogOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobLogBadRequest creates a GetPurgeJobLogBadRequest with default headers values +func NewGetPurgeJobLogBadRequest() *GetPurgeJobLogBadRequest { + return &GetPurgeJobLogBadRequest{} +} + +/* +GetPurgeJobLogBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type GetPurgeJobLogBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job log bad request response has a 2xx status code +func (o *GetPurgeJobLogBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job log bad request response has a 3xx status code +func (o *GetPurgeJobLogBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log bad request response has a 4xx status code +func (o *GetPurgeJobLogBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job log bad request response has a 5xx status code +func (o *GetPurgeJobLogBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job log bad request response a status code equal to that given +func (o *GetPurgeJobLogBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the get purge job log bad request response +func (o *GetPurgeJobLogBadRequest) Code() int { + return 400 +} + +func (o *GetPurgeJobLogBadRequest) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogBadRequest %+v", 400, o.Payload) +} + +func (o *GetPurgeJobLogBadRequest) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogBadRequest %+v", 400, o.Payload) +} + +func (o *GetPurgeJobLogBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobLogBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobLogUnauthorized creates a GetPurgeJobLogUnauthorized with default headers values +func NewGetPurgeJobLogUnauthorized() *GetPurgeJobLogUnauthorized { + return &GetPurgeJobLogUnauthorized{} +} + +/* +GetPurgeJobLogUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetPurgeJobLogUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job log unauthorized response has a 2xx status code +func (o *GetPurgeJobLogUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job log unauthorized response has a 3xx status code +func (o *GetPurgeJobLogUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log unauthorized response has a 4xx status code +func (o *GetPurgeJobLogUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job log unauthorized response has a 5xx status code +func (o *GetPurgeJobLogUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job log unauthorized response a status code equal to that given +func (o *GetPurgeJobLogUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get purge job log unauthorized response +func (o *GetPurgeJobLogUnauthorized) Code() int { + return 401 +} + +func (o *GetPurgeJobLogUnauthorized) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeJobLogUnauthorized) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeJobLogUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobLogUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobLogForbidden creates a GetPurgeJobLogForbidden with default headers values +func NewGetPurgeJobLogForbidden() *GetPurgeJobLogForbidden { + return &GetPurgeJobLogForbidden{} +} + +/* +GetPurgeJobLogForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetPurgeJobLogForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job log forbidden response has a 2xx status code +func (o *GetPurgeJobLogForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job log forbidden response has a 3xx status code +func (o *GetPurgeJobLogForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log forbidden response has a 4xx status code +func (o *GetPurgeJobLogForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job log forbidden response has a 5xx status code +func (o *GetPurgeJobLogForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job log forbidden response a status code equal to that given +func (o *GetPurgeJobLogForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get purge job log forbidden response +func (o *GetPurgeJobLogForbidden) Code() int { + return 403 +} + +func (o *GetPurgeJobLogForbidden) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeJobLogForbidden) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeJobLogForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobLogForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobLogNotFound creates a GetPurgeJobLogNotFound with default headers values +func NewGetPurgeJobLogNotFound() *GetPurgeJobLogNotFound { + return &GetPurgeJobLogNotFound{} +} + +/* +GetPurgeJobLogNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetPurgeJobLogNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job log not found response has a 2xx status code +func (o *GetPurgeJobLogNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job log not found response has a 3xx status code +func (o *GetPurgeJobLogNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log not found response has a 4xx status code +func (o *GetPurgeJobLogNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job log not found response has a 5xx status code +func (o *GetPurgeJobLogNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job log not found response a status code equal to that given +func (o *GetPurgeJobLogNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get purge job log not found response +func (o *GetPurgeJobLogNotFound) Code() int { + return 404 +} + +func (o *GetPurgeJobLogNotFound) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogNotFound %+v", 404, o.Payload) +} + +func (o *GetPurgeJobLogNotFound) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogNotFound %+v", 404, o.Payload) +} + +func (o *GetPurgeJobLogNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobLogNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobLogInternalServerError creates a GetPurgeJobLogInternalServerError with default headers values +func NewGetPurgeJobLogInternalServerError() *GetPurgeJobLogInternalServerError { + return &GetPurgeJobLogInternalServerError{} +} + +/* +GetPurgeJobLogInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetPurgeJobLogInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job log internal server error response has a 2xx status code +func (o *GetPurgeJobLogInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job log internal server error response has a 3xx status code +func (o *GetPurgeJobLogInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job log internal server error response has a 4xx status code +func (o *GetPurgeJobLogInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge job log internal server error response has a 5xx status code +func (o *GetPurgeJobLogInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get purge job log internal server error response a status code equal to that given +func (o *GetPurgeJobLogInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get purge job log internal server error response +func (o *GetPurgeJobLogInternalServerError) Code() int { + return 500 +} + +func (o *GetPurgeJobLogInternalServerError) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeJobLogInternalServerError) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}/log][%d] getPurgeJobLogInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeJobLogInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobLogInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_job_parameters.go b/pkg/harbor/client/purge/get_purge_job_parameters.go new file mode 100644 index 0000000..2ff713f --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_job_parameters.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetPurgeJobParams creates a new GetPurgeJobParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPurgeJobParams() *GetPurgeJobParams { + return &GetPurgeJobParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPurgeJobParamsWithTimeout creates a new GetPurgeJobParams object +// with the ability to set a timeout on a request. +func NewGetPurgeJobParamsWithTimeout(timeout time.Duration) *GetPurgeJobParams { + return &GetPurgeJobParams{ + timeout: timeout, + } +} + +// NewGetPurgeJobParamsWithContext creates a new GetPurgeJobParams object +// with the ability to set a context for a request. +func NewGetPurgeJobParamsWithContext(ctx context.Context) *GetPurgeJobParams { + return &GetPurgeJobParams{ + Context: ctx, + } +} + +// NewGetPurgeJobParamsWithHTTPClient creates a new GetPurgeJobParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPurgeJobParamsWithHTTPClient(client *http.Client) *GetPurgeJobParams { + return &GetPurgeJobParams{ + HTTPClient: client, + } +} + +/* +GetPurgeJobParams contains all the parameters to send to the API endpoint + + for the get purge job operation. + + Typically these are written to a http.Request. +*/ +type GetPurgeJobParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* PurgeID. + + The ID of the purge log + + Format: int64 + */ + PurgeID int64 `js:"purgeID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get purge job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeJobParams) WithDefaults() *GetPurgeJobParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get purge job params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeJobParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get purge job params +func (o *GetPurgeJobParams) WithTimeout(timeout time.Duration) *GetPurgeJobParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get purge job params +func (o *GetPurgeJobParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get purge job params +func (o *GetPurgeJobParams) WithContext(ctx context.Context) *GetPurgeJobParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get purge job params +func (o *GetPurgeJobParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get purge job params +func (o *GetPurgeJobParams) WithHTTPClient(client *http.Client) *GetPurgeJobParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get purge job params +func (o *GetPurgeJobParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get purge job params +func (o *GetPurgeJobParams) WithXRequestID(xRequestID *string) *GetPurgeJobParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get purge job params +func (o *GetPurgeJobParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPurgeID adds the purgeID to the get purge job params +func (o *GetPurgeJobParams) WithPurgeID(purgeID int64) *GetPurgeJobParams { + o.SetPurgeID(purgeID) + return o +} + +// SetPurgeID adds the purgeId to the get purge job params +func (o *GetPurgeJobParams) SetPurgeID(purgeID int64) { + o.PurgeID = purgeID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPurgeJobParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param purge_id + if err := r.SetPathParam("purge_id", swag.FormatInt64(o.PurgeID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_job_responses.go b/pkg/harbor/client/purge/get_purge_job_responses.go new file mode 100644 index 0000000..4f50a2b --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_job_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetPurgeJobReader is a Reader for the GetPurgeJob structure. +type GetPurgeJobReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPurgeJobReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPurgeJobOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetPurgeJobUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetPurgeJobForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetPurgeJobNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetPurgeJobInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /system/purgeaudit/{purge_id}] getPurgeJob", response, response.Code()) + } +} + +// NewGetPurgeJobOK creates a GetPurgeJobOK with default headers values +func NewGetPurgeJobOK() *GetPurgeJobOK { + return &GetPurgeJobOK{} +} + +/* +GetPurgeJobOK describes a response with status code 200, with default header values. + +Get purge job results successfully. +*/ +type GetPurgeJobOK struct { + Payload *models.ExecHistory +} + +// IsSuccess returns true when this get purge job o k response has a 2xx status code +func (o *GetPurgeJobOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get purge job o k response has a 3xx status code +func (o *GetPurgeJobOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job o k response has a 4xx status code +func (o *GetPurgeJobOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge job o k response has a 5xx status code +func (o *GetPurgeJobOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job o k response a status code equal to that given +func (o *GetPurgeJobOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get purge job o k response +func (o *GetPurgeJobOK) Code() int { + return 200 +} + +func (o *GetPurgeJobOK) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobOK %+v", 200, o.Payload) +} + +func (o *GetPurgeJobOK) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobOK %+v", 200, o.Payload) +} + +func (o *GetPurgeJobOK) GetPayload() *models.ExecHistory { + return o.Payload +} + +func (o *GetPurgeJobOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ExecHistory) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobUnauthorized creates a GetPurgeJobUnauthorized with default headers values +func NewGetPurgeJobUnauthorized() *GetPurgeJobUnauthorized { + return &GetPurgeJobUnauthorized{} +} + +/* +GetPurgeJobUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetPurgeJobUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job unauthorized response has a 2xx status code +func (o *GetPurgeJobUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job unauthorized response has a 3xx status code +func (o *GetPurgeJobUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job unauthorized response has a 4xx status code +func (o *GetPurgeJobUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job unauthorized response has a 5xx status code +func (o *GetPurgeJobUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job unauthorized response a status code equal to that given +func (o *GetPurgeJobUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get purge job unauthorized response +func (o *GetPurgeJobUnauthorized) Code() int { + return 401 +} + +func (o *GetPurgeJobUnauthorized) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeJobUnauthorized) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeJobUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobForbidden creates a GetPurgeJobForbidden with default headers values +func NewGetPurgeJobForbidden() *GetPurgeJobForbidden { + return &GetPurgeJobForbidden{} +} + +/* +GetPurgeJobForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetPurgeJobForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job forbidden response has a 2xx status code +func (o *GetPurgeJobForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job forbidden response has a 3xx status code +func (o *GetPurgeJobForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job forbidden response has a 4xx status code +func (o *GetPurgeJobForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job forbidden response has a 5xx status code +func (o *GetPurgeJobForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job forbidden response a status code equal to that given +func (o *GetPurgeJobForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get purge job forbidden response +func (o *GetPurgeJobForbidden) Code() int { + return 403 +} + +func (o *GetPurgeJobForbidden) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeJobForbidden) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeJobForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobNotFound creates a GetPurgeJobNotFound with default headers values +func NewGetPurgeJobNotFound() *GetPurgeJobNotFound { + return &GetPurgeJobNotFound{} +} + +/* +GetPurgeJobNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetPurgeJobNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job not found response has a 2xx status code +func (o *GetPurgeJobNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job not found response has a 3xx status code +func (o *GetPurgeJobNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job not found response has a 4xx status code +func (o *GetPurgeJobNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge job not found response has a 5xx status code +func (o *GetPurgeJobNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge job not found response a status code equal to that given +func (o *GetPurgeJobNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get purge job not found response +func (o *GetPurgeJobNotFound) Code() int { + return 404 +} + +func (o *GetPurgeJobNotFound) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobNotFound %+v", 404, o.Payload) +} + +func (o *GetPurgeJobNotFound) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobNotFound %+v", 404, o.Payload) +} + +func (o *GetPurgeJobNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeJobInternalServerError creates a GetPurgeJobInternalServerError with default headers values +func NewGetPurgeJobInternalServerError() *GetPurgeJobInternalServerError { + return &GetPurgeJobInternalServerError{} +} + +/* +GetPurgeJobInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetPurgeJobInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge job internal server error response has a 2xx status code +func (o *GetPurgeJobInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge job internal server error response has a 3xx status code +func (o *GetPurgeJobInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge job internal server error response has a 4xx status code +func (o *GetPurgeJobInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge job internal server error response has a 5xx status code +func (o *GetPurgeJobInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get purge job internal server error response a status code equal to that given +func (o *GetPurgeJobInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get purge job internal server error response +func (o *GetPurgeJobInternalServerError) Code() int { + return 500 +} + +func (o *GetPurgeJobInternalServerError) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeJobInternalServerError) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/{purge_id}][%d] getPurgeJobInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeJobInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeJobInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_schedule_parameters.go b/pkg/harbor/client/purge/get_purge_schedule_parameters.go new file mode 100644 index 0000000..8e3acee --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_schedule_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetPurgeScheduleParams creates a new GetPurgeScheduleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetPurgeScheduleParams() *GetPurgeScheduleParams { + return &GetPurgeScheduleParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetPurgeScheduleParamsWithTimeout creates a new GetPurgeScheduleParams object +// with the ability to set a timeout on a request. +func NewGetPurgeScheduleParamsWithTimeout(timeout time.Duration) *GetPurgeScheduleParams { + return &GetPurgeScheduleParams{ + timeout: timeout, + } +} + +// NewGetPurgeScheduleParamsWithContext creates a new GetPurgeScheduleParams object +// with the ability to set a context for a request. +func NewGetPurgeScheduleParamsWithContext(ctx context.Context) *GetPurgeScheduleParams { + return &GetPurgeScheduleParams{ + Context: ctx, + } +} + +// NewGetPurgeScheduleParamsWithHTTPClient creates a new GetPurgeScheduleParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetPurgeScheduleParamsWithHTTPClient(client *http.Client) *GetPurgeScheduleParams { + return &GetPurgeScheduleParams{ + HTTPClient: client, + } +} + +/* +GetPurgeScheduleParams contains all the parameters to send to the API endpoint + + for the get purge schedule operation. + + Typically these are written to a http.Request. +*/ +type GetPurgeScheduleParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeScheduleParams) WithDefaults() *GetPurgeScheduleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetPurgeScheduleParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get purge schedule params +func (o *GetPurgeScheduleParams) WithTimeout(timeout time.Duration) *GetPurgeScheduleParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get purge schedule params +func (o *GetPurgeScheduleParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get purge schedule params +func (o *GetPurgeScheduleParams) WithContext(ctx context.Context) *GetPurgeScheduleParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get purge schedule params +func (o *GetPurgeScheduleParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get purge schedule params +func (o *GetPurgeScheduleParams) WithHTTPClient(client *http.Client) *GetPurgeScheduleParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get purge schedule params +func (o *GetPurgeScheduleParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get purge schedule params +func (o *GetPurgeScheduleParams) WithXRequestID(xRequestID *string) *GetPurgeScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get purge schedule params +func (o *GetPurgeScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetPurgeScheduleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/get_purge_schedule_responses.go b/pkg/harbor/client/purge/get_purge_schedule_responses.go new file mode 100644 index 0000000..0640ad8 --- /dev/null +++ b/pkg/harbor/client/purge/get_purge_schedule_responses.go @@ -0,0 +1,361 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetPurgeScheduleReader is a Reader for the GetPurgeSchedule structure. +type GetPurgeScheduleReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetPurgeScheduleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetPurgeScheduleOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetPurgeScheduleUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetPurgeScheduleForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetPurgeScheduleInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /system/purgeaudit/schedule] getPurgeSchedule", response, response.Code()) + } +} + +// NewGetPurgeScheduleOK creates a GetPurgeScheduleOK with default headers values +func NewGetPurgeScheduleOK() *GetPurgeScheduleOK { + return &GetPurgeScheduleOK{} +} + +/* +GetPurgeScheduleOK describes a response with status code 200, with default header values. + +Get purge job's schedule. +*/ +type GetPurgeScheduleOK struct { + Payload *models.ExecHistory +} + +// IsSuccess returns true when this get purge schedule o k response has a 2xx status code +func (o *GetPurgeScheduleOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get purge schedule o k response has a 3xx status code +func (o *GetPurgeScheduleOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge schedule o k response has a 4xx status code +func (o *GetPurgeScheduleOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge schedule o k response has a 5xx status code +func (o *GetPurgeScheduleOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge schedule o k response a status code equal to that given +func (o *GetPurgeScheduleOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get purge schedule o k response +func (o *GetPurgeScheduleOK) Code() int { + return 200 +} + +func (o *GetPurgeScheduleOK) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleOK %+v", 200, o.Payload) +} + +func (o *GetPurgeScheduleOK) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleOK %+v", 200, o.Payload) +} + +func (o *GetPurgeScheduleOK) GetPayload() *models.ExecHistory { + return o.Payload +} + +func (o *GetPurgeScheduleOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ExecHistory) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeScheduleUnauthorized creates a GetPurgeScheduleUnauthorized with default headers values +func NewGetPurgeScheduleUnauthorized() *GetPurgeScheduleUnauthorized { + return &GetPurgeScheduleUnauthorized{} +} + +/* +GetPurgeScheduleUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetPurgeScheduleUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge schedule unauthorized response has a 2xx status code +func (o *GetPurgeScheduleUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge schedule unauthorized response has a 3xx status code +func (o *GetPurgeScheduleUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge schedule unauthorized response has a 4xx status code +func (o *GetPurgeScheduleUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge schedule unauthorized response has a 5xx status code +func (o *GetPurgeScheduleUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge schedule unauthorized response a status code equal to that given +func (o *GetPurgeScheduleUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get purge schedule unauthorized response +func (o *GetPurgeScheduleUnauthorized) Code() int { + return 401 +} + +func (o *GetPurgeScheduleUnauthorized) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeScheduleUnauthorized) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *GetPurgeScheduleUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeScheduleUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeScheduleForbidden creates a GetPurgeScheduleForbidden with default headers values +func NewGetPurgeScheduleForbidden() *GetPurgeScheduleForbidden { + return &GetPurgeScheduleForbidden{} +} + +/* +GetPurgeScheduleForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetPurgeScheduleForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge schedule forbidden response has a 2xx status code +func (o *GetPurgeScheduleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge schedule forbidden response has a 3xx status code +func (o *GetPurgeScheduleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge schedule forbidden response has a 4xx status code +func (o *GetPurgeScheduleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get purge schedule forbidden response has a 5xx status code +func (o *GetPurgeScheduleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get purge schedule forbidden response a status code equal to that given +func (o *GetPurgeScheduleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get purge schedule forbidden response +func (o *GetPurgeScheduleForbidden) Code() int { + return 403 +} + +func (o *GetPurgeScheduleForbidden) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeScheduleForbidden) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *GetPurgeScheduleForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeScheduleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetPurgeScheduleInternalServerError creates a GetPurgeScheduleInternalServerError with default headers values +func NewGetPurgeScheduleInternalServerError() *GetPurgeScheduleInternalServerError { + return &GetPurgeScheduleInternalServerError{} +} + +/* +GetPurgeScheduleInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetPurgeScheduleInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get purge schedule internal server error response has a 2xx status code +func (o *GetPurgeScheduleInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get purge schedule internal server error response has a 3xx status code +func (o *GetPurgeScheduleInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get purge schedule internal server error response has a 4xx status code +func (o *GetPurgeScheduleInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get purge schedule internal server error response has a 5xx status code +func (o *GetPurgeScheduleInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get purge schedule internal server error response a status code equal to that given +func (o *GetPurgeScheduleInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get purge schedule internal server error response +func (o *GetPurgeScheduleInternalServerError) Code() int { + return 500 +} + +func (o *GetPurgeScheduleInternalServerError) Error() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeScheduleInternalServerError) String() string { + return fmt.Sprintf("[GET /system/purgeaudit/schedule][%d] getPurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *GetPurgeScheduleInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetPurgeScheduleInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/purge_client.go b/pkg/harbor/client/purge/purge_client.go new file mode 100644 index 0000000..e805b65 --- /dev/null +++ b/pkg/harbor/client/purge/purge_client.go @@ -0,0 +1,354 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the purge client +type API interface { + /* + CreatePurgeSchedule creates a purge job schedule + + This endpoint is for update purge job schedule. + */ + CreatePurgeSchedule(ctx context.Context, params *CreatePurgeScheduleParams) (*CreatePurgeScheduleCreated, error) + /* + GetPurgeHistory gets purge job results + + get purge job execution history.*/ + GetPurgeHistory(ctx context.Context, params *GetPurgeHistoryParams) (*GetPurgeHistoryOK, error) + /* + GetPurgeJob gets purge job status + + This endpoint let user get purge job status filtered by specific ID.*/ + GetPurgeJob(ctx context.Context, params *GetPurgeJobParams) (*GetPurgeJobOK, error) + /* + GetPurgeJobLog gets purge job log + + This endpoint let user get purge job logs filtered by specific ID.*/ + GetPurgeJobLog(ctx context.Context, params *GetPurgeJobLogParams) (*GetPurgeJobLogOK, error) + /* + GetPurgeSchedule gets purge s schedule + + This endpoint is for get schedule of purge job.*/ + GetPurgeSchedule(ctx context.Context, params *GetPurgeScheduleParams) (*GetPurgeScheduleOK, error) + /* + StopPurge stops the specific purge audit log execution + + Stop the purge audit log execution specified by ID*/ + StopPurge(ctx context.Context, params *StopPurgeParams) (*StopPurgeOK, error) + /* + UpdatePurgeSchedule updates purge job s schedule + + This endpoint is for update purge job schedule. + */ + UpdatePurgeSchedule(ctx context.Context, params *UpdatePurgeScheduleParams) (*UpdatePurgeScheduleOK, error) +} + +// New creates a new purge API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for purge API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +CreatePurgeSchedule creates a purge job schedule + +This endpoint is for update purge job schedule. +*/ +func (a *Client) CreatePurgeSchedule(ctx context.Context, params *CreatePurgeScheduleParams) (*CreatePurgeScheduleCreated, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createPurgeSchedule", + Method: "POST", + PathPattern: "/system/purgeaudit/schedule", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &CreatePurgeScheduleReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *CreatePurgeScheduleCreated: + return value, nil + case *CreatePurgeScheduleBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *CreatePurgeScheduleUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *CreatePurgeScheduleForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *CreatePurgeScheduleInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for createPurgeSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetPurgeHistory gets purge job results + +get purge job execution history. +*/ +func (a *Client) GetPurgeHistory(ctx context.Context, params *GetPurgeHistoryParams) (*GetPurgeHistoryOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getPurgeHistory", + Method: "GET", + PathPattern: "/system/purgeaudit", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetPurgeHistoryReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetPurgeHistoryOK: + return value, nil + case *GetPurgeHistoryUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeHistoryForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeHistoryInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getPurgeHistory: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetPurgeJob gets purge job status + +This endpoint let user get purge job status filtered by specific ID. +*/ +func (a *Client) GetPurgeJob(ctx context.Context, params *GetPurgeJobParams) (*GetPurgeJobOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getPurgeJob", + Method: "GET", + PathPattern: "/system/purgeaudit/{purge_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetPurgeJobReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetPurgeJobOK: + return value, nil + case *GetPurgeJobUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getPurgeJob: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetPurgeJobLog gets purge job log + +This endpoint let user get purge job logs filtered by specific ID. +*/ +func (a *Client) GetPurgeJobLog(ctx context.Context, params *GetPurgeJobLogParams) (*GetPurgeJobLogOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getPurgeJobLog", + Method: "GET", + PathPattern: "/system/purgeaudit/{purge_id}/log", + ProducesMediaTypes: []string{"text/plain"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetPurgeJobLogReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetPurgeJobLogOK: + return value, nil + case *GetPurgeJobLogBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobLogUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobLogForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobLogNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeJobLogInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getPurgeJobLog: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetPurgeSchedule gets purge s schedule + +This endpoint is for get schedule of purge job. +*/ +func (a *Client) GetPurgeSchedule(ctx context.Context, params *GetPurgeScheduleParams) (*GetPurgeScheduleOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getPurgeSchedule", + Method: "GET", + PathPattern: "/system/purgeaudit/schedule", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetPurgeScheduleReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetPurgeScheduleOK: + return value, nil + case *GetPurgeScheduleUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeScheduleForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetPurgeScheduleInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getPurgeSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +StopPurge stops the specific purge audit log execution + +Stop the purge audit log execution specified by ID +*/ +func (a *Client) StopPurge(ctx context.Context, params *StopPurgeParams) (*StopPurgeOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "stopPurge", + Method: "PUT", + PathPattern: "/system/purgeaudit/{purge_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StopPurgeReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *StopPurgeOK: + return value, nil + case *StopPurgeUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopPurgeForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopPurgeNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopPurgeInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for stopPurge: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +UpdatePurgeSchedule updates purge job s schedule + +This endpoint is for update purge job schedule. +*/ +func (a *Client) UpdatePurgeSchedule(ctx context.Context, params *UpdatePurgeScheduleParams) (*UpdatePurgeScheduleOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "updatePurgeSchedule", + Method: "PUT", + PathPattern: "/system/purgeaudit/schedule", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &UpdatePurgeScheduleReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *UpdatePurgeScheduleOK: + return value, nil + case *UpdatePurgeScheduleBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *UpdatePurgeScheduleUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *UpdatePurgeScheduleForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *UpdatePurgeScheduleInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for updatePurgeSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/purge/stop_purge_parameters.go b/pkg/harbor/client/purge/stop_purge_parameters.go new file mode 100644 index 0000000..2830270 --- /dev/null +++ b/pkg/harbor/client/purge/stop_purge_parameters.go @@ -0,0 +1,179 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewStopPurgeParams creates a new StopPurgeParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStopPurgeParams() *StopPurgeParams { + return &StopPurgeParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStopPurgeParamsWithTimeout creates a new StopPurgeParams object +// with the ability to set a timeout on a request. +func NewStopPurgeParamsWithTimeout(timeout time.Duration) *StopPurgeParams { + return &StopPurgeParams{ + timeout: timeout, + } +} + +// NewStopPurgeParamsWithContext creates a new StopPurgeParams object +// with the ability to set a context for a request. +func NewStopPurgeParamsWithContext(ctx context.Context) *StopPurgeParams { + return &StopPurgeParams{ + Context: ctx, + } +} + +// NewStopPurgeParamsWithHTTPClient creates a new StopPurgeParams object +// with the ability to set a custom HTTPClient for a request. +func NewStopPurgeParamsWithHTTPClient(client *http.Client) *StopPurgeParams { + return &StopPurgeParams{ + HTTPClient: client, + } +} + +/* +StopPurgeParams contains all the parameters to send to the API endpoint + + for the stop purge operation. + + Typically these are written to a http.Request. +*/ +type StopPurgeParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* PurgeID. + + The ID of the purge log + + Format: int64 + */ + PurgeID int64 `js:"purgeID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the stop purge params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopPurgeParams) WithDefaults() *StopPurgeParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the stop purge params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopPurgeParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the stop purge params +func (o *StopPurgeParams) WithTimeout(timeout time.Duration) *StopPurgeParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the stop purge params +func (o *StopPurgeParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the stop purge params +func (o *StopPurgeParams) WithContext(ctx context.Context) *StopPurgeParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the stop purge params +func (o *StopPurgeParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the stop purge params +func (o *StopPurgeParams) WithHTTPClient(client *http.Client) *StopPurgeParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the stop purge params +func (o *StopPurgeParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the stop purge params +func (o *StopPurgeParams) WithXRequestID(xRequestID *string) *StopPurgeParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop purge params +func (o *StopPurgeParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPurgeID adds the purgeID to the stop purge params +func (o *StopPurgeParams) WithPurgeID(purgeID int64) *StopPurgeParams { + o.SetPurgeID(purgeID) + return o +} + +// SetPurgeID adds the purgeId to the stop purge params +func (o *StopPurgeParams) SetPurgeID(purgeID int64) { + o.PurgeID = purgeID +} + +// WriteToRequest writes these params to a swagger request +func (o *StopPurgeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param purge_id + if err := r.SetPathParam("purge_id", swag.FormatInt64(o.PurgeID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/stop_purge_responses.go b/pkg/harbor/client/purge/stop_purge_responses.go new file mode 100644 index 0000000..5362bd3 --- /dev/null +++ b/pkg/harbor/client/purge/stop_purge_responses.go @@ -0,0 +1,446 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// StopPurgeReader is a Reader for the StopPurge structure. +type StopPurgeReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StopPurgeReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStopPurgeOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewStopPurgeUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewStopPurgeForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewStopPurgeNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewStopPurgeInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /system/purgeaudit/{purge_id}] stopPurge", response, response.Code()) + } +} + +// NewStopPurgeOK creates a StopPurgeOK with default headers values +func NewStopPurgeOK() *StopPurgeOK { + return &StopPurgeOK{} +} + +/* +StopPurgeOK describes a response with status code 200, with default header values. + +Success +*/ +type StopPurgeOK struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string +} + +// IsSuccess returns true when this stop purge o k response has a 2xx status code +func (o *StopPurgeOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this stop purge o k response has a 3xx status code +func (o *StopPurgeOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop purge o k response has a 4xx status code +func (o *StopPurgeOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop purge o k response has a 5xx status code +func (o *StopPurgeOK) IsServerError() bool { + return false +} + +// IsCode returns true when this stop purge o k response a status code equal to that given +func (o *StopPurgeOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the stop purge o k response +func (o *StopPurgeOK) Code() int { + return 200 +} + +func (o *StopPurgeOK) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeOK ", 200) +} + +func (o *StopPurgeOK) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeOK ", 200) +} + +func (o *StopPurgeOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + return nil +} + +// NewStopPurgeUnauthorized creates a StopPurgeUnauthorized with default headers values +func NewStopPurgeUnauthorized() *StopPurgeUnauthorized { + return &StopPurgeUnauthorized{} +} + +/* +StopPurgeUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type StopPurgeUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop purge unauthorized response has a 2xx status code +func (o *StopPurgeUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop purge unauthorized response has a 3xx status code +func (o *StopPurgeUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop purge unauthorized response has a 4xx status code +func (o *StopPurgeUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop purge unauthorized response has a 5xx status code +func (o *StopPurgeUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this stop purge unauthorized response a status code equal to that given +func (o *StopPurgeUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the stop purge unauthorized response +func (o *StopPurgeUnauthorized) Code() int { + return 401 +} + +func (o *StopPurgeUnauthorized) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeUnauthorized %+v", 401, o.Payload) +} + +func (o *StopPurgeUnauthorized) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeUnauthorized %+v", 401, o.Payload) +} + +func (o *StopPurgeUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopPurgeUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopPurgeForbidden creates a StopPurgeForbidden with default headers values +func NewStopPurgeForbidden() *StopPurgeForbidden { + return &StopPurgeForbidden{} +} + +/* +StopPurgeForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type StopPurgeForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop purge forbidden response has a 2xx status code +func (o *StopPurgeForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop purge forbidden response has a 3xx status code +func (o *StopPurgeForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop purge forbidden response has a 4xx status code +func (o *StopPurgeForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop purge forbidden response has a 5xx status code +func (o *StopPurgeForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this stop purge forbidden response a status code equal to that given +func (o *StopPurgeForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the stop purge forbidden response +func (o *StopPurgeForbidden) Code() int { + return 403 +} + +func (o *StopPurgeForbidden) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeForbidden %+v", 403, o.Payload) +} + +func (o *StopPurgeForbidden) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeForbidden %+v", 403, o.Payload) +} + +func (o *StopPurgeForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopPurgeForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopPurgeNotFound creates a StopPurgeNotFound with default headers values +func NewStopPurgeNotFound() *StopPurgeNotFound { + return &StopPurgeNotFound{} +} + +/* +StopPurgeNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type StopPurgeNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop purge not found response has a 2xx status code +func (o *StopPurgeNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop purge not found response has a 3xx status code +func (o *StopPurgeNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop purge not found response has a 4xx status code +func (o *StopPurgeNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop purge not found response has a 5xx status code +func (o *StopPurgeNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this stop purge not found response a status code equal to that given +func (o *StopPurgeNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the stop purge not found response +func (o *StopPurgeNotFound) Code() int { + return 404 +} + +func (o *StopPurgeNotFound) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeNotFound %+v", 404, o.Payload) +} + +func (o *StopPurgeNotFound) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeNotFound %+v", 404, o.Payload) +} + +func (o *StopPurgeNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopPurgeNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopPurgeInternalServerError creates a StopPurgeInternalServerError with default headers values +func NewStopPurgeInternalServerError() *StopPurgeInternalServerError { + return &StopPurgeInternalServerError{} +} + +/* +StopPurgeInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type StopPurgeInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop purge internal server error response has a 2xx status code +func (o *StopPurgeInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop purge internal server error response has a 3xx status code +func (o *StopPurgeInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop purge internal server error response has a 4xx status code +func (o *StopPurgeInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop purge internal server error response has a 5xx status code +func (o *StopPurgeInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this stop purge internal server error response a status code equal to that given +func (o *StopPurgeInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the stop purge internal server error response +func (o *StopPurgeInternalServerError) Code() int { + return 500 +} + +func (o *StopPurgeInternalServerError) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeInternalServerError %+v", 500, o.Payload) +} + +func (o *StopPurgeInternalServerError) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/{purge_id}][%d] stopPurgeInternalServerError %+v", 500, o.Payload) +} + +func (o *StopPurgeInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopPurgeInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/purge/update_purge_schedule_parameters.go b/pkg/harbor/client/purge/update_purge_schedule_parameters.go new file mode 100644 index 0000000..7bf30b8 --- /dev/null +++ b/pkg/harbor/client/purge/update_purge_schedule_parameters.go @@ -0,0 +1,182 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// NewUpdatePurgeScheduleParams creates a new UpdatePurgeScheduleParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUpdatePurgeScheduleParams() *UpdatePurgeScheduleParams { + return &UpdatePurgeScheduleParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdatePurgeScheduleParamsWithTimeout creates a new UpdatePurgeScheduleParams object +// with the ability to set a timeout on a request. +func NewUpdatePurgeScheduleParamsWithTimeout(timeout time.Duration) *UpdatePurgeScheduleParams { + return &UpdatePurgeScheduleParams{ + timeout: timeout, + } +} + +// NewUpdatePurgeScheduleParamsWithContext creates a new UpdatePurgeScheduleParams object +// with the ability to set a context for a request. +func NewUpdatePurgeScheduleParamsWithContext(ctx context.Context) *UpdatePurgeScheduleParams { + return &UpdatePurgeScheduleParams{ + Context: ctx, + } +} + +// NewUpdatePurgeScheduleParamsWithHTTPClient creates a new UpdatePurgeScheduleParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdatePurgeScheduleParamsWithHTTPClient(client *http.Client) *UpdatePurgeScheduleParams { + return &UpdatePurgeScheduleParams{ + HTTPClient: client, + } +} + +/* +UpdatePurgeScheduleParams contains all the parameters to send to the API endpoint + + for the update purge schedule operation. + + Typically these are written to a http.Request. +*/ +type UpdatePurgeScheduleParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Schedule. + + The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + + */ + Schedule *models.Schedule `js:"schedule"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the update purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePurgeScheduleParams) WithDefaults() *UpdatePurgeScheduleParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update purge schedule params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdatePurgeScheduleParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update purge schedule params +func (o *UpdatePurgeScheduleParams) WithTimeout(timeout time.Duration) *UpdatePurgeScheduleParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update purge schedule params +func (o *UpdatePurgeScheduleParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update purge schedule params +func (o *UpdatePurgeScheduleParams) WithContext(ctx context.Context) *UpdatePurgeScheduleParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update purge schedule params +func (o *UpdatePurgeScheduleParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update purge schedule params +func (o *UpdatePurgeScheduleParams) WithHTTPClient(client *http.Client) *UpdatePurgeScheduleParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update purge schedule params +func (o *UpdatePurgeScheduleParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the update purge schedule params +func (o *UpdatePurgeScheduleParams) WithXRequestID(xRequestID *string) *UpdatePurgeScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the update purge schedule params +func (o *UpdatePurgeScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithSchedule adds the schedule to the update purge schedule params +func (o *UpdatePurgeScheduleParams) WithSchedule(schedule *models.Schedule) *UpdatePurgeScheduleParams { + o.SetSchedule(schedule) + return o +} + +// SetSchedule adds the schedule to the update purge schedule params +func (o *UpdatePurgeScheduleParams) SetSchedule(schedule *models.Schedule) { + o.Schedule = schedule +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdatePurgeScheduleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.Schedule != nil { + if err := r.SetBodyParam(o.Schedule); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/purge/update_purge_schedule_responses.go b/pkg/harbor/client/purge/update_purge_schedule_responses.go new file mode 100644 index 0000000..5757f78 --- /dev/null +++ b/pkg/harbor/client/purge/update_purge_schedule_responses.go @@ -0,0 +1,435 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package purge + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// UpdatePurgeScheduleReader is a Reader for the UpdatePurgeSchedule structure. +type UpdatePurgeScheduleReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdatePurgeScheduleReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdatePurgeScheduleOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewUpdatePurgeScheduleBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewUpdatePurgeScheduleUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewUpdatePurgeScheduleForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewUpdatePurgeScheduleInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /system/purgeaudit/schedule] updatePurgeSchedule", response, response.Code()) + } +} + +// NewUpdatePurgeScheduleOK creates a UpdatePurgeScheduleOK with default headers values +func NewUpdatePurgeScheduleOK() *UpdatePurgeScheduleOK { + return &UpdatePurgeScheduleOK{} +} + +/* +UpdatePurgeScheduleOK describes a response with status code 200, with default header values. + +Updated purge's schedule successfully. +*/ +type UpdatePurgeScheduleOK struct { +} + +// IsSuccess returns true when this update purge schedule o k response has a 2xx status code +func (o *UpdatePurgeScheduleOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update purge schedule o k response has a 3xx status code +func (o *UpdatePurgeScheduleOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update purge schedule o k response has a 4xx status code +func (o *UpdatePurgeScheduleOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update purge schedule o k response has a 5xx status code +func (o *UpdatePurgeScheduleOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update purge schedule o k response a status code equal to that given +func (o *UpdatePurgeScheduleOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update purge schedule o k response +func (o *UpdatePurgeScheduleOK) Code() int { + return 200 +} + +func (o *UpdatePurgeScheduleOK) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleOK ", 200) +} + +func (o *UpdatePurgeScheduleOK) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleOK ", 200) +} + +func (o *UpdatePurgeScheduleOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdatePurgeScheduleBadRequest creates a UpdatePurgeScheduleBadRequest with default headers values +func NewUpdatePurgeScheduleBadRequest() *UpdatePurgeScheduleBadRequest { + return &UpdatePurgeScheduleBadRequest{} +} + +/* +UpdatePurgeScheduleBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type UpdatePurgeScheduleBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this update purge schedule bad request response has a 2xx status code +func (o *UpdatePurgeScheduleBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update purge schedule bad request response has a 3xx status code +func (o *UpdatePurgeScheduleBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update purge schedule bad request response has a 4xx status code +func (o *UpdatePurgeScheduleBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this update purge schedule bad request response has a 5xx status code +func (o *UpdatePurgeScheduleBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this update purge schedule bad request response a status code equal to that given +func (o *UpdatePurgeScheduleBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the update purge schedule bad request response +func (o *UpdatePurgeScheduleBadRequest) Code() int { + return 400 +} + +func (o *UpdatePurgeScheduleBadRequest) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleBadRequest %+v", 400, o.Payload) +} + +func (o *UpdatePurgeScheduleBadRequest) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleBadRequest %+v", 400, o.Payload) +} + +func (o *UpdatePurgeScheduleBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *UpdatePurgeScheduleBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdatePurgeScheduleUnauthorized creates a UpdatePurgeScheduleUnauthorized with default headers values +func NewUpdatePurgeScheduleUnauthorized() *UpdatePurgeScheduleUnauthorized { + return &UpdatePurgeScheduleUnauthorized{} +} + +/* +UpdatePurgeScheduleUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type UpdatePurgeScheduleUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this update purge schedule unauthorized response has a 2xx status code +func (o *UpdatePurgeScheduleUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update purge schedule unauthorized response has a 3xx status code +func (o *UpdatePurgeScheduleUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update purge schedule unauthorized response has a 4xx status code +func (o *UpdatePurgeScheduleUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this update purge schedule unauthorized response has a 5xx status code +func (o *UpdatePurgeScheduleUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this update purge schedule unauthorized response a status code equal to that given +func (o *UpdatePurgeScheduleUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the update purge schedule unauthorized response +func (o *UpdatePurgeScheduleUnauthorized) Code() int { + return 401 +} + +func (o *UpdatePurgeScheduleUnauthorized) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *UpdatePurgeScheduleUnauthorized) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleUnauthorized %+v", 401, o.Payload) +} + +func (o *UpdatePurgeScheduleUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *UpdatePurgeScheduleUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdatePurgeScheduleForbidden creates a UpdatePurgeScheduleForbidden with default headers values +func NewUpdatePurgeScheduleForbidden() *UpdatePurgeScheduleForbidden { + return &UpdatePurgeScheduleForbidden{} +} + +/* +UpdatePurgeScheduleForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type UpdatePurgeScheduleForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this update purge schedule forbidden response has a 2xx status code +func (o *UpdatePurgeScheduleForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update purge schedule forbidden response has a 3xx status code +func (o *UpdatePurgeScheduleForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update purge schedule forbidden response has a 4xx status code +func (o *UpdatePurgeScheduleForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update purge schedule forbidden response has a 5xx status code +func (o *UpdatePurgeScheduleForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update purge schedule forbidden response a status code equal to that given +func (o *UpdatePurgeScheduleForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update purge schedule forbidden response +func (o *UpdatePurgeScheduleForbidden) Code() int { + return 403 +} + +func (o *UpdatePurgeScheduleForbidden) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *UpdatePurgeScheduleForbidden) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleForbidden %+v", 403, o.Payload) +} + +func (o *UpdatePurgeScheduleForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *UpdatePurgeScheduleForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdatePurgeScheduleInternalServerError creates a UpdatePurgeScheduleInternalServerError with default headers values +func NewUpdatePurgeScheduleInternalServerError() *UpdatePurgeScheduleInternalServerError { + return &UpdatePurgeScheduleInternalServerError{} +} + +/* +UpdatePurgeScheduleInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type UpdatePurgeScheduleInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this update purge schedule internal server error response has a 2xx status code +func (o *UpdatePurgeScheduleInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update purge schedule internal server error response has a 3xx status code +func (o *UpdatePurgeScheduleInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update purge schedule internal server error response has a 4xx status code +func (o *UpdatePurgeScheduleInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this update purge schedule internal server error response has a 5xx status code +func (o *UpdatePurgeScheduleInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this update purge schedule internal server error response a status code equal to that given +func (o *UpdatePurgeScheduleInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the update purge schedule internal server error response +func (o *UpdatePurgeScheduleInternalServerError) Code() int { + return 500 +} + +func (o *UpdatePurgeScheduleInternalServerError) Error() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *UpdatePurgeScheduleInternalServerError) String() string { + return fmt.Sprintf("[PUT /system/purgeaudit/schedule][%d] updatePurgeScheduleInternalServerError %+v", 500, o.Payload) +} + +func (o *UpdatePurgeScheduleInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *UpdatePurgeScheduleInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/registry/list_registries_parameters.go b/pkg/harbor/client/registry/list_registries_parameters.go index 1bc071d..743b9fc 100644 --- a/pkg/harbor/client/registry/list_registries_parameters.go +++ b/pkg/harbor/client/registry/list_registries_parameters.go @@ -100,7 +100,7 @@ type ListRegistriesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/replication/create_replication_policy_parameters.go b/pkg/harbor/client/replication/create_replication_policy_parameters.go index 5f2a071..81b8d4d 100644 --- a/pkg/harbor/client/replication/create_replication_policy_parameters.go +++ b/pkg/harbor/client/replication/create_replication_policy_parameters.go @@ -63,6 +63,12 @@ CreateReplicationPolicyParams contains all the parameters to send to the API end */ type CreateReplicationPolicyParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Policy. The replication policy @@ -122,6 +128,17 @@ func (o *CreateReplicationPolicyParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the create replication policy params +func (o *CreateReplicationPolicyParams) WithXRequestID(xRequestID *string) *CreateReplicationPolicyParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the create replication policy params +func (o *CreateReplicationPolicyParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithPolicy adds the policy to the create replication policy params func (o *CreateReplicationPolicyParams) WithPolicy(policy *models.ReplicationPolicy) *CreateReplicationPolicyParams { o.SetPolicy(policy) @@ -140,6 +157,14 @@ func (o *CreateReplicationPolicyParams) WriteToRequest(r runtime.ClientRequest, return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Policy != nil { if err := r.SetBodyParam(o.Policy); err != nil { return err diff --git a/pkg/harbor/client/replication/delete_replication_policy_parameters.go b/pkg/harbor/client/replication/delete_replication_policy_parameters.go index 02299b3..74c9ee8 100644 --- a/pkg/harbor/client/replication/delete_replication_policy_parameters.go +++ b/pkg/harbor/client/replication/delete_replication_policy_parameters.go @@ -62,6 +62,12 @@ DeleteReplicationPolicyParams contains all the parameters to send to the API end */ type DeleteReplicationPolicyParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. Replication policy ID @@ -123,6 +129,17 @@ func (o *DeleteReplicationPolicyParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the delete replication policy params +func (o *DeleteReplicationPolicyParams) WithXRequestID(xRequestID *string) *DeleteReplicationPolicyParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the delete replication policy params +func (o *DeleteReplicationPolicyParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the delete replication policy params func (o *DeleteReplicationPolicyParams) WithID(id int64) *DeleteReplicationPolicyParams { o.SetID(id) @@ -142,6 +159,14 @@ func (o *DeleteReplicationPolicyParams) WriteToRequest(r runtime.ClientRequest, } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/replication/get_replication_execution_parameters.go b/pkg/harbor/client/replication/get_replication_execution_parameters.go index fc5599d..7a1848e 100644 --- a/pkg/harbor/client/replication/get_replication_execution_parameters.go +++ b/pkg/harbor/client/replication/get_replication_execution_parameters.go @@ -62,6 +62,12 @@ GetReplicationExecutionParams contains all the parameters to send to the API end */ type GetReplicationExecutionParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. The ID of the execution. @@ -123,6 +129,17 @@ func (o *GetReplicationExecutionParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the get replication execution params +func (o *GetReplicationExecutionParams) WithXRequestID(xRequestID *string) *GetReplicationExecutionParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get replication execution params +func (o *GetReplicationExecutionParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the get replication execution params func (o *GetReplicationExecutionParams) WithID(id int64) *GetReplicationExecutionParams { o.SetID(id) @@ -142,6 +159,14 @@ func (o *GetReplicationExecutionParams) WriteToRequest(r runtime.ClientRequest, } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/replication/get_replication_log_parameters.go b/pkg/harbor/client/replication/get_replication_log_parameters.go index b26df78..17389e2 100644 --- a/pkg/harbor/client/replication/get_replication_log_parameters.go +++ b/pkg/harbor/client/replication/get_replication_log_parameters.go @@ -62,6 +62,12 @@ GetReplicationLogParams contains all the parameters to send to the API endpoint */ type GetReplicationLogParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. The ID of the execution that the tasks belongs to. @@ -131,6 +137,17 @@ func (o *GetReplicationLogParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the get replication log params +func (o *GetReplicationLogParams) WithXRequestID(xRequestID *string) *GetReplicationLogParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get replication log params +func (o *GetReplicationLogParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the get replication log params func (o *GetReplicationLogParams) WithID(id int64) *GetReplicationLogParams { o.SetID(id) @@ -161,6 +178,14 @@ func (o *GetReplicationLogParams) WriteToRequest(r runtime.ClientRequest, reg st } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/replication/get_replication_policy_parameters.go b/pkg/harbor/client/replication/get_replication_policy_parameters.go index bc199fc..5af2a98 100644 --- a/pkg/harbor/client/replication/get_replication_policy_parameters.go +++ b/pkg/harbor/client/replication/get_replication_policy_parameters.go @@ -62,6 +62,12 @@ GetReplicationPolicyParams contains all the parameters to send to the API endpoi */ type GetReplicationPolicyParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. Policy ID @@ -123,6 +129,17 @@ func (o *GetReplicationPolicyParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the get replication policy params +func (o *GetReplicationPolicyParams) WithXRequestID(xRequestID *string) *GetReplicationPolicyParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get replication policy params +func (o *GetReplicationPolicyParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the get replication policy params func (o *GetReplicationPolicyParams) WithID(id int64) *GetReplicationPolicyParams { o.SetID(id) @@ -142,6 +159,14 @@ func (o *GetReplicationPolicyParams) WriteToRequest(r runtime.ClientRequest, reg } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/replication/list_replication_executions_parameters.go b/pkg/harbor/client/replication/list_replication_executions_parameters.go index 5253156..b2ceb3c 100644 --- a/pkg/harbor/client/replication/list_replication_executions_parameters.go +++ b/pkg/harbor/client/replication/list_replication_executions_parameters.go @@ -94,7 +94,7 @@ type ListReplicationExecutionsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/replication/list_replication_policies_parameters.go b/pkg/harbor/client/replication/list_replication_policies_parameters.go index c44c0ad..aaa6285 100644 --- a/pkg/harbor/client/replication/list_replication_policies_parameters.go +++ b/pkg/harbor/client/replication/list_replication_policies_parameters.go @@ -100,7 +100,7 @@ type ListReplicationPoliciesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/replication/list_replication_tasks_parameters.go b/pkg/harbor/client/replication/list_replication_tasks_parameters.go index 90702bc..03dc63a 100644 --- a/pkg/harbor/client/replication/list_replication_tasks_parameters.go +++ b/pkg/harbor/client/replication/list_replication_tasks_parameters.go @@ -102,7 +102,7 @@ type ListReplicationTasksParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/replication/start_replication_parameters.go b/pkg/harbor/client/replication/start_replication_parameters.go index de1eef1..596db75 100644 --- a/pkg/harbor/client/replication/start_replication_parameters.go +++ b/pkg/harbor/client/replication/start_replication_parameters.go @@ -63,6 +63,12 @@ StartReplicationParams contains all the parameters to send to the API endpoint */ type StartReplicationParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Execution. The ID of policy that the execution belongs to @@ -122,6 +128,17 @@ func (o *StartReplicationParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the start replication params +func (o *StartReplicationParams) WithXRequestID(xRequestID *string) *StartReplicationParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the start replication params +func (o *StartReplicationParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithExecution adds the execution to the start replication params func (o *StartReplicationParams) WithExecution(execution *models.StartReplicationExecution) *StartReplicationParams { o.SetExecution(execution) @@ -140,6 +157,14 @@ func (o *StartReplicationParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Execution != nil { if err := r.SetBodyParam(o.Execution); err != nil { return err diff --git a/pkg/harbor/client/replication/stop_replication_parameters.go b/pkg/harbor/client/replication/stop_replication_parameters.go index 538bcfb..8cbe565 100644 --- a/pkg/harbor/client/replication/stop_replication_parameters.go +++ b/pkg/harbor/client/replication/stop_replication_parameters.go @@ -62,6 +62,12 @@ StopReplicationParams contains all the parameters to send to the API endpoint */ type StopReplicationParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. The ID of the execution. @@ -123,6 +129,17 @@ func (o *StopReplicationParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the stop replication params +func (o *StopReplicationParams) WithXRequestID(xRequestID *string) *StopReplicationParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop replication params +func (o *StopReplicationParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the stop replication params func (o *StopReplicationParams) WithID(id int64) *StopReplicationParams { o.SetID(id) @@ -142,6 +159,14 @@ func (o *StopReplicationParams) WriteToRequest(r runtime.ClientRequest, reg strf } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/replication/update_replication_policy_parameters.go b/pkg/harbor/client/replication/update_replication_policy_parameters.go index 37451c8..049be98 100644 --- a/pkg/harbor/client/replication/update_replication_policy_parameters.go +++ b/pkg/harbor/client/replication/update_replication_policy_parameters.go @@ -64,6 +64,12 @@ UpdateReplicationPolicyParams contains all the parameters to send to the API end */ type UpdateReplicationPolicyParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* ID. The policy ID @@ -131,6 +137,17 @@ func (o *UpdateReplicationPolicyParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the update replication policy params +func (o *UpdateReplicationPolicyParams) WithXRequestID(xRequestID *string) *UpdateReplicationPolicyParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the update replication policy params +func (o *UpdateReplicationPolicyParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithID adds the id to the update replication policy params func (o *UpdateReplicationPolicyParams) WithID(id int64) *UpdateReplicationPolicyParams { o.SetID(id) @@ -161,6 +178,14 @@ func (o *UpdateReplicationPolicyParams) WriteToRequest(r runtime.ClientRequest, } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param id if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { return err diff --git a/pkg/harbor/client/repository/delete_repository_parameters.go b/pkg/harbor/client/repository/delete_repository_parameters.go index fce8c9b..bb5908f 100644 --- a/pkg/harbor/client/repository/delete_repository_parameters.go +++ b/pkg/harbor/client/repository/delete_repository_parameters.go @@ -75,7 +75,7 @@ type DeleteRepositoryParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/repository/get_repository_parameters.go b/pkg/harbor/client/repository/get_repository_parameters.go index 0c602a7..791ccc3 100644 --- a/pkg/harbor/client/repository/get_repository_parameters.go +++ b/pkg/harbor/client/repository/get_repository_parameters.go @@ -75,7 +75,7 @@ type GetRepositoryParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/repository/list_all_repositories_parameters.go b/pkg/harbor/client/repository/list_all_repositories_parameters.go index 53fbcbc..31eb85d 100644 --- a/pkg/harbor/client/repository/list_all_repositories_parameters.go +++ b/pkg/harbor/client/repository/list_all_repositories_parameters.go @@ -94,7 +94,7 @@ type ListAllRepositoriesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/repository/list_repositories_parameters.go b/pkg/harbor/client/repository/list_repositories_parameters.go index bfa2cc1..2f6b5e1 100644 --- a/pkg/harbor/client/repository/list_repositories_parameters.go +++ b/pkg/harbor/client/repository/list_repositories_parameters.go @@ -100,7 +100,7 @@ type ListRepositoriesParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/repository/update_repository_parameters.go b/pkg/harbor/client/repository/update_repository_parameters.go index bc2af86..31ce339 100644 --- a/pkg/harbor/client/repository/update_repository_parameters.go +++ b/pkg/harbor/client/repository/update_repository_parameters.go @@ -83,7 +83,7 @@ type UpdateRepositoryParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/robot/list_robot_parameters.go b/pkg/harbor/client/robot/list_robot_parameters.go index 57ca69d..786d68d 100644 --- a/pkg/harbor/client/robot/list_robot_parameters.go +++ b/pkg/harbor/client/robot/list_robot_parameters.go @@ -94,7 +94,7 @@ type ListRobotParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/robotv1/list_robot_v1_parameters.go b/pkg/harbor/client/robotv1/list_robot_v1_parameters.go index 324b513..473d3c3 100644 --- a/pkg/harbor/client/robotv1/list_robot_v1_parameters.go +++ b/pkg/harbor/client/robotv1/list_robot_v1_parameters.go @@ -106,7 +106,7 @@ type ListRobotV1Params struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/scan/get_report_log_parameters.go b/pkg/harbor/client/scan/get_report_log_parameters.go index 6d9798f..38f4b40 100644 --- a/pkg/harbor/client/scan/get_report_log_parameters.go +++ b/pkg/harbor/client/scan/get_report_log_parameters.go @@ -87,7 +87,7 @@ type GetReportLogParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` diff --git a/pkg/harbor/client/scan/get_report_log_responses.go b/pkg/harbor/client/scan/get_report_log_responses.go index 8b2f804..851293d 100644 --- a/pkg/harbor/client/scan/get_report_log_responses.go +++ b/pkg/harbor/client/scan/get_report_log_responses.go @@ -29,6 +29,12 @@ func (o *GetReportLogReader) ReadResponse(response runtime.ClientResponse, consu return nil, err } return result, nil + case 400: + result := NewGetReportLogBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 401: result := NewGetReportLogUnauthorized() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -124,6 +130,86 @@ func (o *GetReportLogOK) readResponse(response runtime.ClientResponse, consumer return nil } +// NewGetReportLogBadRequest creates a GetReportLogBadRequest with default headers values +func NewGetReportLogBadRequest() *GetReportLogBadRequest { + return &GetReportLogBadRequest{} +} + +/* +GetReportLogBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type GetReportLogBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get report log bad request response has a 2xx status code +func (o *GetReportLogBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get report log bad request response has a 3xx status code +func (o *GetReportLogBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get report log bad request response has a 4xx status code +func (o *GetReportLogBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this get report log bad request response has a 5xx status code +func (o *GetReportLogBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this get report log bad request response a status code equal to that given +func (o *GetReportLogBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the get report log bad request response +func (o *GetReportLogBadRequest) Code() int { + return 400 +} + +func (o *GetReportLogBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log][%d] getReportLogBadRequest %+v", 400, o.Payload) +} + +func (o *GetReportLogBadRequest) String() string { + return fmt.Sprintf("[GET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log][%d] getReportLogBadRequest %+v", 400, o.Payload) +} + +func (o *GetReportLogBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetReportLogBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewGetReportLogUnauthorized creates a GetReportLogUnauthorized with default headers values func NewGetReportLogUnauthorized() *GetReportLogUnauthorized { return &GetReportLogUnauthorized{} diff --git a/pkg/harbor/client/scan/scan_artifact_parameters.go b/pkg/harbor/client/scan/scan_artifact_parameters.go index 0c68bef..bf27459 100644 --- a/pkg/harbor/client/scan/scan_artifact_parameters.go +++ b/pkg/harbor/client/scan/scan_artifact_parameters.go @@ -14,6 +14,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" ) // NewScanArtifactParams creates a new ScanArtifactParams object, @@ -81,10 +83,13 @@ type ScanArtifactParams struct { /* RepositoryName. - The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb */ RepositoryName string `js:"repositoryName"` + // ScanType. + ScanType *models.ScanType `js:"scanType"` + timeout time.Duration Context context.Context `js:"context"` HTTPClient *http.Client `js:"httpClient"` @@ -182,6 +187,17 @@ func (o *ScanArtifactParams) SetRepositoryName(repositoryName string) { o.RepositoryName = repositoryName } +// WithScanType adds the scanType to the scan artifact params +func (o *ScanArtifactParams) WithScanType(scanType *models.ScanType) *ScanArtifactParams { + o.SetScanType(scanType) + return o +} + +// SetScanType adds the scanType to the scan artifact params +func (o *ScanArtifactParams) SetScanType(scanType *models.ScanType) { + o.ScanType = scanType +} + // WriteToRequest writes these params to a swagger request func (o *ScanArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -212,6 +228,11 @@ func (o *ScanArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. if err := r.SetPathParam("repository_name", o.RepositoryName); err != nil { return err } + if o.ScanType != nil { + if err := r.SetBodyParam(o.ScanType); err != nil { + return err + } + } if len(res) > 0 { return errors.CompositeValidationError(res...) diff --git a/pkg/harbor/client/scan/scan_artifact_responses.go b/pkg/harbor/client/scan/scan_artifact_responses.go index 17750fb..3113f4c 100644 --- a/pkg/harbor/client/scan/scan_artifact_responses.go +++ b/pkg/harbor/client/scan/scan_artifact_responses.go @@ -53,6 +53,12 @@ func (o *ScanArtifactReader) ReadResponse(response runtime.ClientResponse, consu return nil, err } return nil, result + case 422: + result := NewScanArtifactUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 500: result := NewScanArtifactInternalServerError() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -451,6 +457,86 @@ func (o *ScanArtifactNotFound) readResponse(response runtime.ClientResponse, con return nil } +// NewScanArtifactUnprocessableEntity creates a ScanArtifactUnprocessableEntity with default headers values +func NewScanArtifactUnprocessableEntity() *ScanArtifactUnprocessableEntity { + return &ScanArtifactUnprocessableEntity{} +} + +/* +ScanArtifactUnprocessableEntity describes a response with status code 422, with default header values. + +Unsupported Type +*/ +type ScanArtifactUnprocessableEntity struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this scan artifact unprocessable entity response has a 2xx status code +func (o *ScanArtifactUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this scan artifact unprocessable entity response has a 3xx status code +func (o *ScanArtifactUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this scan artifact unprocessable entity response has a 4xx status code +func (o *ScanArtifactUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this scan artifact unprocessable entity response has a 5xx status code +func (o *ScanArtifactUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this scan artifact unprocessable entity response a status code equal to that given +func (o *ScanArtifactUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the scan artifact unprocessable entity response +func (o *ScanArtifactUnprocessableEntity) Code() int { + return 422 +} + +func (o *ScanArtifactUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan][%d] scanArtifactUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *ScanArtifactUnprocessableEntity) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan][%d] scanArtifactUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *ScanArtifactUnprocessableEntity) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ScanArtifactUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewScanArtifactInternalServerError creates a ScanArtifactInternalServerError with default headers values func NewScanArtifactInternalServerError() *ScanArtifactInternalServerError { return &ScanArtifactInternalServerError{} diff --git a/pkg/harbor/client/scan/scan_client.go b/pkg/harbor/client/scan/scan_client.go index 3650993..898a45d 100644 --- a/pkg/harbor/client/scan/scan_client.go +++ b/pkg/harbor/client/scan/scan_client.go @@ -28,6 +28,11 @@ type API interface { Scan the specified artifact*/ ScanArtifact(ctx context.Context, params *ScanArtifactParams) (*ScanArtifactAccepted, error) + /* + StopScanArtifact cancellings a scan job for a particular artifact + + Cancelling a scan job for a particular artifact*/ + StopScanArtifact(ctx context.Context, params *StopScanArtifactParams) (*StopScanArtifactAccepted, error) } // New creates a new scan API client. @@ -74,6 +79,8 @@ func (a *Client) GetReportLog(ctx context.Context, params *GetReportLogParams) ( switch value := result.(type) { case *GetReportLogOK: return value, nil + case *GetReportLogBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *GetReportLogUnauthorized: return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *GetReportLogForbidden: @@ -122,6 +129,8 @@ func (a *Client) ScanArtifact(ctx context.Context, params *ScanArtifactParams) ( return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *ScanArtifactNotFound: return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ScanArtifactUnprocessableEntity: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) case *ScanArtifactInternalServerError: return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) } @@ -129,3 +138,47 @@ func (a *Client) ScanArtifact(ctx context.Context, params *ScanArtifactParams) ( msg := fmt.Sprintf("unexpected success response for scanArtifact: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } + +/* +StopScanArtifact cancellings a scan job for a particular artifact + +Cancelling a scan job for a particular artifact +*/ +func (a *Client) StopScanArtifact(ctx context.Context, params *StopScanArtifactParams) (*StopScanArtifactAccepted, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "stopScanArtifact", + Method: "POST", + PathPattern: "/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StopScanArtifactReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *StopScanArtifactAccepted: + return value, nil + case *StopScanArtifactBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanArtifactUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanArtifactForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanArtifactNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanArtifactUnprocessableEntity: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanArtifactInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for stopScanArtifact: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/scan/stop_scan_artifact_parameters.go b/pkg/harbor/client/scan/stop_scan_artifact_parameters.go new file mode 100644 index 0000000..6ea4418 --- /dev/null +++ b/pkg/harbor/client/scan/stop_scan_artifact_parameters.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// NewStopScanArtifactParams creates a new StopScanArtifactParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStopScanArtifactParams() *StopScanArtifactParams { + return &StopScanArtifactParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStopScanArtifactParamsWithTimeout creates a new StopScanArtifactParams object +// with the ability to set a timeout on a request. +func NewStopScanArtifactParamsWithTimeout(timeout time.Duration) *StopScanArtifactParams { + return &StopScanArtifactParams{ + timeout: timeout, + } +} + +// NewStopScanArtifactParamsWithContext creates a new StopScanArtifactParams object +// with the ability to set a context for a request. +func NewStopScanArtifactParamsWithContext(ctx context.Context) *StopScanArtifactParams { + return &StopScanArtifactParams{ + Context: ctx, + } +} + +// NewStopScanArtifactParamsWithHTTPClient creates a new StopScanArtifactParams object +// with the ability to set a custom HTTPClient for a request. +func NewStopScanArtifactParamsWithHTTPClient(client *http.Client) *StopScanArtifactParams { + return &StopScanArtifactParams{ + HTTPClient: client, + } +} + +/* +StopScanArtifactParams contains all the parameters to send to the API endpoint + + for the stop scan artifact operation. + + Typically these are written to a http.Request. +*/ +type StopScanArtifactParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* ProjectName. + + The name of the project + */ + ProjectName string `js:"projectName"` + + /* Reference. + + The reference of the artifact, can be digest or tag + */ + Reference string `js:"reference"` + + /* RepositoryName. + + The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb + */ + RepositoryName string `js:"repositoryName"` + + /* ScanType. + + The scan type: Vulnerabilities, SBOM + */ + ScanType *models.ScanType `js:"scanType"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the stop scan artifact params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopScanArtifactParams) WithDefaults() *StopScanArtifactParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the stop scan artifact params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopScanArtifactParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the stop scan artifact params +func (o *StopScanArtifactParams) WithTimeout(timeout time.Duration) *StopScanArtifactParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the stop scan artifact params +func (o *StopScanArtifactParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the stop scan artifact params +func (o *StopScanArtifactParams) WithContext(ctx context.Context) *StopScanArtifactParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the stop scan artifact params +func (o *StopScanArtifactParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the stop scan artifact params +func (o *StopScanArtifactParams) WithHTTPClient(client *http.Client) *StopScanArtifactParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the stop scan artifact params +func (o *StopScanArtifactParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the stop scan artifact params +func (o *StopScanArtifactParams) WithXRequestID(xRequestID *string) *StopScanArtifactParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop scan artifact params +func (o *StopScanArtifactParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithProjectName adds the projectName to the stop scan artifact params +func (o *StopScanArtifactParams) WithProjectName(projectName string) *StopScanArtifactParams { + o.SetProjectName(projectName) + return o +} + +// SetProjectName adds the projectName to the stop scan artifact params +func (o *StopScanArtifactParams) SetProjectName(projectName string) { + o.ProjectName = projectName +} + +// WithReference adds the reference to the stop scan artifact params +func (o *StopScanArtifactParams) WithReference(reference string) *StopScanArtifactParams { + o.SetReference(reference) + return o +} + +// SetReference adds the reference to the stop scan artifact params +func (o *StopScanArtifactParams) SetReference(reference string) { + o.Reference = reference +} + +// WithRepositoryName adds the repositoryName to the stop scan artifact params +func (o *StopScanArtifactParams) WithRepositoryName(repositoryName string) *StopScanArtifactParams { + o.SetRepositoryName(repositoryName) + return o +} + +// SetRepositoryName adds the repositoryName to the stop scan artifact params +func (o *StopScanArtifactParams) SetRepositoryName(repositoryName string) { + o.RepositoryName = repositoryName +} + +// WithScanType adds the scanType to the stop scan artifact params +func (o *StopScanArtifactParams) WithScanType(scanType *models.ScanType) *StopScanArtifactParams { + o.SetScanType(scanType) + return o +} + +// SetScanType adds the scanType to the stop scan artifact params +func (o *StopScanArtifactParams) SetScanType(scanType *models.ScanType) { + o.ScanType = scanType +} + +// WriteToRequest writes these params to a swagger request +func (o *StopScanArtifactParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param project_name + if err := r.SetPathParam("project_name", o.ProjectName); err != nil { + return err + } + + // path param reference + if err := r.SetPathParam("reference", o.Reference); err != nil { + return err + } + + // path param repository_name + if err := r.SetPathParam("repository_name", o.RepositoryName); err != nil { + return err + } + if o.ScanType != nil { + if err := r.SetBodyParam(o.ScanType); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan/stop_scan_artifact_responses.go b/pkg/harbor/client/scan/stop_scan_artifact_responses.go new file mode 100644 index 0000000..aabddf2 --- /dev/null +++ b/pkg/harbor/client/scan/stop_scan_artifact_responses.go @@ -0,0 +1,618 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// StopScanArtifactReader is a Reader for the StopScanArtifact structure. +type StopScanArtifactReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StopScanArtifactReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewStopScanArtifactAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewStopScanArtifactBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewStopScanArtifactUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewStopScanArtifactForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewStopScanArtifactNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewStopScanArtifactUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewStopScanArtifactInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop] stopScanArtifact", response, response.Code()) + } +} + +// NewStopScanArtifactAccepted creates a StopScanArtifactAccepted with default headers values +func NewStopScanArtifactAccepted() *StopScanArtifactAccepted { + return &StopScanArtifactAccepted{} +} + +/* +StopScanArtifactAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type StopScanArtifactAccepted struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string +} + +// IsSuccess returns true when this stop scan artifact accepted response has a 2xx status code +func (o *StopScanArtifactAccepted) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this stop scan artifact accepted response has a 3xx status code +func (o *StopScanArtifactAccepted) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact accepted response has a 4xx status code +func (o *StopScanArtifactAccepted) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop scan artifact accepted response has a 5xx status code +func (o *StopScanArtifactAccepted) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact accepted response a status code equal to that given +func (o *StopScanArtifactAccepted) IsCode(code int) bool { + return code == 202 +} + +// Code gets the status code for the stop scan artifact accepted response +func (o *StopScanArtifactAccepted) Code() int { + return 202 +} + +func (o *StopScanArtifactAccepted) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactAccepted ", 202) +} + +func (o *StopScanArtifactAccepted) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactAccepted ", 202) +} + +func (o *StopScanArtifactAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + return nil +} + +// NewStopScanArtifactBadRequest creates a StopScanArtifactBadRequest with default headers values +func NewStopScanArtifactBadRequest() *StopScanArtifactBadRequest { + return &StopScanArtifactBadRequest{} +} + +/* +StopScanArtifactBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type StopScanArtifactBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact bad request response has a 2xx status code +func (o *StopScanArtifactBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact bad request response has a 3xx status code +func (o *StopScanArtifactBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact bad request response has a 4xx status code +func (o *StopScanArtifactBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan artifact bad request response has a 5xx status code +func (o *StopScanArtifactBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact bad request response a status code equal to that given +func (o *StopScanArtifactBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the stop scan artifact bad request response +func (o *StopScanArtifactBadRequest) Code() int { + return 400 +} + +func (o *StopScanArtifactBadRequest) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactBadRequest %+v", 400, o.Payload) +} + +func (o *StopScanArtifactBadRequest) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactBadRequest %+v", 400, o.Payload) +} + +func (o *StopScanArtifactBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanArtifactUnauthorized creates a StopScanArtifactUnauthorized with default headers values +func NewStopScanArtifactUnauthorized() *StopScanArtifactUnauthorized { + return &StopScanArtifactUnauthorized{} +} + +/* +StopScanArtifactUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type StopScanArtifactUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact unauthorized response has a 2xx status code +func (o *StopScanArtifactUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact unauthorized response has a 3xx status code +func (o *StopScanArtifactUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact unauthorized response has a 4xx status code +func (o *StopScanArtifactUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan artifact unauthorized response has a 5xx status code +func (o *StopScanArtifactUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact unauthorized response a status code equal to that given +func (o *StopScanArtifactUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the stop scan artifact unauthorized response +func (o *StopScanArtifactUnauthorized) Code() int { + return 401 +} + +func (o *StopScanArtifactUnauthorized) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactUnauthorized %+v", 401, o.Payload) +} + +func (o *StopScanArtifactUnauthorized) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactUnauthorized %+v", 401, o.Payload) +} + +func (o *StopScanArtifactUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanArtifactForbidden creates a StopScanArtifactForbidden with default headers values +func NewStopScanArtifactForbidden() *StopScanArtifactForbidden { + return &StopScanArtifactForbidden{} +} + +/* +StopScanArtifactForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type StopScanArtifactForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact forbidden response has a 2xx status code +func (o *StopScanArtifactForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact forbidden response has a 3xx status code +func (o *StopScanArtifactForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact forbidden response has a 4xx status code +func (o *StopScanArtifactForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan artifact forbidden response has a 5xx status code +func (o *StopScanArtifactForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact forbidden response a status code equal to that given +func (o *StopScanArtifactForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the stop scan artifact forbidden response +func (o *StopScanArtifactForbidden) Code() int { + return 403 +} + +func (o *StopScanArtifactForbidden) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactForbidden %+v", 403, o.Payload) +} + +func (o *StopScanArtifactForbidden) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactForbidden %+v", 403, o.Payload) +} + +func (o *StopScanArtifactForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanArtifactNotFound creates a StopScanArtifactNotFound with default headers values +func NewStopScanArtifactNotFound() *StopScanArtifactNotFound { + return &StopScanArtifactNotFound{} +} + +/* +StopScanArtifactNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type StopScanArtifactNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact not found response has a 2xx status code +func (o *StopScanArtifactNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact not found response has a 3xx status code +func (o *StopScanArtifactNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact not found response has a 4xx status code +func (o *StopScanArtifactNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan artifact not found response has a 5xx status code +func (o *StopScanArtifactNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact not found response a status code equal to that given +func (o *StopScanArtifactNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the stop scan artifact not found response +func (o *StopScanArtifactNotFound) Code() int { + return 404 +} + +func (o *StopScanArtifactNotFound) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactNotFound %+v", 404, o.Payload) +} + +func (o *StopScanArtifactNotFound) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactNotFound %+v", 404, o.Payload) +} + +func (o *StopScanArtifactNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanArtifactUnprocessableEntity creates a StopScanArtifactUnprocessableEntity with default headers values +func NewStopScanArtifactUnprocessableEntity() *StopScanArtifactUnprocessableEntity { + return &StopScanArtifactUnprocessableEntity{} +} + +/* +StopScanArtifactUnprocessableEntity describes a response with status code 422, with default header values. + +Unsupported Type +*/ +type StopScanArtifactUnprocessableEntity struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact unprocessable entity response has a 2xx status code +func (o *StopScanArtifactUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact unprocessable entity response has a 3xx status code +func (o *StopScanArtifactUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact unprocessable entity response has a 4xx status code +func (o *StopScanArtifactUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan artifact unprocessable entity response has a 5xx status code +func (o *StopScanArtifactUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan artifact unprocessable entity response a status code equal to that given +func (o *StopScanArtifactUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the stop scan artifact unprocessable entity response +func (o *StopScanArtifactUnprocessableEntity) Code() int { + return 422 +} + +func (o *StopScanArtifactUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *StopScanArtifactUnprocessableEntity) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *StopScanArtifactUnprocessableEntity) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanArtifactInternalServerError creates a StopScanArtifactInternalServerError with default headers values +func NewStopScanArtifactInternalServerError() *StopScanArtifactInternalServerError { + return &StopScanArtifactInternalServerError{} +} + +/* +StopScanArtifactInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type StopScanArtifactInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan artifact internal server error response has a 2xx status code +func (o *StopScanArtifactInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan artifact internal server error response has a 3xx status code +func (o *StopScanArtifactInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan artifact internal server error response has a 4xx status code +func (o *StopScanArtifactInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop scan artifact internal server error response has a 5xx status code +func (o *StopScanArtifactInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this stop scan artifact internal server error response a status code equal to that given +func (o *StopScanArtifactInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the stop scan artifact internal server error response +func (o *StopScanArtifactInternalServerError) Code() int { + return 500 +} + +func (o *StopScanArtifactInternalServerError) Error() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactInternalServerError %+v", 500, o.Payload) +} + +func (o *StopScanArtifactInternalServerError) String() string { + return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop][%d] stopScanArtifactInternalServerError %+v", 500, o.Payload) +} + +func (o *StopScanArtifactInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanArtifactInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_all/create_scan_all_schedule_parameters.go b/pkg/harbor/client/scan_all/create_scan_all_schedule_parameters.go index 01dd555..cee6cd8 100644 --- a/pkg/harbor/client/scan_all/create_scan_all_schedule_parameters.go +++ b/pkg/harbor/client/scan_all/create_scan_all_schedule_parameters.go @@ -63,6 +63,12 @@ CreateScanAllScheduleParams contains all the parameters to send to the API endpo */ type CreateScanAllScheduleParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Schedule. Create a schedule or a manual trigger for the scan all job. @@ -122,6 +128,17 @@ func (o *CreateScanAllScheduleParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the create scan all schedule params +func (o *CreateScanAllScheduleParams) WithXRequestID(xRequestID *string) *CreateScanAllScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the create scan all schedule params +func (o *CreateScanAllScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithSchedule adds the schedule to the create scan all schedule params func (o *CreateScanAllScheduleParams) WithSchedule(schedule *models.Schedule) *CreateScanAllScheduleParams { o.SetSchedule(schedule) @@ -140,6 +157,14 @@ func (o *CreateScanAllScheduleParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Schedule != nil { if err := r.SetBodyParam(o.Schedule); err != nil { return err diff --git a/pkg/harbor/client/scan_all/scan_all_client.go b/pkg/harbor/client/scan_all/scan_all_client.go index 842555a..9055ceb 100644 --- a/pkg/harbor/client/scan_all/scan_all_client.go +++ b/pkg/harbor/client/scan_all/scan_all_client.go @@ -38,6 +38,11 @@ type API interface { This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor.*/ GetScanAllSchedule(ctx context.Context, params *GetScanAllScheduleParams) (*GetScanAllScheduleOK, error) + /* + StopScanAll stops scan all job execution + + Stop scanAll job execution*/ + StopScanAll(ctx context.Context, params *StopScanAllParams) (*StopScanAllAccepted, error) /* UpdateScanAllSchedule updates scan all s schedule @@ -227,6 +232,46 @@ func (a *Client) GetScanAllSchedule(ctx context.Context, params *GetScanAllSched panic(msg) } +/* +StopScanAll stops scan all job execution + +Stop scanAll job execution +*/ +func (a *Client) StopScanAll(ctx context.Context, params *StopScanAllParams) (*StopScanAllAccepted, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "stopScanAll", + Method: "POST", + PathPattern: "/system/scanAll/stop", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StopScanAllReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *StopScanAllAccepted: + return value, nil + case *StopScanAllBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanAllUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanAllForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *StopScanAllInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for stopScanAll: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* UpdateScanAllSchedule updates scan all s schedule diff --git a/pkg/harbor/client/scan_all/stop_scan_all_parameters.go b/pkg/harbor/client/scan_all/stop_scan_all_parameters.go new file mode 100644 index 0000000..70e1c41 --- /dev/null +++ b/pkg/harbor/client/scan_all/stop_scan_all_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewStopScanAllParams creates a new StopScanAllParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStopScanAllParams() *StopScanAllParams { + return &StopScanAllParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStopScanAllParamsWithTimeout creates a new StopScanAllParams object +// with the ability to set a timeout on a request. +func NewStopScanAllParamsWithTimeout(timeout time.Duration) *StopScanAllParams { + return &StopScanAllParams{ + timeout: timeout, + } +} + +// NewStopScanAllParamsWithContext creates a new StopScanAllParams object +// with the ability to set a context for a request. +func NewStopScanAllParamsWithContext(ctx context.Context) *StopScanAllParams { + return &StopScanAllParams{ + Context: ctx, + } +} + +// NewStopScanAllParamsWithHTTPClient creates a new StopScanAllParams object +// with the ability to set a custom HTTPClient for a request. +func NewStopScanAllParamsWithHTTPClient(client *http.Client) *StopScanAllParams { + return &StopScanAllParams{ + HTTPClient: client, + } +} + +/* +StopScanAllParams contains all the parameters to send to the API endpoint + + for the stop scan all operation. + + Typically these are written to a http.Request. +*/ +type StopScanAllParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the stop scan all params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopScanAllParams) WithDefaults() *StopScanAllParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the stop scan all params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StopScanAllParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the stop scan all params +func (o *StopScanAllParams) WithTimeout(timeout time.Duration) *StopScanAllParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the stop scan all params +func (o *StopScanAllParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the stop scan all params +func (o *StopScanAllParams) WithContext(ctx context.Context) *StopScanAllParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the stop scan all params +func (o *StopScanAllParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the stop scan all params +func (o *StopScanAllParams) WithHTTPClient(client *http.Client) *StopScanAllParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the stop scan all params +func (o *StopScanAllParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the stop scan all params +func (o *StopScanAllParams) WithXRequestID(xRequestID *string) *StopScanAllParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the stop scan all params +func (o *StopScanAllParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *StopScanAllParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan_all/stop_scan_all_responses.go b/pkg/harbor/client/scan_all/stop_scan_all_responses.go new file mode 100644 index 0000000..489c463 --- /dev/null +++ b/pkg/harbor/client/scan_all/stop_scan_all_responses.go @@ -0,0 +1,446 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_all + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// StopScanAllReader is a Reader for the StopScanAll structure. +type StopScanAllReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StopScanAllReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 202: + result := NewStopScanAllAccepted() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewStopScanAllBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewStopScanAllUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewStopScanAllForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewStopScanAllInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /system/scanAll/stop] stopScanAll", response, response.Code()) + } +} + +// NewStopScanAllAccepted creates a StopScanAllAccepted with default headers values +func NewStopScanAllAccepted() *StopScanAllAccepted { + return &StopScanAllAccepted{} +} + +/* +StopScanAllAccepted describes a response with status code 202, with default header values. + +Accepted +*/ +type StopScanAllAccepted struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string +} + +// IsSuccess returns true when this stop scan all accepted response has a 2xx status code +func (o *StopScanAllAccepted) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this stop scan all accepted response has a 3xx status code +func (o *StopScanAllAccepted) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan all accepted response has a 4xx status code +func (o *StopScanAllAccepted) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop scan all accepted response has a 5xx status code +func (o *StopScanAllAccepted) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan all accepted response a status code equal to that given +func (o *StopScanAllAccepted) IsCode(code int) bool { + return code == 202 +} + +// Code gets the status code for the stop scan all accepted response +func (o *StopScanAllAccepted) Code() int { + return 202 +} + +func (o *StopScanAllAccepted) Error() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllAccepted ", 202) +} + +func (o *StopScanAllAccepted) String() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllAccepted ", 202) +} + +func (o *StopScanAllAccepted) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + return nil +} + +// NewStopScanAllBadRequest creates a StopScanAllBadRequest with default headers values +func NewStopScanAllBadRequest() *StopScanAllBadRequest { + return &StopScanAllBadRequest{} +} + +/* +StopScanAllBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type StopScanAllBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan all bad request response has a 2xx status code +func (o *StopScanAllBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan all bad request response has a 3xx status code +func (o *StopScanAllBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan all bad request response has a 4xx status code +func (o *StopScanAllBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan all bad request response has a 5xx status code +func (o *StopScanAllBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan all bad request response a status code equal to that given +func (o *StopScanAllBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the stop scan all bad request response +func (o *StopScanAllBadRequest) Code() int { + return 400 +} + +func (o *StopScanAllBadRequest) Error() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllBadRequest %+v", 400, o.Payload) +} + +func (o *StopScanAllBadRequest) String() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllBadRequest %+v", 400, o.Payload) +} + +func (o *StopScanAllBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanAllBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanAllUnauthorized creates a StopScanAllUnauthorized with default headers values +func NewStopScanAllUnauthorized() *StopScanAllUnauthorized { + return &StopScanAllUnauthorized{} +} + +/* +StopScanAllUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type StopScanAllUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan all unauthorized response has a 2xx status code +func (o *StopScanAllUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan all unauthorized response has a 3xx status code +func (o *StopScanAllUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan all unauthorized response has a 4xx status code +func (o *StopScanAllUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan all unauthorized response has a 5xx status code +func (o *StopScanAllUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan all unauthorized response a status code equal to that given +func (o *StopScanAllUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the stop scan all unauthorized response +func (o *StopScanAllUnauthorized) Code() int { + return 401 +} + +func (o *StopScanAllUnauthorized) Error() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllUnauthorized %+v", 401, o.Payload) +} + +func (o *StopScanAllUnauthorized) String() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllUnauthorized %+v", 401, o.Payload) +} + +func (o *StopScanAllUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanAllUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanAllForbidden creates a StopScanAllForbidden with default headers values +func NewStopScanAllForbidden() *StopScanAllForbidden { + return &StopScanAllForbidden{} +} + +/* +StopScanAllForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type StopScanAllForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan all forbidden response has a 2xx status code +func (o *StopScanAllForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan all forbidden response has a 3xx status code +func (o *StopScanAllForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan all forbidden response has a 4xx status code +func (o *StopScanAllForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this stop scan all forbidden response has a 5xx status code +func (o *StopScanAllForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this stop scan all forbidden response a status code equal to that given +func (o *StopScanAllForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the stop scan all forbidden response +func (o *StopScanAllForbidden) Code() int { + return 403 +} + +func (o *StopScanAllForbidden) Error() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllForbidden %+v", 403, o.Payload) +} + +func (o *StopScanAllForbidden) String() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllForbidden %+v", 403, o.Payload) +} + +func (o *StopScanAllForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanAllForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStopScanAllInternalServerError creates a StopScanAllInternalServerError with default headers values +func NewStopScanAllInternalServerError() *StopScanAllInternalServerError { + return &StopScanAllInternalServerError{} +} + +/* +StopScanAllInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type StopScanAllInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this stop scan all internal server error response has a 2xx status code +func (o *StopScanAllInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this stop scan all internal server error response has a 3xx status code +func (o *StopScanAllInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this stop scan all internal server error response has a 4xx status code +func (o *StopScanAllInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this stop scan all internal server error response has a 5xx status code +func (o *StopScanAllInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this stop scan all internal server error response a status code equal to that given +func (o *StopScanAllInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the stop scan all internal server error response +func (o *StopScanAllInternalServerError) Code() int { + return 500 +} + +func (o *StopScanAllInternalServerError) Error() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllInternalServerError %+v", 500, o.Payload) +} + +func (o *StopScanAllInternalServerError) String() string { + return fmt.Sprintf("[POST /system/scanAll/stop][%d] stopScanAllInternalServerError %+v", 500, o.Payload) +} + +func (o *StopScanAllInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *StopScanAllInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_all/update_scan_all_schedule_parameters.go b/pkg/harbor/client/scan_all/update_scan_all_schedule_parameters.go index 6e6576c..f2b69cb 100644 --- a/pkg/harbor/client/scan_all/update_scan_all_schedule_parameters.go +++ b/pkg/harbor/client/scan_all/update_scan_all_schedule_parameters.go @@ -63,6 +63,12 @@ UpdateScanAllScheduleParams contains all the parameters to send to the API endpo */ type UpdateScanAllScheduleParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Schedule. Updates the schedule of scan all job, which scans all of images in Harbor. @@ -122,6 +128,17 @@ func (o *UpdateScanAllScheduleParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the update scan all schedule params +func (o *UpdateScanAllScheduleParams) WithXRequestID(xRequestID *string) *UpdateScanAllScheduleParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the update scan all schedule params +func (o *UpdateScanAllScheduleParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithSchedule adds the schedule to the update scan all schedule params func (o *UpdateScanAllScheduleParams) WithSchedule(schedule *models.Schedule) *UpdateScanAllScheduleParams { o.SetSchedule(schedule) @@ -140,6 +157,14 @@ func (o *UpdateScanAllScheduleParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Schedule != nil { if err := r.SetBodyParam(o.Schedule); err != nil { return err diff --git a/pkg/harbor/client/scan_data_export/download_scan_data_parameters.go b/pkg/harbor/client/scan_data_export/download_scan_data_parameters.go new file mode 100644 index 0000000..41b3469 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/download_scan_data_parameters.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDownloadScanDataParams creates a new DownloadScanDataParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDownloadScanDataParams() *DownloadScanDataParams { + return &DownloadScanDataParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDownloadScanDataParamsWithTimeout creates a new DownloadScanDataParams object +// with the ability to set a timeout on a request. +func NewDownloadScanDataParamsWithTimeout(timeout time.Duration) *DownloadScanDataParams { + return &DownloadScanDataParams{ + timeout: timeout, + } +} + +// NewDownloadScanDataParamsWithContext creates a new DownloadScanDataParams object +// with the ability to set a context for a request. +func NewDownloadScanDataParamsWithContext(ctx context.Context) *DownloadScanDataParams { + return &DownloadScanDataParams{ + Context: ctx, + } +} + +// NewDownloadScanDataParamsWithHTTPClient creates a new DownloadScanDataParams object +// with the ability to set a custom HTTPClient for a request. +func NewDownloadScanDataParamsWithHTTPClient(client *http.Client) *DownloadScanDataParams { + return &DownloadScanDataParams{ + HTTPClient: client, + } +} + +/* +DownloadScanDataParams contains all the parameters to send to the API endpoint + + for the download scan data operation. + + Typically these are written to a http.Request. +*/ +type DownloadScanDataParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* ExecutionID. + + Execution ID + */ + ExecutionID int64 `js:"executionID"` + + /* Format. + + The format of the data to be exported. e.g. CSV or PDF + */ + Format *string `js:"format"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the download scan data params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DownloadScanDataParams) WithDefaults() *DownloadScanDataParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the download scan data params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DownloadScanDataParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the download scan data params +func (o *DownloadScanDataParams) WithTimeout(timeout time.Duration) *DownloadScanDataParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the download scan data params +func (o *DownloadScanDataParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the download scan data params +func (o *DownloadScanDataParams) WithContext(ctx context.Context) *DownloadScanDataParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the download scan data params +func (o *DownloadScanDataParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the download scan data params +func (o *DownloadScanDataParams) WithHTTPClient(client *http.Client) *DownloadScanDataParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the download scan data params +func (o *DownloadScanDataParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the download scan data params +func (o *DownloadScanDataParams) WithXRequestID(xRequestID *string) *DownloadScanDataParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the download scan data params +func (o *DownloadScanDataParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithExecutionID adds the executionID to the download scan data params +func (o *DownloadScanDataParams) WithExecutionID(executionID int64) *DownloadScanDataParams { + o.SetExecutionID(executionID) + return o +} + +// SetExecutionID adds the executionId to the download scan data params +func (o *DownloadScanDataParams) SetExecutionID(executionID int64) { + o.ExecutionID = executionID +} + +// WithFormat adds the format to the download scan data params +func (o *DownloadScanDataParams) WithFormat(format *string) *DownloadScanDataParams { + o.SetFormat(format) + return o +} + +// SetFormat adds the format to the download scan data params +func (o *DownloadScanDataParams) SetFormat(format *string) { + o.Format = format +} + +// WriteToRequest writes these params to a swagger request +func (o *DownloadScanDataParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param execution_id + if err := r.SetPathParam("execution_id", swag.FormatInt64(o.ExecutionID)); err != nil { + return err + } + + if o.Format != nil { + + // query param format + var qrFormat string + + if o.Format != nil { + qrFormat = *o.Format + } + qFormat := qrFormat + if qFormat != "" { + + if err := r.SetQueryParam("format", qFormat); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan_data_export/download_scan_data_responses.go b/pkg/harbor/client/scan_data_export/download_scan_data_responses.go new file mode 100644 index 0000000..071c2b8 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/download_scan_data_responses.go @@ -0,0 +1,461 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// DownloadScanDataReader is a Reader for the DownloadScanData structure. +type DownloadScanDataReader struct { + formats strfmt.Registry + writer io.Writer +} + +// ReadResponse reads a server response into the received o. +func (o *DownloadScanDataReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDownloadScanDataOK(o.writer) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewDownloadScanDataUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewDownloadScanDataForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewDownloadScanDataNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewDownloadScanDataInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /export/cve/download/{execution_id}] downloadScanData", response, response.Code()) + } +} + +// NewDownloadScanDataOK creates a DownloadScanDataOK with default headers values +func NewDownloadScanDataOK(writer io.Writer) *DownloadScanDataOK { + return &DownloadScanDataOK{ + + Payload: writer, + } +} + +/* +DownloadScanDataOK describes a response with status code 200, with default header values. + +Data file containing the export data +*/ +type DownloadScanDataOK struct { + + /* Value is a CSV formatted file; filename=export.csv + */ + ContentDisposition string + + Payload io.Writer +} + +// IsSuccess returns true when this download scan data o k response has a 2xx status code +func (o *DownloadScanDataOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this download scan data o k response has a 3xx status code +func (o *DownloadScanDataOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this download scan data o k response has a 4xx status code +func (o *DownloadScanDataOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this download scan data o k response has a 5xx status code +func (o *DownloadScanDataOK) IsServerError() bool { + return false +} + +// IsCode returns true when this download scan data o k response a status code equal to that given +func (o *DownloadScanDataOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the download scan data o k response +func (o *DownloadScanDataOK) Code() int { + return 200 +} + +func (o *DownloadScanDataOK) Error() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataOK %+v", 200, o.Payload) +} + +func (o *DownloadScanDataOK) String() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataOK %+v", 200, o.Payload) +} + +func (o *DownloadScanDataOK) GetPayload() io.Writer { + return o.Payload +} + +func (o *DownloadScanDataOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Content-Disposition + hdrContentDisposition := response.GetHeader("Content-Disposition") + + if hdrContentDisposition != "" { + o.ContentDisposition = hdrContentDisposition + } + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDownloadScanDataUnauthorized creates a DownloadScanDataUnauthorized with default headers values +func NewDownloadScanDataUnauthorized() *DownloadScanDataUnauthorized { + return &DownloadScanDataUnauthorized{} +} + +/* +DownloadScanDataUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type DownloadScanDataUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this download scan data unauthorized response has a 2xx status code +func (o *DownloadScanDataUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this download scan data unauthorized response has a 3xx status code +func (o *DownloadScanDataUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this download scan data unauthorized response has a 4xx status code +func (o *DownloadScanDataUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this download scan data unauthorized response has a 5xx status code +func (o *DownloadScanDataUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this download scan data unauthorized response a status code equal to that given +func (o *DownloadScanDataUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the download scan data unauthorized response +func (o *DownloadScanDataUnauthorized) Code() int { + return 401 +} + +func (o *DownloadScanDataUnauthorized) Error() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataUnauthorized %+v", 401, o.Payload) +} + +func (o *DownloadScanDataUnauthorized) String() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataUnauthorized %+v", 401, o.Payload) +} + +func (o *DownloadScanDataUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *DownloadScanDataUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDownloadScanDataForbidden creates a DownloadScanDataForbidden with default headers values +func NewDownloadScanDataForbidden() *DownloadScanDataForbidden { + return &DownloadScanDataForbidden{} +} + +/* +DownloadScanDataForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type DownloadScanDataForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this download scan data forbidden response has a 2xx status code +func (o *DownloadScanDataForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this download scan data forbidden response has a 3xx status code +func (o *DownloadScanDataForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this download scan data forbidden response has a 4xx status code +func (o *DownloadScanDataForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this download scan data forbidden response has a 5xx status code +func (o *DownloadScanDataForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this download scan data forbidden response a status code equal to that given +func (o *DownloadScanDataForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the download scan data forbidden response +func (o *DownloadScanDataForbidden) Code() int { + return 403 +} + +func (o *DownloadScanDataForbidden) Error() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataForbidden %+v", 403, o.Payload) +} + +func (o *DownloadScanDataForbidden) String() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataForbidden %+v", 403, o.Payload) +} + +func (o *DownloadScanDataForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *DownloadScanDataForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDownloadScanDataNotFound creates a DownloadScanDataNotFound with default headers values +func NewDownloadScanDataNotFound() *DownloadScanDataNotFound { + return &DownloadScanDataNotFound{} +} + +/* +DownloadScanDataNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type DownloadScanDataNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this download scan data not found response has a 2xx status code +func (o *DownloadScanDataNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this download scan data not found response has a 3xx status code +func (o *DownloadScanDataNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this download scan data not found response has a 4xx status code +func (o *DownloadScanDataNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this download scan data not found response has a 5xx status code +func (o *DownloadScanDataNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this download scan data not found response a status code equal to that given +func (o *DownloadScanDataNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the download scan data not found response +func (o *DownloadScanDataNotFound) Code() int { + return 404 +} + +func (o *DownloadScanDataNotFound) Error() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataNotFound %+v", 404, o.Payload) +} + +func (o *DownloadScanDataNotFound) String() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataNotFound %+v", 404, o.Payload) +} + +func (o *DownloadScanDataNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *DownloadScanDataNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDownloadScanDataInternalServerError creates a DownloadScanDataInternalServerError with default headers values +func NewDownloadScanDataInternalServerError() *DownloadScanDataInternalServerError { + return &DownloadScanDataInternalServerError{} +} + +/* +DownloadScanDataInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type DownloadScanDataInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this download scan data internal server error response has a 2xx status code +func (o *DownloadScanDataInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this download scan data internal server error response has a 3xx status code +func (o *DownloadScanDataInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this download scan data internal server error response has a 4xx status code +func (o *DownloadScanDataInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this download scan data internal server error response has a 5xx status code +func (o *DownloadScanDataInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this download scan data internal server error response a status code equal to that given +func (o *DownloadScanDataInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the download scan data internal server error response +func (o *DownloadScanDataInternalServerError) Code() int { + return 500 +} + +func (o *DownloadScanDataInternalServerError) Error() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataInternalServerError %+v", 500, o.Payload) +} + +func (o *DownloadScanDataInternalServerError) String() string { + return fmt.Sprintf("[GET /export/cve/download/{execution_id}][%d] downloadScanDataInternalServerError %+v", 500, o.Payload) +} + +func (o *DownloadScanDataInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *DownloadScanDataInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_data_export/export_scan_data_parameters.go b/pkg/harbor/client/scan_data_export/export_scan_data_parameters.go new file mode 100644 index 0000000..0a6b225 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/export_scan_data_parameters.go @@ -0,0 +1,200 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// NewExportScanDataParams creates a new ExportScanDataParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewExportScanDataParams() *ExportScanDataParams { + return &ExportScanDataParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewExportScanDataParamsWithTimeout creates a new ExportScanDataParams object +// with the ability to set a timeout on a request. +func NewExportScanDataParamsWithTimeout(timeout time.Duration) *ExportScanDataParams { + return &ExportScanDataParams{ + timeout: timeout, + } +} + +// NewExportScanDataParamsWithContext creates a new ExportScanDataParams object +// with the ability to set a context for a request. +func NewExportScanDataParamsWithContext(ctx context.Context) *ExportScanDataParams { + return &ExportScanDataParams{ + Context: ctx, + } +} + +// NewExportScanDataParamsWithHTTPClient creates a new ExportScanDataParams object +// with the ability to set a custom HTTPClient for a request. +func NewExportScanDataParamsWithHTTPClient(client *http.Client) *ExportScanDataParams { + return &ExportScanDataParams{ + HTTPClient: client, + } +} + +/* +ExportScanDataParams contains all the parameters to send to the API endpoint + + for the export scan data operation. + + Typically these are written to a http.Request. +*/ +type ExportScanDataParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* XScanDataType. + + The type of scan data to export + */ + XScanDataType string `js:"xScanDataType"` + + /* Criteria. + + The criteria for the export + */ + Criteria *models.ScanDataExportRequest `js:"criteria"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the export scan data params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ExportScanDataParams) WithDefaults() *ExportScanDataParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the export scan data params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ExportScanDataParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the export scan data params +func (o *ExportScanDataParams) WithTimeout(timeout time.Duration) *ExportScanDataParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the export scan data params +func (o *ExportScanDataParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the export scan data params +func (o *ExportScanDataParams) WithContext(ctx context.Context) *ExportScanDataParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the export scan data params +func (o *ExportScanDataParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the export scan data params +func (o *ExportScanDataParams) WithHTTPClient(client *http.Client) *ExportScanDataParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the export scan data params +func (o *ExportScanDataParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the export scan data params +func (o *ExportScanDataParams) WithXRequestID(xRequestID *string) *ExportScanDataParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the export scan data params +func (o *ExportScanDataParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithXScanDataType adds the xScanDataType to the export scan data params +func (o *ExportScanDataParams) WithXScanDataType(xScanDataType string) *ExportScanDataParams { + o.SetXScanDataType(xScanDataType) + return o +} + +// SetXScanDataType adds the xScanDataType to the export scan data params +func (o *ExportScanDataParams) SetXScanDataType(xScanDataType string) { + o.XScanDataType = xScanDataType +} + +// WithCriteria adds the criteria to the export scan data params +func (o *ExportScanDataParams) WithCriteria(criteria *models.ScanDataExportRequest) *ExportScanDataParams { + o.SetCriteria(criteria) + return o +} + +// SetCriteria adds the criteria to the export scan data params +func (o *ExportScanDataParams) SetCriteria(criteria *models.ScanDataExportRequest) { + o.Criteria = criteria +} + +// WriteToRequest writes these params to a swagger request +func (o *ExportScanDataParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // header param X-Scan-Data-Type + if err := r.SetHeaderParam("X-Scan-Data-Type", o.XScanDataType); err != nil { + return err + } + if o.Criteria != nil { + if err := r.SetBodyParam(o.Criteria); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan_data_export/export_scan_data_responses.go b/pkg/harbor/client/scan_data_export/export_scan_data_responses.go new file mode 100644 index 0000000..e7aeeac --- /dev/null +++ b/pkg/harbor/client/scan_data_export/export_scan_data_responses.go @@ -0,0 +1,705 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ExportScanDataReader is a Reader for the ExportScanData structure. +type ExportScanDataReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ExportScanDataReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewExportScanDataOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewExportScanDataBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewExportScanDataUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewExportScanDataForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewExportScanDataNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 405: + result := NewExportScanDataMethodNotAllowed() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewExportScanDataConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewExportScanDataInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /export/cve] exportScanData", response, response.Code()) + } +} + +// NewExportScanDataOK creates a ExportScanDataOK with default headers values +func NewExportScanDataOK() *ExportScanDataOK { + return &ExportScanDataOK{} +} + +/* +ExportScanDataOK describes a response with status code 200, with default header values. + +Success. +*/ +type ExportScanDataOK struct { + Payload *models.ScanDataExportJob +} + +// IsSuccess returns true when this export scan data o k response has a 2xx status code +func (o *ExportScanDataOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this export scan data o k response has a 3xx status code +func (o *ExportScanDataOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data o k response has a 4xx status code +func (o *ExportScanDataOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this export scan data o k response has a 5xx status code +func (o *ExportScanDataOK) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data o k response a status code equal to that given +func (o *ExportScanDataOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the export scan data o k response +func (o *ExportScanDataOK) Code() int { + return 200 +} + +func (o *ExportScanDataOK) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataOK %+v", 200, o.Payload) +} + +func (o *ExportScanDataOK) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataOK %+v", 200, o.Payload) +} + +func (o *ExportScanDataOK) GetPayload() *models.ScanDataExportJob { + return o.Payload +} + +func (o *ExportScanDataOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ScanDataExportJob) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataBadRequest creates a ExportScanDataBadRequest with default headers values +func NewExportScanDataBadRequest() *ExportScanDataBadRequest { + return &ExportScanDataBadRequest{} +} + +/* +ExportScanDataBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type ExportScanDataBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data bad request response has a 2xx status code +func (o *ExportScanDataBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data bad request response has a 3xx status code +func (o *ExportScanDataBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data bad request response has a 4xx status code +func (o *ExportScanDataBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data bad request response has a 5xx status code +func (o *ExportScanDataBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data bad request response a status code equal to that given +func (o *ExportScanDataBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the export scan data bad request response +func (o *ExportScanDataBadRequest) Code() int { + return 400 +} + +func (o *ExportScanDataBadRequest) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataBadRequest %+v", 400, o.Payload) +} + +func (o *ExportScanDataBadRequest) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataBadRequest %+v", 400, o.Payload) +} + +func (o *ExportScanDataBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataUnauthorized creates a ExportScanDataUnauthorized with default headers values +func NewExportScanDataUnauthorized() *ExportScanDataUnauthorized { + return &ExportScanDataUnauthorized{} +} + +/* +ExportScanDataUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ExportScanDataUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data unauthorized response has a 2xx status code +func (o *ExportScanDataUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data unauthorized response has a 3xx status code +func (o *ExportScanDataUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data unauthorized response has a 4xx status code +func (o *ExportScanDataUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data unauthorized response has a 5xx status code +func (o *ExportScanDataUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data unauthorized response a status code equal to that given +func (o *ExportScanDataUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the export scan data unauthorized response +func (o *ExportScanDataUnauthorized) Code() int { + return 401 +} + +func (o *ExportScanDataUnauthorized) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataUnauthorized %+v", 401, o.Payload) +} + +func (o *ExportScanDataUnauthorized) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataUnauthorized %+v", 401, o.Payload) +} + +func (o *ExportScanDataUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataForbidden creates a ExportScanDataForbidden with default headers values +func NewExportScanDataForbidden() *ExportScanDataForbidden { + return &ExportScanDataForbidden{} +} + +/* +ExportScanDataForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ExportScanDataForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data forbidden response has a 2xx status code +func (o *ExportScanDataForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data forbidden response has a 3xx status code +func (o *ExportScanDataForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data forbidden response has a 4xx status code +func (o *ExportScanDataForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data forbidden response has a 5xx status code +func (o *ExportScanDataForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data forbidden response a status code equal to that given +func (o *ExportScanDataForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the export scan data forbidden response +func (o *ExportScanDataForbidden) Code() int { + return 403 +} + +func (o *ExportScanDataForbidden) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataForbidden %+v", 403, o.Payload) +} + +func (o *ExportScanDataForbidden) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataForbidden %+v", 403, o.Payload) +} + +func (o *ExportScanDataForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataNotFound creates a ExportScanDataNotFound with default headers values +func NewExportScanDataNotFound() *ExportScanDataNotFound { + return &ExportScanDataNotFound{} +} + +/* +ExportScanDataNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ExportScanDataNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data not found response has a 2xx status code +func (o *ExportScanDataNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data not found response has a 3xx status code +func (o *ExportScanDataNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data not found response has a 4xx status code +func (o *ExportScanDataNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data not found response has a 5xx status code +func (o *ExportScanDataNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data not found response a status code equal to that given +func (o *ExportScanDataNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the export scan data not found response +func (o *ExportScanDataNotFound) Code() int { + return 404 +} + +func (o *ExportScanDataNotFound) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataNotFound %+v", 404, o.Payload) +} + +func (o *ExportScanDataNotFound) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataNotFound %+v", 404, o.Payload) +} + +func (o *ExportScanDataNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataMethodNotAllowed creates a ExportScanDataMethodNotAllowed with default headers values +func NewExportScanDataMethodNotAllowed() *ExportScanDataMethodNotAllowed { + return &ExportScanDataMethodNotAllowed{} +} + +/* +ExportScanDataMethodNotAllowed describes a response with status code 405, with default header values. + +Method not allowed +*/ +type ExportScanDataMethodNotAllowed struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data method not allowed response has a 2xx status code +func (o *ExportScanDataMethodNotAllowed) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data method not allowed response has a 3xx status code +func (o *ExportScanDataMethodNotAllowed) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data method not allowed response has a 4xx status code +func (o *ExportScanDataMethodNotAllowed) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data method not allowed response has a 5xx status code +func (o *ExportScanDataMethodNotAllowed) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data method not allowed response a status code equal to that given +func (o *ExportScanDataMethodNotAllowed) IsCode(code int) bool { + return code == 405 +} + +// Code gets the status code for the export scan data method not allowed response +func (o *ExportScanDataMethodNotAllowed) Code() int { + return 405 +} + +func (o *ExportScanDataMethodNotAllowed) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataMethodNotAllowed %+v", 405, o.Payload) +} + +func (o *ExportScanDataMethodNotAllowed) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataMethodNotAllowed %+v", 405, o.Payload) +} + +func (o *ExportScanDataMethodNotAllowed) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataConflict creates a ExportScanDataConflict with default headers values +func NewExportScanDataConflict() *ExportScanDataConflict { + return &ExportScanDataConflict{} +} + +/* +ExportScanDataConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type ExportScanDataConflict struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data conflict response has a 2xx status code +func (o *ExportScanDataConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data conflict response has a 3xx status code +func (o *ExportScanDataConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data conflict response has a 4xx status code +func (o *ExportScanDataConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this export scan data conflict response has a 5xx status code +func (o *ExportScanDataConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this export scan data conflict response a status code equal to that given +func (o *ExportScanDataConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the export scan data conflict response +func (o *ExportScanDataConflict) Code() int { + return 409 +} + +func (o *ExportScanDataConflict) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataConflict %+v", 409, o.Payload) +} + +func (o *ExportScanDataConflict) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataConflict %+v", 409, o.Payload) +} + +func (o *ExportScanDataConflict) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewExportScanDataInternalServerError creates a ExportScanDataInternalServerError with default headers values +func NewExportScanDataInternalServerError() *ExportScanDataInternalServerError { + return &ExportScanDataInternalServerError{} +} + +/* +ExportScanDataInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ExportScanDataInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this export scan data internal server error response has a 2xx status code +func (o *ExportScanDataInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this export scan data internal server error response has a 3xx status code +func (o *ExportScanDataInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this export scan data internal server error response has a 4xx status code +func (o *ExportScanDataInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this export scan data internal server error response has a 5xx status code +func (o *ExportScanDataInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this export scan data internal server error response a status code equal to that given +func (o *ExportScanDataInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the export scan data internal server error response +func (o *ExportScanDataInternalServerError) Code() int { + return 500 +} + +func (o *ExportScanDataInternalServerError) Error() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataInternalServerError %+v", 500, o.Payload) +} + +func (o *ExportScanDataInternalServerError) String() string { + return fmt.Sprintf("[POST /export/cve][%d] exportScanDataInternalServerError %+v", 500, o.Payload) +} + +func (o *ExportScanDataInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ExportScanDataInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_parameters.go b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_parameters.go new file mode 100644 index 0000000..bad22ab --- /dev/null +++ b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_parameters.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetScanDataExportExecutionListParams creates a new GetScanDataExportExecutionListParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetScanDataExportExecutionListParams() *GetScanDataExportExecutionListParams { + return &GetScanDataExportExecutionListParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetScanDataExportExecutionListParamsWithTimeout creates a new GetScanDataExportExecutionListParams object +// with the ability to set a timeout on a request. +func NewGetScanDataExportExecutionListParamsWithTimeout(timeout time.Duration) *GetScanDataExportExecutionListParams { + return &GetScanDataExportExecutionListParams{ + timeout: timeout, + } +} + +// NewGetScanDataExportExecutionListParamsWithContext creates a new GetScanDataExportExecutionListParams object +// with the ability to set a context for a request. +func NewGetScanDataExportExecutionListParamsWithContext(ctx context.Context) *GetScanDataExportExecutionListParams { + return &GetScanDataExportExecutionListParams{ + Context: ctx, + } +} + +// NewGetScanDataExportExecutionListParamsWithHTTPClient creates a new GetScanDataExportExecutionListParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetScanDataExportExecutionListParamsWithHTTPClient(client *http.Client) *GetScanDataExportExecutionListParams { + return &GetScanDataExportExecutionListParams{ + HTTPClient: client, + } +} + +/* +GetScanDataExportExecutionListParams contains all the parameters to send to the API endpoint + + for the get scan data export execution list operation. + + Typically these are written to a http.Request. +*/ +type GetScanDataExportExecutionListParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get scan data export execution list params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetScanDataExportExecutionListParams) WithDefaults() *GetScanDataExportExecutionListParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get scan data export execution list params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetScanDataExportExecutionListParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) WithTimeout(timeout time.Duration) *GetScanDataExportExecutionListParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) WithContext(ctx context.Context) *GetScanDataExportExecutionListParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) WithHTTPClient(client *http.Client) *GetScanDataExportExecutionListParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) WithXRequestID(xRequestID *string) *GetScanDataExportExecutionListParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get scan data export execution list params +func (o *GetScanDataExportExecutionListParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetScanDataExportExecutionListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_responses.go b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_responses.go new file mode 100644 index 0000000..eeab9a4 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_list_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetScanDataExportExecutionListReader is a Reader for the GetScanDataExportExecutionList structure. +type GetScanDataExportExecutionListReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetScanDataExportExecutionListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetScanDataExportExecutionListOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetScanDataExportExecutionListUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetScanDataExportExecutionListForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetScanDataExportExecutionListNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetScanDataExportExecutionListInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /export/cve/executions] getScanDataExportExecutionList", response, response.Code()) + } +} + +// NewGetScanDataExportExecutionListOK creates a GetScanDataExportExecutionListOK with default headers values +func NewGetScanDataExportExecutionListOK() *GetScanDataExportExecutionListOK { + return &GetScanDataExportExecutionListOK{} +} + +/* +GetScanDataExportExecutionListOK describes a response with status code 200, with default header values. + +Success +*/ +type GetScanDataExportExecutionListOK struct { + Payload *models.ScanDataExportExecutionList +} + +// IsSuccess returns true when this get scan data export execution list o k response has a 2xx status code +func (o *GetScanDataExportExecutionListOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get scan data export execution list o k response has a 3xx status code +func (o *GetScanDataExportExecutionListOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution list o k response has a 4xx status code +func (o *GetScanDataExportExecutionListOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get scan data export execution list o k response has a 5xx status code +func (o *GetScanDataExportExecutionListOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution list o k response a status code equal to that given +func (o *GetScanDataExportExecutionListOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get scan data export execution list o k response +func (o *GetScanDataExportExecutionListOK) Code() int { + return 200 +} + +func (o *GetScanDataExportExecutionListOK) Error() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListOK %+v", 200, o.Payload) +} + +func (o *GetScanDataExportExecutionListOK) String() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListOK %+v", 200, o.Payload) +} + +func (o *GetScanDataExportExecutionListOK) GetPayload() *models.ScanDataExportExecutionList { + return o.Payload +} + +func (o *GetScanDataExportExecutionListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ScanDataExportExecutionList) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionListUnauthorized creates a GetScanDataExportExecutionListUnauthorized with default headers values +func NewGetScanDataExportExecutionListUnauthorized() *GetScanDataExportExecutionListUnauthorized { + return &GetScanDataExportExecutionListUnauthorized{} +} + +/* +GetScanDataExportExecutionListUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetScanDataExportExecutionListUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution list unauthorized response has a 2xx status code +func (o *GetScanDataExportExecutionListUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution list unauthorized response has a 3xx status code +func (o *GetScanDataExportExecutionListUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution list unauthorized response has a 4xx status code +func (o *GetScanDataExportExecutionListUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution list unauthorized response has a 5xx status code +func (o *GetScanDataExportExecutionListUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution list unauthorized response a status code equal to that given +func (o *GetScanDataExportExecutionListUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get scan data export execution list unauthorized response +func (o *GetScanDataExportExecutionListUnauthorized) Code() int { + return 401 +} + +func (o *GetScanDataExportExecutionListUnauthorized) Error() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListUnauthorized %+v", 401, o.Payload) +} + +func (o *GetScanDataExportExecutionListUnauthorized) String() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListUnauthorized %+v", 401, o.Payload) +} + +func (o *GetScanDataExportExecutionListUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionListUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionListForbidden creates a GetScanDataExportExecutionListForbidden with default headers values +func NewGetScanDataExportExecutionListForbidden() *GetScanDataExportExecutionListForbidden { + return &GetScanDataExportExecutionListForbidden{} +} + +/* +GetScanDataExportExecutionListForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetScanDataExportExecutionListForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution list forbidden response has a 2xx status code +func (o *GetScanDataExportExecutionListForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution list forbidden response has a 3xx status code +func (o *GetScanDataExportExecutionListForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution list forbidden response has a 4xx status code +func (o *GetScanDataExportExecutionListForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution list forbidden response has a 5xx status code +func (o *GetScanDataExportExecutionListForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution list forbidden response a status code equal to that given +func (o *GetScanDataExportExecutionListForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get scan data export execution list forbidden response +func (o *GetScanDataExportExecutionListForbidden) Code() int { + return 403 +} + +func (o *GetScanDataExportExecutionListForbidden) Error() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListForbidden %+v", 403, o.Payload) +} + +func (o *GetScanDataExportExecutionListForbidden) String() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListForbidden %+v", 403, o.Payload) +} + +func (o *GetScanDataExportExecutionListForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionListForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionListNotFound creates a GetScanDataExportExecutionListNotFound with default headers values +func NewGetScanDataExportExecutionListNotFound() *GetScanDataExportExecutionListNotFound { + return &GetScanDataExportExecutionListNotFound{} +} + +/* +GetScanDataExportExecutionListNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetScanDataExportExecutionListNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution list not found response has a 2xx status code +func (o *GetScanDataExportExecutionListNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution list not found response has a 3xx status code +func (o *GetScanDataExportExecutionListNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution list not found response has a 4xx status code +func (o *GetScanDataExportExecutionListNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution list not found response has a 5xx status code +func (o *GetScanDataExportExecutionListNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution list not found response a status code equal to that given +func (o *GetScanDataExportExecutionListNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get scan data export execution list not found response +func (o *GetScanDataExportExecutionListNotFound) Code() int { + return 404 +} + +func (o *GetScanDataExportExecutionListNotFound) Error() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListNotFound %+v", 404, o.Payload) +} + +func (o *GetScanDataExportExecutionListNotFound) String() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListNotFound %+v", 404, o.Payload) +} + +func (o *GetScanDataExportExecutionListNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionListNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionListInternalServerError creates a GetScanDataExportExecutionListInternalServerError with default headers values +func NewGetScanDataExportExecutionListInternalServerError() *GetScanDataExportExecutionListInternalServerError { + return &GetScanDataExportExecutionListInternalServerError{} +} + +/* +GetScanDataExportExecutionListInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetScanDataExportExecutionListInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution list internal server error response has a 2xx status code +func (o *GetScanDataExportExecutionListInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution list internal server error response has a 3xx status code +func (o *GetScanDataExportExecutionListInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution list internal server error response has a 4xx status code +func (o *GetScanDataExportExecutionListInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get scan data export execution list internal server error response has a 5xx status code +func (o *GetScanDataExportExecutionListInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get scan data export execution list internal server error response a status code equal to that given +func (o *GetScanDataExportExecutionListInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get scan data export execution list internal server error response +func (o *GetScanDataExportExecutionListInternalServerError) Code() int { + return 500 +} + +func (o *GetScanDataExportExecutionListInternalServerError) Error() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListInternalServerError %+v", 500, o.Payload) +} + +func (o *GetScanDataExportExecutionListInternalServerError) String() string { + return fmt.Sprintf("[GET /export/cve/executions][%d] getScanDataExportExecutionListInternalServerError %+v", 500, o.Payload) +} + +func (o *GetScanDataExportExecutionListInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionListInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_parameters.go b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_parameters.go new file mode 100644 index 0000000..f6dd434 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_parameters.go @@ -0,0 +1,177 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetScanDataExportExecutionParams creates a new GetScanDataExportExecutionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetScanDataExportExecutionParams() *GetScanDataExportExecutionParams { + return &GetScanDataExportExecutionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetScanDataExportExecutionParamsWithTimeout creates a new GetScanDataExportExecutionParams object +// with the ability to set a timeout on a request. +func NewGetScanDataExportExecutionParamsWithTimeout(timeout time.Duration) *GetScanDataExportExecutionParams { + return &GetScanDataExportExecutionParams{ + timeout: timeout, + } +} + +// NewGetScanDataExportExecutionParamsWithContext creates a new GetScanDataExportExecutionParams object +// with the ability to set a context for a request. +func NewGetScanDataExportExecutionParamsWithContext(ctx context.Context) *GetScanDataExportExecutionParams { + return &GetScanDataExportExecutionParams{ + Context: ctx, + } +} + +// NewGetScanDataExportExecutionParamsWithHTTPClient creates a new GetScanDataExportExecutionParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetScanDataExportExecutionParamsWithHTTPClient(client *http.Client) *GetScanDataExportExecutionParams { + return &GetScanDataExportExecutionParams{ + HTTPClient: client, + } +} + +/* +GetScanDataExportExecutionParams contains all the parameters to send to the API endpoint + + for the get scan data export execution operation. + + Typically these are written to a http.Request. +*/ +type GetScanDataExportExecutionParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* ExecutionID. + + Execution ID + */ + ExecutionID int64 `js:"executionID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get scan data export execution params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetScanDataExportExecutionParams) WithDefaults() *GetScanDataExportExecutionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get scan data export execution params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetScanDataExportExecutionParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) WithTimeout(timeout time.Duration) *GetScanDataExportExecutionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) WithContext(ctx context.Context) *GetScanDataExportExecutionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) WithHTTPClient(client *http.Client) *GetScanDataExportExecutionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) WithXRequestID(xRequestID *string) *GetScanDataExportExecutionParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithExecutionID adds the executionID to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) WithExecutionID(executionID int64) *GetScanDataExportExecutionParams { + o.SetExecutionID(executionID) + return o +} + +// SetExecutionID adds the executionId to the get scan data export execution params +func (o *GetScanDataExportExecutionParams) SetExecutionID(executionID int64) { + o.ExecutionID = executionID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetScanDataExportExecutionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param execution_id + if err := r.SetPathParam("execution_id", swag.FormatInt64(o.ExecutionID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_responses.go b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_responses.go new file mode 100644 index 0000000..888e908 --- /dev/null +++ b/pkg/harbor/client/scan_data_export/get_scan_data_export_execution_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetScanDataExportExecutionReader is a Reader for the GetScanDataExportExecution structure. +type GetScanDataExportExecutionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetScanDataExportExecutionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetScanDataExportExecutionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetScanDataExportExecutionUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetScanDataExportExecutionForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetScanDataExportExecutionNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetScanDataExportExecutionInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /export/cve/execution/{execution_id}] getScanDataExportExecution", response, response.Code()) + } +} + +// NewGetScanDataExportExecutionOK creates a GetScanDataExportExecutionOK with default headers values +func NewGetScanDataExportExecutionOK() *GetScanDataExportExecutionOK { + return &GetScanDataExportExecutionOK{} +} + +/* +GetScanDataExportExecutionOK describes a response with status code 200, with default header values. + +Success +*/ +type GetScanDataExportExecutionOK struct { + Payload *models.ScanDataExportExecution +} + +// IsSuccess returns true when this get scan data export execution o k response has a 2xx status code +func (o *GetScanDataExportExecutionOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get scan data export execution o k response has a 3xx status code +func (o *GetScanDataExportExecutionOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution o k response has a 4xx status code +func (o *GetScanDataExportExecutionOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get scan data export execution o k response has a 5xx status code +func (o *GetScanDataExportExecutionOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution o k response a status code equal to that given +func (o *GetScanDataExportExecutionOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get scan data export execution o k response +func (o *GetScanDataExportExecutionOK) Code() int { + return 200 +} + +func (o *GetScanDataExportExecutionOK) Error() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionOK %+v", 200, o.Payload) +} + +func (o *GetScanDataExportExecutionOK) String() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionOK %+v", 200, o.Payload) +} + +func (o *GetScanDataExportExecutionOK) GetPayload() *models.ScanDataExportExecution { + return o.Payload +} + +func (o *GetScanDataExportExecutionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ScanDataExportExecution) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionUnauthorized creates a GetScanDataExportExecutionUnauthorized with default headers values +func NewGetScanDataExportExecutionUnauthorized() *GetScanDataExportExecutionUnauthorized { + return &GetScanDataExportExecutionUnauthorized{} +} + +/* +GetScanDataExportExecutionUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetScanDataExportExecutionUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution unauthorized response has a 2xx status code +func (o *GetScanDataExportExecutionUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution unauthorized response has a 3xx status code +func (o *GetScanDataExportExecutionUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution unauthorized response has a 4xx status code +func (o *GetScanDataExportExecutionUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution unauthorized response has a 5xx status code +func (o *GetScanDataExportExecutionUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution unauthorized response a status code equal to that given +func (o *GetScanDataExportExecutionUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get scan data export execution unauthorized response +func (o *GetScanDataExportExecutionUnauthorized) Code() int { + return 401 +} + +func (o *GetScanDataExportExecutionUnauthorized) Error() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionUnauthorized %+v", 401, o.Payload) +} + +func (o *GetScanDataExportExecutionUnauthorized) String() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionUnauthorized %+v", 401, o.Payload) +} + +func (o *GetScanDataExportExecutionUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionForbidden creates a GetScanDataExportExecutionForbidden with default headers values +func NewGetScanDataExportExecutionForbidden() *GetScanDataExportExecutionForbidden { + return &GetScanDataExportExecutionForbidden{} +} + +/* +GetScanDataExportExecutionForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetScanDataExportExecutionForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution forbidden response has a 2xx status code +func (o *GetScanDataExportExecutionForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution forbidden response has a 3xx status code +func (o *GetScanDataExportExecutionForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution forbidden response has a 4xx status code +func (o *GetScanDataExportExecutionForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution forbidden response has a 5xx status code +func (o *GetScanDataExportExecutionForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution forbidden response a status code equal to that given +func (o *GetScanDataExportExecutionForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get scan data export execution forbidden response +func (o *GetScanDataExportExecutionForbidden) Code() int { + return 403 +} + +func (o *GetScanDataExportExecutionForbidden) Error() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionForbidden %+v", 403, o.Payload) +} + +func (o *GetScanDataExportExecutionForbidden) String() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionForbidden %+v", 403, o.Payload) +} + +func (o *GetScanDataExportExecutionForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionNotFound creates a GetScanDataExportExecutionNotFound with default headers values +func NewGetScanDataExportExecutionNotFound() *GetScanDataExportExecutionNotFound { + return &GetScanDataExportExecutionNotFound{} +} + +/* +GetScanDataExportExecutionNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetScanDataExportExecutionNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution not found response has a 2xx status code +func (o *GetScanDataExportExecutionNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution not found response has a 3xx status code +func (o *GetScanDataExportExecutionNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution not found response has a 4xx status code +func (o *GetScanDataExportExecutionNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get scan data export execution not found response has a 5xx status code +func (o *GetScanDataExportExecutionNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get scan data export execution not found response a status code equal to that given +func (o *GetScanDataExportExecutionNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get scan data export execution not found response +func (o *GetScanDataExportExecutionNotFound) Code() int { + return 404 +} + +func (o *GetScanDataExportExecutionNotFound) Error() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionNotFound %+v", 404, o.Payload) +} + +func (o *GetScanDataExportExecutionNotFound) String() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionNotFound %+v", 404, o.Payload) +} + +func (o *GetScanDataExportExecutionNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanDataExportExecutionInternalServerError creates a GetScanDataExportExecutionInternalServerError with default headers values +func NewGetScanDataExportExecutionInternalServerError() *GetScanDataExportExecutionInternalServerError { + return &GetScanDataExportExecutionInternalServerError{} +} + +/* +GetScanDataExportExecutionInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetScanDataExportExecutionInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get scan data export execution internal server error response has a 2xx status code +func (o *GetScanDataExportExecutionInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get scan data export execution internal server error response has a 3xx status code +func (o *GetScanDataExportExecutionInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get scan data export execution internal server error response has a 4xx status code +func (o *GetScanDataExportExecutionInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get scan data export execution internal server error response has a 5xx status code +func (o *GetScanDataExportExecutionInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get scan data export execution internal server error response a status code equal to that given +func (o *GetScanDataExportExecutionInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get scan data export execution internal server error response +func (o *GetScanDataExportExecutionInternalServerError) Code() int { + return 500 +} + +func (o *GetScanDataExportExecutionInternalServerError) Error() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionInternalServerError %+v", 500, o.Payload) +} + +func (o *GetScanDataExportExecutionInternalServerError) String() string { + return fmt.Sprintf("[GET /export/cve/execution/{execution_id}][%d] getScanDataExportExecutionInternalServerError %+v", 500, o.Payload) +} + +func (o *GetScanDataExportExecutionInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetScanDataExportExecutionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/scan_data_export/scan_data_export_client.go b/pkg/harbor/client/scan_data_export/scan_data_export_client.go new file mode 100644 index 0000000..a5984cd --- /dev/null +++ b/pkg/harbor/client/scan_data_export/scan_data_export_client.go @@ -0,0 +1,226 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scan_data_export + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the scan data export client +type API interface { + /* + DownloadScanData downloads the scan data export file + + Download the scan data report. Default format is CSV*/ + DownloadScanData(ctx context.Context, params *DownloadScanDataParams, writer io.Writer) (*DownloadScanDataOK, error) + /* + ExportScanData exports scan data for selected projects + + Export scan data for selected projects*/ + ExportScanData(ctx context.Context, params *ExportScanDataParams) (*ExportScanDataOK, error) + /* + GetScanDataExportExecution gets the specific scan data export execution + + Get the scan data export execution specified by ID*/ + GetScanDataExportExecution(ctx context.Context, params *GetScanDataExportExecutionParams) (*GetScanDataExportExecutionOK, error) + /* + GetScanDataExportExecutionList gets a list of specific scan data export execution jobs for a specified user + + Get a list of specific scan data export execution jobs for a specified user*/ + GetScanDataExportExecutionList(ctx context.Context, params *GetScanDataExportExecutionListParams) (*GetScanDataExportExecutionListOK, error) +} + +// New creates a new scan data export API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for scan data export API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +DownloadScanData downloads the scan data export file + +Download the scan data report. Default format is CSV +*/ +func (a *Client) DownloadScanData(ctx context.Context, params *DownloadScanDataParams, writer io.Writer) (*DownloadScanDataOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "downloadScanData", + Method: "GET", + PathPattern: "/export/cve/download/{execution_id}", + ProducesMediaTypes: []string{"text/csv"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &DownloadScanDataReader{formats: a.formats, writer: writer}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *DownloadScanDataOK: + return value, nil + case *DownloadScanDataUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *DownloadScanDataForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *DownloadScanDataNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *DownloadScanDataInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for downloadScanData: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +ExportScanData exports scan data for selected projects + +Export scan data for selected projects +*/ +func (a *Client) ExportScanData(ctx context.Context, params *ExportScanDataParams) (*ExportScanDataOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "exportScanData", + Method: "POST", + PathPattern: "/export/cve", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ExportScanDataReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ExportScanDataOK: + return value, nil + case *ExportScanDataBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataMethodNotAllowed: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataConflict: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ExportScanDataInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for exportScanData: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetScanDataExportExecution gets the specific scan data export execution + +Get the scan data export execution specified by ID +*/ +func (a *Client) GetScanDataExportExecution(ctx context.Context, params *GetScanDataExportExecutionParams) (*GetScanDataExportExecutionOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getScanDataExportExecution", + Method: "GET", + PathPattern: "/export/cve/execution/{execution_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetScanDataExportExecutionReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetScanDataExportExecutionOK: + return value, nil + case *GetScanDataExportExecutionUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getScanDataExportExecution: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetScanDataExportExecutionList gets a list of specific scan data export execution jobs for a specified user + +Get a list of specific scan data export execution jobs for a specified user +*/ +func (a *Client) GetScanDataExportExecutionList(ctx context.Context, params *GetScanDataExportExecutionListParams) (*GetScanDataExportExecutionListOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getScanDataExportExecutionList", + Method: "GET", + PathPattern: "/export/cve/executions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetScanDataExportExecutionListReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetScanDataExportExecutionListOK: + return value, nil + case *GetScanDataExportExecutionListUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionListForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionListNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetScanDataExportExecutionListInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getScanDataExportExecutionList: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/scanner/list_scanners_parameters.go b/pkg/harbor/client/scanner/list_scanners_parameters.go index 52677f6..11fbb65 100644 --- a/pkg/harbor/client/scanner/list_scanners_parameters.go +++ b/pkg/harbor/client/scanner/list_scanners_parameters.go @@ -94,7 +94,7 @@ type ListScannersParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/scanner/set_scanner_as_default_parameters.go b/pkg/harbor/client/scanner/set_scanner_as_default_parameters.go index 3c20c12..21577e4 100644 --- a/pkg/harbor/client/scanner/set_scanner_as_default_parameters.go +++ b/pkg/harbor/client/scanner/set_scanner_as_default_parameters.go @@ -63,6 +63,12 @@ SetScannerAsDefaultParams contains all the parameters to send to the API endpoin */ type SetScannerAsDefaultParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + // Payload. Payload *models.IsDefault `js:"payload"` @@ -125,6 +131,17 @@ func (o *SetScannerAsDefaultParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the set scanner as default params +func (o *SetScannerAsDefaultParams) WithXRequestID(xRequestID *string) *SetScannerAsDefaultParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the set scanner as default params +func (o *SetScannerAsDefaultParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithPayload adds the payload to the set scanner as default params func (o *SetScannerAsDefaultParams) WithPayload(payload *models.IsDefault) *SetScannerAsDefaultParams { o.SetPayload(payload) @@ -154,6 +171,14 @@ func (o *SetScannerAsDefaultParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Payload != nil { if err := r.SetBodyParam(o.Payload); err != nil { return err diff --git a/pkg/harbor/client/schedule/get_schedule_paused_parameters.go b/pkg/harbor/client/schedule/get_schedule_paused_parameters.go new file mode 100644 index 0000000..e9d7276 --- /dev/null +++ b/pkg/harbor/client/schedule/get_schedule_paused_parameters.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetSchedulePausedParams creates a new GetSchedulePausedParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetSchedulePausedParams() *GetSchedulePausedParams { + return &GetSchedulePausedParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetSchedulePausedParamsWithTimeout creates a new GetSchedulePausedParams object +// with the ability to set a timeout on a request. +func NewGetSchedulePausedParamsWithTimeout(timeout time.Duration) *GetSchedulePausedParams { + return &GetSchedulePausedParams{ + timeout: timeout, + } +} + +// NewGetSchedulePausedParamsWithContext creates a new GetSchedulePausedParams object +// with the ability to set a context for a request. +func NewGetSchedulePausedParamsWithContext(ctx context.Context) *GetSchedulePausedParams { + return &GetSchedulePausedParams{ + Context: ctx, + } +} + +// NewGetSchedulePausedParamsWithHTTPClient creates a new GetSchedulePausedParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetSchedulePausedParamsWithHTTPClient(client *http.Client) *GetSchedulePausedParams { + return &GetSchedulePausedParams{ + HTTPClient: client, + } +} + +/* +GetSchedulePausedParams contains all the parameters to send to the API endpoint + + for the get schedule paused operation. + + Typically these are written to a http.Request. +*/ +type GetSchedulePausedParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* JobType. + + The type of the job. 'all' stands for all job types, current only support query with all + */ + JobType string `js:"jobType"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get schedule paused params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSchedulePausedParams) WithDefaults() *GetSchedulePausedParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get schedule paused params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSchedulePausedParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get schedule paused params +func (o *GetSchedulePausedParams) WithTimeout(timeout time.Duration) *GetSchedulePausedParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get schedule paused params +func (o *GetSchedulePausedParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get schedule paused params +func (o *GetSchedulePausedParams) WithContext(ctx context.Context) *GetSchedulePausedParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get schedule paused params +func (o *GetSchedulePausedParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get schedule paused params +func (o *GetSchedulePausedParams) WithHTTPClient(client *http.Client) *GetSchedulePausedParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get schedule paused params +func (o *GetSchedulePausedParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get schedule paused params +func (o *GetSchedulePausedParams) WithXRequestID(xRequestID *string) *GetSchedulePausedParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get schedule paused params +func (o *GetSchedulePausedParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithJobType adds the jobType to the get schedule paused params +func (o *GetSchedulePausedParams) WithJobType(jobType string) *GetSchedulePausedParams { + o.SetJobType(jobType) + return o +} + +// SetJobType adds the jobType to the get schedule paused params +func (o *GetSchedulePausedParams) SetJobType(jobType string) { + o.JobType = jobType +} + +// WriteToRequest writes these params to a swagger request +func (o *GetSchedulePausedParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param job_type + if err := r.SetPathParam("job_type", o.JobType); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/schedule/get_schedule_paused_responses.go b/pkg/harbor/client/schedule/get_schedule_paused_responses.go new file mode 100644 index 0000000..58c98ad --- /dev/null +++ b/pkg/harbor/client/schedule/get_schedule_paused_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetSchedulePausedReader is a Reader for the GetSchedulePaused structure. +type GetSchedulePausedReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetSchedulePausedReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetSchedulePausedOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetSchedulePausedUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetSchedulePausedForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetSchedulePausedNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetSchedulePausedInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /schedules/{job_type}/paused] getSchedulePaused", response, response.Code()) + } +} + +// NewGetSchedulePausedOK creates a GetSchedulePausedOK with default headers values +func NewGetSchedulePausedOK() *GetSchedulePausedOK { + return &GetSchedulePausedOK{} +} + +/* +GetSchedulePausedOK describes a response with status code 200, with default header values. + +Get scheduler status successfully. +*/ +type GetSchedulePausedOK struct { + Payload *models.SchedulerStatus +} + +// IsSuccess returns true when this get schedule paused o k response has a 2xx status code +func (o *GetSchedulePausedOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get schedule paused o k response has a 3xx status code +func (o *GetSchedulePausedOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get schedule paused o k response has a 4xx status code +func (o *GetSchedulePausedOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get schedule paused o k response has a 5xx status code +func (o *GetSchedulePausedOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get schedule paused o k response a status code equal to that given +func (o *GetSchedulePausedOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get schedule paused o k response +func (o *GetSchedulePausedOK) Code() int { + return 200 +} + +func (o *GetSchedulePausedOK) Error() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedOK %+v", 200, o.Payload) +} + +func (o *GetSchedulePausedOK) String() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedOK %+v", 200, o.Payload) +} + +func (o *GetSchedulePausedOK) GetPayload() *models.SchedulerStatus { + return o.Payload +} + +func (o *GetSchedulePausedOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SchedulerStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSchedulePausedUnauthorized creates a GetSchedulePausedUnauthorized with default headers values +func NewGetSchedulePausedUnauthorized() *GetSchedulePausedUnauthorized { + return &GetSchedulePausedUnauthorized{} +} + +/* +GetSchedulePausedUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetSchedulePausedUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get schedule paused unauthorized response has a 2xx status code +func (o *GetSchedulePausedUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get schedule paused unauthorized response has a 3xx status code +func (o *GetSchedulePausedUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get schedule paused unauthorized response has a 4xx status code +func (o *GetSchedulePausedUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get schedule paused unauthorized response has a 5xx status code +func (o *GetSchedulePausedUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get schedule paused unauthorized response a status code equal to that given +func (o *GetSchedulePausedUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get schedule paused unauthorized response +func (o *GetSchedulePausedUnauthorized) Code() int { + return 401 +} + +func (o *GetSchedulePausedUnauthorized) Error() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedUnauthorized %+v", 401, o.Payload) +} + +func (o *GetSchedulePausedUnauthorized) String() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedUnauthorized %+v", 401, o.Payload) +} + +func (o *GetSchedulePausedUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSchedulePausedUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSchedulePausedForbidden creates a GetSchedulePausedForbidden with default headers values +func NewGetSchedulePausedForbidden() *GetSchedulePausedForbidden { + return &GetSchedulePausedForbidden{} +} + +/* +GetSchedulePausedForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetSchedulePausedForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get schedule paused forbidden response has a 2xx status code +func (o *GetSchedulePausedForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get schedule paused forbidden response has a 3xx status code +func (o *GetSchedulePausedForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get schedule paused forbidden response has a 4xx status code +func (o *GetSchedulePausedForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get schedule paused forbidden response has a 5xx status code +func (o *GetSchedulePausedForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get schedule paused forbidden response a status code equal to that given +func (o *GetSchedulePausedForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get schedule paused forbidden response +func (o *GetSchedulePausedForbidden) Code() int { + return 403 +} + +func (o *GetSchedulePausedForbidden) Error() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedForbidden %+v", 403, o.Payload) +} + +func (o *GetSchedulePausedForbidden) String() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedForbidden %+v", 403, o.Payload) +} + +func (o *GetSchedulePausedForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSchedulePausedForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSchedulePausedNotFound creates a GetSchedulePausedNotFound with default headers values +func NewGetSchedulePausedNotFound() *GetSchedulePausedNotFound { + return &GetSchedulePausedNotFound{} +} + +/* +GetSchedulePausedNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetSchedulePausedNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get schedule paused not found response has a 2xx status code +func (o *GetSchedulePausedNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get schedule paused not found response has a 3xx status code +func (o *GetSchedulePausedNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get schedule paused not found response has a 4xx status code +func (o *GetSchedulePausedNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get schedule paused not found response has a 5xx status code +func (o *GetSchedulePausedNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get schedule paused not found response a status code equal to that given +func (o *GetSchedulePausedNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get schedule paused not found response +func (o *GetSchedulePausedNotFound) Code() int { + return 404 +} + +func (o *GetSchedulePausedNotFound) Error() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedNotFound %+v", 404, o.Payload) +} + +func (o *GetSchedulePausedNotFound) String() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedNotFound %+v", 404, o.Payload) +} + +func (o *GetSchedulePausedNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSchedulePausedNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSchedulePausedInternalServerError creates a GetSchedulePausedInternalServerError with default headers values +func NewGetSchedulePausedInternalServerError() *GetSchedulePausedInternalServerError { + return &GetSchedulePausedInternalServerError{} +} + +/* +GetSchedulePausedInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetSchedulePausedInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get schedule paused internal server error response has a 2xx status code +func (o *GetSchedulePausedInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get schedule paused internal server error response has a 3xx status code +func (o *GetSchedulePausedInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get schedule paused internal server error response has a 4xx status code +func (o *GetSchedulePausedInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get schedule paused internal server error response has a 5xx status code +func (o *GetSchedulePausedInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get schedule paused internal server error response a status code equal to that given +func (o *GetSchedulePausedInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get schedule paused internal server error response +func (o *GetSchedulePausedInternalServerError) Code() int { + return 500 +} + +func (o *GetSchedulePausedInternalServerError) Error() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedInternalServerError %+v", 500, o.Payload) +} + +func (o *GetSchedulePausedInternalServerError) String() string { + return fmt.Sprintf("[GET /schedules/{job_type}/paused][%d] getSchedulePausedInternalServerError %+v", 500, o.Payload) +} + +func (o *GetSchedulePausedInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSchedulePausedInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/schedule/list_schedules_parameters.go b/pkg/harbor/client/schedule/list_schedules_parameters.go new file mode 100644 index 0000000..9a07fcc --- /dev/null +++ b/pkg/harbor/client/schedule/list_schedules_parameters.go @@ -0,0 +1,243 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListSchedulesParams creates a new ListSchedulesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListSchedulesParams() *ListSchedulesParams { + return &ListSchedulesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListSchedulesParamsWithTimeout creates a new ListSchedulesParams object +// with the ability to set a timeout on a request. +func NewListSchedulesParamsWithTimeout(timeout time.Duration) *ListSchedulesParams { + return &ListSchedulesParams{ + timeout: timeout, + } +} + +// NewListSchedulesParamsWithContext creates a new ListSchedulesParams object +// with the ability to set a context for a request. +func NewListSchedulesParamsWithContext(ctx context.Context) *ListSchedulesParams { + return &ListSchedulesParams{ + Context: ctx, + } +} + +// NewListSchedulesParamsWithHTTPClient creates a new ListSchedulesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListSchedulesParamsWithHTTPClient(client *http.Client) *ListSchedulesParams { + return &ListSchedulesParams{ + HTTPClient: client, + } +} + +/* +ListSchedulesParams contains all the parameters to send to the API endpoint + + for the list schedules operation. + + Typically these are written to a http.Request. +*/ +type ListSchedulesParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list schedules params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListSchedulesParams) WithDefaults() *ListSchedulesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list schedules params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListSchedulesParams) SetDefaults() { + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := ListSchedulesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the list schedules params +func (o *ListSchedulesParams) WithTimeout(timeout time.Duration) *ListSchedulesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list schedules params +func (o *ListSchedulesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list schedules params +func (o *ListSchedulesParams) WithContext(ctx context.Context) *ListSchedulesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list schedules params +func (o *ListSchedulesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list schedules params +func (o *ListSchedulesParams) WithHTTPClient(client *http.Client) *ListSchedulesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list schedules params +func (o *ListSchedulesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the list schedules params +func (o *ListSchedulesParams) WithXRequestID(xRequestID *string) *ListSchedulesParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list schedules params +func (o *ListSchedulesParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the list schedules params +func (o *ListSchedulesParams) WithPage(page *int64) *ListSchedulesParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list schedules params +func (o *ListSchedulesParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list schedules params +func (o *ListSchedulesParams) WithPageSize(pageSize *int64) *ListSchedulesParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list schedules params +func (o *ListSchedulesParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WriteToRequest writes these params to a swagger request +func (o *ListSchedulesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/schedule/list_schedules_responses.go b/pkg/harbor/client/schedule/list_schedules_responses.go new file mode 100644 index 0000000..2b29b85 --- /dev/null +++ b/pkg/harbor/client/schedule/list_schedules_responses.go @@ -0,0 +1,474 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListSchedulesReader is a Reader for the ListSchedules structure. +type ListSchedulesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListSchedulesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListSchedulesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewListSchedulesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListSchedulesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListSchedulesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListSchedulesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /schedules] listSchedules", response, response.Code()) + } +} + +// NewListSchedulesOK creates a ListSchedulesOK with default headers values +func NewListSchedulesOK() *ListSchedulesOK { + return &ListSchedulesOK{} +} + +/* +ListSchedulesOK describes a response with status code 200, with default header values. + +list schedule successfully. +*/ +type ListSchedulesOK struct { + + /* Link to previous page and next page + */ + Link string + + /* The total count of available items + */ + XTotalCount int64 + + Payload []*models.ScheduleTask +} + +// IsSuccess returns true when this list schedules o k response has a 2xx status code +func (o *ListSchedulesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list schedules o k response has a 3xx status code +func (o *ListSchedulesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list schedules o k response has a 4xx status code +func (o *ListSchedulesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list schedules o k response has a 5xx status code +func (o *ListSchedulesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list schedules o k response a status code equal to that given +func (o *ListSchedulesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list schedules o k response +func (o *ListSchedulesOK) Code() int { + return 200 +} + +func (o *ListSchedulesOK) Error() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesOK %+v", 200, o.Payload) +} + +func (o *ListSchedulesOK) String() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesOK %+v", 200, o.Payload) +} + +func (o *ListSchedulesOK) GetPayload() []*models.ScheduleTask { + return o.Payload +} + +func (o *ListSchedulesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListSchedulesUnauthorized creates a ListSchedulesUnauthorized with default headers values +func NewListSchedulesUnauthorized() *ListSchedulesUnauthorized { + return &ListSchedulesUnauthorized{} +} + +/* +ListSchedulesUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListSchedulesUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list schedules unauthorized response has a 2xx status code +func (o *ListSchedulesUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list schedules unauthorized response has a 3xx status code +func (o *ListSchedulesUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list schedules unauthorized response has a 4xx status code +func (o *ListSchedulesUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list schedules unauthorized response has a 5xx status code +func (o *ListSchedulesUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list schedules unauthorized response a status code equal to that given +func (o *ListSchedulesUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list schedules unauthorized response +func (o *ListSchedulesUnauthorized) Code() int { + return 401 +} + +func (o *ListSchedulesUnauthorized) Error() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListSchedulesUnauthorized) String() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListSchedulesUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListSchedulesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListSchedulesForbidden creates a ListSchedulesForbidden with default headers values +func NewListSchedulesForbidden() *ListSchedulesForbidden { + return &ListSchedulesForbidden{} +} + +/* +ListSchedulesForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ListSchedulesForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list schedules forbidden response has a 2xx status code +func (o *ListSchedulesForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list schedules forbidden response has a 3xx status code +func (o *ListSchedulesForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list schedules forbidden response has a 4xx status code +func (o *ListSchedulesForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list schedules forbidden response has a 5xx status code +func (o *ListSchedulesForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list schedules forbidden response a status code equal to that given +func (o *ListSchedulesForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list schedules forbidden response +func (o *ListSchedulesForbidden) Code() int { + return 403 +} + +func (o *ListSchedulesForbidden) Error() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesForbidden %+v", 403, o.Payload) +} + +func (o *ListSchedulesForbidden) String() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesForbidden %+v", 403, o.Payload) +} + +func (o *ListSchedulesForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListSchedulesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListSchedulesNotFound creates a ListSchedulesNotFound with default headers values +func NewListSchedulesNotFound() *ListSchedulesNotFound { + return &ListSchedulesNotFound{} +} + +/* +ListSchedulesNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ListSchedulesNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list schedules not found response has a 2xx status code +func (o *ListSchedulesNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list schedules not found response has a 3xx status code +func (o *ListSchedulesNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list schedules not found response has a 4xx status code +func (o *ListSchedulesNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list schedules not found response has a 5xx status code +func (o *ListSchedulesNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list schedules not found response a status code equal to that given +func (o *ListSchedulesNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list schedules not found response +func (o *ListSchedulesNotFound) Code() int { + return 404 +} + +func (o *ListSchedulesNotFound) Error() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesNotFound %+v", 404, o.Payload) +} + +func (o *ListSchedulesNotFound) String() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesNotFound %+v", 404, o.Payload) +} + +func (o *ListSchedulesNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListSchedulesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListSchedulesInternalServerError creates a ListSchedulesInternalServerError with default headers values +func NewListSchedulesInternalServerError() *ListSchedulesInternalServerError { + return &ListSchedulesInternalServerError{} +} + +/* +ListSchedulesInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListSchedulesInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list schedules internal server error response has a 2xx status code +func (o *ListSchedulesInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list schedules internal server error response has a 3xx status code +func (o *ListSchedulesInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list schedules internal server error response has a 4xx status code +func (o *ListSchedulesInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list schedules internal server error response has a 5xx status code +func (o *ListSchedulesInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list schedules internal server error response a status code equal to that given +func (o *ListSchedulesInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list schedules internal server error response +func (o *ListSchedulesInternalServerError) Code() int { + return 500 +} + +func (o *ListSchedulesInternalServerError) Error() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListSchedulesInternalServerError) String() string { + return fmt.Sprintf("[GET /schedules][%d] listSchedulesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListSchedulesInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListSchedulesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/schedule/schedule_client.go b/pkg/harbor/client/schedule/schedule_client.go new file mode 100644 index 0000000..7c173eb --- /dev/null +++ b/pkg/harbor/client/schedule/schedule_client.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package schedule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the schedule client +type API interface { + /* + GetSchedulePaused Get scheduler paused status*/ + GetSchedulePaused(ctx context.Context, params *GetSchedulePausedParams) (*GetSchedulePausedOK, error) + /* + ListSchedules List schedules*/ + ListSchedules(ctx context.Context, params *ListSchedulesParams) (*ListSchedulesOK, error) +} + +// New creates a new schedule API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for schedule API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +GetSchedulePaused Get scheduler paused status +*/ +func (a *Client) GetSchedulePaused(ctx context.Context, params *GetSchedulePausedParams) (*GetSchedulePausedOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getSchedulePaused", + Method: "GET", + PathPattern: "/schedules/{job_type}/paused", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetSchedulePausedReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetSchedulePausedOK: + return value, nil + case *GetSchedulePausedUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSchedulePausedForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSchedulePausedNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSchedulePausedInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getSchedulePaused: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +ListSchedules List schedules +*/ +func (a *Client) ListSchedules(ctx context.Context, params *ListSchedulesParams) (*ListSchedulesOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listSchedules", + Method: "GET", + PathPattern: "/schedules", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListSchedulesReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListSchedulesOK: + return value, nil + case *ListSchedulesUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListSchedulesForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListSchedulesNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListSchedulesInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for listSchedules: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/search/search_client.go b/pkg/harbor/client/search/search_client.go index ca71089..5ab71de 100644 --- a/pkg/harbor/client/search/search_client.go +++ b/pkg/harbor/client/search/search_client.go @@ -19,9 +19,9 @@ import ( // API is the interface of the search client type API interface { /* - Search searches for projects repositories and helm charts + Search searches for projects and repositories - The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order.*/ + The Search endpoint returns information about the projects and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order.*/ Search(ctx context.Context, params *SearchParams) (*SearchOK, error) } @@ -44,9 +44,9 @@ type Client struct { } /* -Search searches for projects repositories and helm charts +Search searches for projects and repositories -The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order. +The Search endpoint returns information about the projects and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order. */ func (a *Client) Search(ctx context.Context, params *SearchParams) (*SearchOK, error) { diff --git a/pkg/harbor/client/securityhub/get_security_summary_parameters.go b/pkg/harbor/client/securityhub/get_security_summary_parameters.go new file mode 100644 index 0000000..13820c5 --- /dev/null +++ b/pkg/harbor/client/securityhub/get_security_summary_parameters.go @@ -0,0 +1,237 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package securityhub + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetSecuritySummaryParams creates a new GetSecuritySummaryParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetSecuritySummaryParams() *GetSecuritySummaryParams { + return &GetSecuritySummaryParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetSecuritySummaryParamsWithTimeout creates a new GetSecuritySummaryParams object +// with the ability to set a timeout on a request. +func NewGetSecuritySummaryParamsWithTimeout(timeout time.Duration) *GetSecuritySummaryParams { + return &GetSecuritySummaryParams{ + timeout: timeout, + } +} + +// NewGetSecuritySummaryParamsWithContext creates a new GetSecuritySummaryParams object +// with the ability to set a context for a request. +func NewGetSecuritySummaryParamsWithContext(ctx context.Context) *GetSecuritySummaryParams { + return &GetSecuritySummaryParams{ + Context: ctx, + } +} + +// NewGetSecuritySummaryParamsWithHTTPClient creates a new GetSecuritySummaryParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetSecuritySummaryParamsWithHTTPClient(client *http.Client) *GetSecuritySummaryParams { + return &GetSecuritySummaryParams{ + HTTPClient: client, + } +} + +/* +GetSecuritySummaryParams contains all the parameters to send to the API endpoint + + for the get security summary operation. + + Typically these are written to a http.Request. +*/ +type GetSecuritySummaryParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* WithDangerousArtifact. + + Specify whether the dangerous Artifact are included inside summary information + */ + WithDangerousArtifact *bool `js:"withDangerousArtifact"` + + /* WithDangerousCVE. + + Specify whether the dangerous CVEs are included inside summary information + */ + WithDangerousCVE *bool `js:"withDangerousCVE"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get security summary params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSecuritySummaryParams) WithDefaults() *GetSecuritySummaryParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get security summary params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetSecuritySummaryParams) SetDefaults() { + var ( + withDangerousArtifactDefault = bool(false) + + withDangerousCVEDefault = bool(false) + ) + + val := GetSecuritySummaryParams{ + WithDangerousArtifact: &withDangerousArtifactDefault, + WithDangerousCVE: &withDangerousCVEDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the get security summary params +func (o *GetSecuritySummaryParams) WithTimeout(timeout time.Duration) *GetSecuritySummaryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get security summary params +func (o *GetSecuritySummaryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get security summary params +func (o *GetSecuritySummaryParams) WithContext(ctx context.Context) *GetSecuritySummaryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get security summary params +func (o *GetSecuritySummaryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get security summary params +func (o *GetSecuritySummaryParams) WithHTTPClient(client *http.Client) *GetSecuritySummaryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get security summary params +func (o *GetSecuritySummaryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the get security summary params +func (o *GetSecuritySummaryParams) WithXRequestID(xRequestID *string) *GetSecuritySummaryParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get security summary params +func (o *GetSecuritySummaryParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithWithDangerousArtifact adds the withDangerousArtifact to the get security summary params +func (o *GetSecuritySummaryParams) WithWithDangerousArtifact(withDangerousArtifact *bool) *GetSecuritySummaryParams { + o.SetWithDangerousArtifact(withDangerousArtifact) + return o +} + +// SetWithDangerousArtifact adds the withDangerousArtifact to the get security summary params +func (o *GetSecuritySummaryParams) SetWithDangerousArtifact(withDangerousArtifact *bool) { + o.WithDangerousArtifact = withDangerousArtifact +} + +// WithWithDangerousCVE adds the withDangerousCVE to the get security summary params +func (o *GetSecuritySummaryParams) WithWithDangerousCVE(withDangerousCVE *bool) *GetSecuritySummaryParams { + o.SetWithDangerousCVE(withDangerousCVE) + return o +} + +// SetWithDangerousCVE adds the withDangerousCve to the get security summary params +func (o *GetSecuritySummaryParams) SetWithDangerousCVE(withDangerousCVE *bool) { + o.WithDangerousCVE = withDangerousCVE +} + +// WriteToRequest writes these params to a swagger request +func (o *GetSecuritySummaryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.WithDangerousArtifact != nil { + + // query param with_dangerous_artifact + var qrWithDangerousArtifact bool + + if o.WithDangerousArtifact != nil { + qrWithDangerousArtifact = *o.WithDangerousArtifact + } + qWithDangerousArtifact := swag.FormatBool(qrWithDangerousArtifact) + if qWithDangerousArtifact != "" { + + if err := r.SetQueryParam("with_dangerous_artifact", qWithDangerousArtifact); err != nil { + return err + } + } + } + + if o.WithDangerousCVE != nil { + + // query param with_dangerous_cve + var qrWithDangerousCVE bool + + if o.WithDangerousCVE != nil { + qrWithDangerousCVE = *o.WithDangerousCVE + } + qWithDangerousCVE := swag.FormatBool(qrWithDangerousCVE) + if qWithDangerousCVE != "" { + + if err := r.SetQueryParam("with_dangerous_cve", qWithDangerousCVE); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/securityhub/get_security_summary_responses.go b/pkg/harbor/client/securityhub/get_security_summary_responses.go new file mode 100644 index 0000000..023b1a0 --- /dev/null +++ b/pkg/harbor/client/securityhub/get_security_summary_responses.go @@ -0,0 +1,447 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package securityhub + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetSecuritySummaryReader is a Reader for the GetSecuritySummary structure. +type GetSecuritySummaryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetSecuritySummaryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetSecuritySummaryOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetSecuritySummaryUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetSecuritySummaryForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetSecuritySummaryNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetSecuritySummaryInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /security/summary] getSecuritySummary", response, response.Code()) + } +} + +// NewGetSecuritySummaryOK creates a GetSecuritySummaryOK with default headers values +func NewGetSecuritySummaryOK() *GetSecuritySummaryOK { + return &GetSecuritySummaryOK{} +} + +/* +GetSecuritySummaryOK describes a response with status code 200, with default header values. + +Success +*/ +type GetSecuritySummaryOK struct { + Payload *models.SecuritySummary +} + +// IsSuccess returns true when this get security summary o k response has a 2xx status code +func (o *GetSecuritySummaryOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get security summary o k response has a 3xx status code +func (o *GetSecuritySummaryOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get security summary o k response has a 4xx status code +func (o *GetSecuritySummaryOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get security summary o k response has a 5xx status code +func (o *GetSecuritySummaryOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get security summary o k response a status code equal to that given +func (o *GetSecuritySummaryOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get security summary o k response +func (o *GetSecuritySummaryOK) Code() int { + return 200 +} + +func (o *GetSecuritySummaryOK) Error() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryOK %+v", 200, o.Payload) +} + +func (o *GetSecuritySummaryOK) String() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryOK %+v", 200, o.Payload) +} + +func (o *GetSecuritySummaryOK) GetPayload() *models.SecuritySummary { + return o.Payload +} + +func (o *GetSecuritySummaryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SecuritySummary) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSecuritySummaryUnauthorized creates a GetSecuritySummaryUnauthorized with default headers values +func NewGetSecuritySummaryUnauthorized() *GetSecuritySummaryUnauthorized { + return &GetSecuritySummaryUnauthorized{} +} + +/* +GetSecuritySummaryUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetSecuritySummaryUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get security summary unauthorized response has a 2xx status code +func (o *GetSecuritySummaryUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get security summary unauthorized response has a 3xx status code +func (o *GetSecuritySummaryUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get security summary unauthorized response has a 4xx status code +func (o *GetSecuritySummaryUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get security summary unauthorized response has a 5xx status code +func (o *GetSecuritySummaryUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get security summary unauthorized response a status code equal to that given +func (o *GetSecuritySummaryUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get security summary unauthorized response +func (o *GetSecuritySummaryUnauthorized) Code() int { + return 401 +} + +func (o *GetSecuritySummaryUnauthorized) Error() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryUnauthorized %+v", 401, o.Payload) +} + +func (o *GetSecuritySummaryUnauthorized) String() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryUnauthorized %+v", 401, o.Payload) +} + +func (o *GetSecuritySummaryUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSecuritySummaryUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSecuritySummaryForbidden creates a GetSecuritySummaryForbidden with default headers values +func NewGetSecuritySummaryForbidden() *GetSecuritySummaryForbidden { + return &GetSecuritySummaryForbidden{} +} + +/* +GetSecuritySummaryForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetSecuritySummaryForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get security summary forbidden response has a 2xx status code +func (o *GetSecuritySummaryForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get security summary forbidden response has a 3xx status code +func (o *GetSecuritySummaryForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get security summary forbidden response has a 4xx status code +func (o *GetSecuritySummaryForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get security summary forbidden response has a 5xx status code +func (o *GetSecuritySummaryForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get security summary forbidden response a status code equal to that given +func (o *GetSecuritySummaryForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get security summary forbidden response +func (o *GetSecuritySummaryForbidden) Code() int { + return 403 +} + +func (o *GetSecuritySummaryForbidden) Error() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryForbidden %+v", 403, o.Payload) +} + +func (o *GetSecuritySummaryForbidden) String() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryForbidden %+v", 403, o.Payload) +} + +func (o *GetSecuritySummaryForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSecuritySummaryForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSecuritySummaryNotFound creates a GetSecuritySummaryNotFound with default headers values +func NewGetSecuritySummaryNotFound() *GetSecuritySummaryNotFound { + return &GetSecuritySummaryNotFound{} +} + +/* +GetSecuritySummaryNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetSecuritySummaryNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get security summary not found response has a 2xx status code +func (o *GetSecuritySummaryNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get security summary not found response has a 3xx status code +func (o *GetSecuritySummaryNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get security summary not found response has a 4xx status code +func (o *GetSecuritySummaryNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get security summary not found response has a 5xx status code +func (o *GetSecuritySummaryNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get security summary not found response a status code equal to that given +func (o *GetSecuritySummaryNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get security summary not found response +func (o *GetSecuritySummaryNotFound) Code() int { + return 404 +} + +func (o *GetSecuritySummaryNotFound) Error() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryNotFound %+v", 404, o.Payload) +} + +func (o *GetSecuritySummaryNotFound) String() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryNotFound %+v", 404, o.Payload) +} + +func (o *GetSecuritySummaryNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSecuritySummaryNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetSecuritySummaryInternalServerError creates a GetSecuritySummaryInternalServerError with default headers values +func NewGetSecuritySummaryInternalServerError() *GetSecuritySummaryInternalServerError { + return &GetSecuritySummaryInternalServerError{} +} + +/* +GetSecuritySummaryInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetSecuritySummaryInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get security summary internal server error response has a 2xx status code +func (o *GetSecuritySummaryInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get security summary internal server error response has a 3xx status code +func (o *GetSecuritySummaryInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get security summary internal server error response has a 4xx status code +func (o *GetSecuritySummaryInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get security summary internal server error response has a 5xx status code +func (o *GetSecuritySummaryInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get security summary internal server error response a status code equal to that given +func (o *GetSecuritySummaryInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get security summary internal server error response +func (o *GetSecuritySummaryInternalServerError) Code() int { + return 500 +} + +func (o *GetSecuritySummaryInternalServerError) Error() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryInternalServerError %+v", 500, o.Payload) +} + +func (o *GetSecuritySummaryInternalServerError) String() string { + return fmt.Sprintf("[GET /security/summary][%d] getSecuritySummaryInternalServerError %+v", 500, o.Payload) +} + +func (o *GetSecuritySummaryInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetSecuritySummaryInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/securityhub/list_vulnerabilities_parameters.go b/pkg/harbor/client/securityhub/list_vulnerabilities_parameters.go new file mode 100644 index 0000000..cf4ec8b --- /dev/null +++ b/pkg/harbor/client/securityhub/list_vulnerabilities_parameters.go @@ -0,0 +1,351 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package securityhub + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListVulnerabilitiesParams creates a new ListVulnerabilitiesParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListVulnerabilitiesParams() *ListVulnerabilitiesParams { + return &ListVulnerabilitiesParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListVulnerabilitiesParamsWithTimeout creates a new ListVulnerabilitiesParams object +// with the ability to set a timeout on a request. +func NewListVulnerabilitiesParamsWithTimeout(timeout time.Duration) *ListVulnerabilitiesParams { + return &ListVulnerabilitiesParams{ + timeout: timeout, + } +} + +// NewListVulnerabilitiesParamsWithContext creates a new ListVulnerabilitiesParams object +// with the ability to set a context for a request. +func NewListVulnerabilitiesParamsWithContext(ctx context.Context) *ListVulnerabilitiesParams { + return &ListVulnerabilitiesParams{ + Context: ctx, + } +} + +// NewListVulnerabilitiesParamsWithHTTPClient creates a new ListVulnerabilitiesParams object +// with the ability to set a custom HTTPClient for a request. +func NewListVulnerabilitiesParamsWithHTTPClient(client *http.Client) *ListVulnerabilitiesParams { + return &ListVulnerabilitiesParams{ + HTTPClient: client, + } +} + +/* +ListVulnerabilitiesParams contains all the parameters to send to the API endpoint + + for the list vulnerabilities operation. + + Typically these are written to a http.Request. +*/ +type ListVulnerabilitiesParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + /* Q. + + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + */ + Q *string `js:"q"` + + /* TuneCount. + + Enable to ignore X-Total-Count when the total count > 1000, if the total count is less than 1000, the real total count is returned, else -1. + */ + TuneCount *bool `js:"tuneCount"` + + /* WithTag. + + Specify whether the tag information is included inside vulnerability information + */ + WithTag *bool `js:"withTag"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list vulnerabilities params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListVulnerabilitiesParams) WithDefaults() *ListVulnerabilitiesParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list vulnerabilities params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListVulnerabilitiesParams) SetDefaults() { + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + + tuneCountDefault = bool(false) + + withTagDefault = bool(false) + ) + + val := ListVulnerabilitiesParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + TuneCount: &tuneCountDefault, + WithTag: &withTagDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithTimeout(timeout time.Duration) *ListVulnerabilitiesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithContext(ctx context.Context) *ListVulnerabilitiesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithHTTPClient(client *http.Client) *ListVulnerabilitiesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithXRequestID(xRequestID *string) *ListVulnerabilitiesParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithPage(page *int64) *ListVulnerabilitiesParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithPageSize(pageSize *int64) *ListVulnerabilitiesParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithQ adds the q to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithQ(q *string) *ListVulnerabilitiesParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetQ(q *string) { + o.Q = q +} + +// WithTuneCount adds the tuneCount to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithTuneCount(tuneCount *bool) *ListVulnerabilitiesParams { + o.SetTuneCount(tuneCount) + return o +} + +// SetTuneCount adds the tuneCount to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetTuneCount(tuneCount *bool) { + o.TuneCount = tuneCount +} + +// WithWithTag adds the withTag to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) WithWithTag(withTag *bool) *ListVulnerabilitiesParams { + o.SetWithTag(withTag) + return o +} + +// SetWithTag adds the withTag to the list vulnerabilities params +func (o *ListVulnerabilitiesParams) SetWithTag(withTag *bool) { + o.WithTag = withTag +} + +// WriteToRequest writes these params to a swagger request +func (o *ListVulnerabilitiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + if o.Q != nil { + + // query param q + var qrQ string + + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + } + + if o.TuneCount != nil { + + // query param tune_count + var qrTuneCount bool + + if o.TuneCount != nil { + qrTuneCount = *o.TuneCount + } + qTuneCount := swag.FormatBool(qrTuneCount) + if qTuneCount != "" { + + if err := r.SetQueryParam("tune_count", qTuneCount); err != nil { + return err + } + } + } + + if o.WithTag != nil { + + // query param with_tag + var qrWithTag bool + + if o.WithTag != nil { + qrWithTag = *o.WithTag + } + qWithTag := swag.FormatBool(qrWithTag) + if qWithTag != "" { + + if err := r.SetQueryParam("with_tag", qWithTag); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/securityhub/list_vulnerabilities_responses.go b/pkg/harbor/client/securityhub/list_vulnerabilities_responses.go new file mode 100644 index 0000000..4a7d9e2 --- /dev/null +++ b/pkg/harbor/client/securityhub/list_vulnerabilities_responses.go @@ -0,0 +1,388 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package securityhub + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListVulnerabilitiesReader is a Reader for the ListVulnerabilities structure. +type ListVulnerabilitiesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListVulnerabilitiesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListVulnerabilitiesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListVulnerabilitiesBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListVulnerabilitiesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListVulnerabilitiesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /security/vul] ListVulnerabilities", response, response.Code()) + } +} + +// NewListVulnerabilitiesOK creates a ListVulnerabilitiesOK with default headers values +func NewListVulnerabilitiesOK() *ListVulnerabilitiesOK { + return &ListVulnerabilitiesOK{} +} + +/* +ListVulnerabilitiesOK describes a response with status code 200, with default header values. + +The vulnerability list. +*/ +type ListVulnerabilitiesOK struct { + + /* Link refers to the previous page and next page + */ + Link string + + /* The total count of vulnerabilities + */ + XTotalCount int64 + + Payload []*models.VulnerabilityItem +} + +// IsSuccess returns true when this list vulnerabilities o k response has a 2xx status code +func (o *ListVulnerabilitiesOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list vulnerabilities o k response has a 3xx status code +func (o *ListVulnerabilitiesOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list vulnerabilities o k response has a 4xx status code +func (o *ListVulnerabilitiesOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list vulnerabilities o k response has a 5xx status code +func (o *ListVulnerabilitiesOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list vulnerabilities o k response a status code equal to that given +func (o *ListVulnerabilitiesOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list vulnerabilities o k response +func (o *ListVulnerabilitiesOK) Code() int { + return 200 +} + +func (o *ListVulnerabilitiesOK) Error() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesOK %+v", 200, o.Payload) +} + +func (o *ListVulnerabilitiesOK) String() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesOK %+v", 200, o.Payload) +} + +func (o *ListVulnerabilitiesOK) GetPayload() []*models.VulnerabilityItem { + return o.Payload +} + +func (o *ListVulnerabilitiesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListVulnerabilitiesBadRequest creates a ListVulnerabilitiesBadRequest with default headers values +func NewListVulnerabilitiesBadRequest() *ListVulnerabilitiesBadRequest { + return &ListVulnerabilitiesBadRequest{} +} + +/* +ListVulnerabilitiesBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type ListVulnerabilitiesBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list vulnerabilities bad request response has a 2xx status code +func (o *ListVulnerabilitiesBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list vulnerabilities bad request response has a 3xx status code +func (o *ListVulnerabilitiesBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list vulnerabilities bad request response has a 4xx status code +func (o *ListVulnerabilitiesBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list vulnerabilities bad request response has a 5xx status code +func (o *ListVulnerabilitiesBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list vulnerabilities bad request response a status code equal to that given +func (o *ListVulnerabilitiesBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list vulnerabilities bad request response +func (o *ListVulnerabilitiesBadRequest) Code() int { + return 400 +} + +func (o *ListVulnerabilitiesBadRequest) Error() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesBadRequest %+v", 400, o.Payload) +} + +func (o *ListVulnerabilitiesBadRequest) String() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesBadRequest %+v", 400, o.Payload) +} + +func (o *ListVulnerabilitiesBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListVulnerabilitiesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListVulnerabilitiesUnauthorized creates a ListVulnerabilitiesUnauthorized with default headers values +func NewListVulnerabilitiesUnauthorized() *ListVulnerabilitiesUnauthorized { + return &ListVulnerabilitiesUnauthorized{} +} + +/* +ListVulnerabilitiesUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListVulnerabilitiesUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list vulnerabilities unauthorized response has a 2xx status code +func (o *ListVulnerabilitiesUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list vulnerabilities unauthorized response has a 3xx status code +func (o *ListVulnerabilitiesUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list vulnerabilities unauthorized response has a 4xx status code +func (o *ListVulnerabilitiesUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list vulnerabilities unauthorized response has a 5xx status code +func (o *ListVulnerabilitiesUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list vulnerabilities unauthorized response a status code equal to that given +func (o *ListVulnerabilitiesUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list vulnerabilities unauthorized response +func (o *ListVulnerabilitiesUnauthorized) Code() int { + return 401 +} + +func (o *ListVulnerabilitiesUnauthorized) Error() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListVulnerabilitiesUnauthorized) String() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesUnauthorized %+v", 401, o.Payload) +} + +func (o *ListVulnerabilitiesUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListVulnerabilitiesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListVulnerabilitiesInternalServerError creates a ListVulnerabilitiesInternalServerError with default headers values +func NewListVulnerabilitiesInternalServerError() *ListVulnerabilitiesInternalServerError { + return &ListVulnerabilitiesInternalServerError{} +} + +/* +ListVulnerabilitiesInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListVulnerabilitiesInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list vulnerabilities internal server error response has a 2xx status code +func (o *ListVulnerabilitiesInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list vulnerabilities internal server error response has a 3xx status code +func (o *ListVulnerabilitiesInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list vulnerabilities internal server error response has a 4xx status code +func (o *ListVulnerabilitiesInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list vulnerabilities internal server error response has a 5xx status code +func (o *ListVulnerabilitiesInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list vulnerabilities internal server error response a status code equal to that given +func (o *ListVulnerabilitiesInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list vulnerabilities internal server error response +func (o *ListVulnerabilitiesInternalServerError) Code() int { + return 500 +} + +func (o *ListVulnerabilitiesInternalServerError) Error() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListVulnerabilitiesInternalServerError) String() string { + return fmt.Sprintf("[GET /security/vul][%d] listVulnerabilitiesInternalServerError %+v", 500, o.Payload) +} + +func (o *ListVulnerabilitiesInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListVulnerabilitiesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/securityhub/securityhub_client.go b/pkg/harbor/client/securityhub/securityhub_client.go new file mode 100644 index 0000000..aabf2c7 --- /dev/null +++ b/pkg/harbor/client/securityhub/securityhub_client.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package securityhub + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +//go:generate mockery --name API --keeptree --with-expecter --case underscore + +// API is the interface of the securityhub client +type API interface { + /* + ListVulnerabilities gets the vulnerability list + + Get the vulnerability list. use q to pass the query condition, + supported conditions: + cve_id(exact match) + cvss_score_v3(range condition) + severity(exact match) + repository_name(exact match) + project_id(exact match) + package(exact match) + tag(exact match) + digest(exact match) + */ + ListVulnerabilities(ctx context.Context, params *ListVulnerabilitiesParams) (*ListVulnerabilitiesOK, error) + /* + GetSecuritySummary gets vulnerability system summary + + Retrieve the vulnerability summary of the system*/ + GetSecuritySummary(ctx context.Context, params *GetSecuritySummaryParams) (*GetSecuritySummaryOK, error) +} + +// New creates a new securityhub API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client { + return &Client{ + transport: transport, + formats: formats, + authInfo: authInfo, + } +} + +/* +Client for securityhub API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry + authInfo runtime.ClientAuthInfoWriter +} + +/* +ListVulnerabilities gets the vulnerability list + +Get the vulnerability list. use q to pass the query condition, +supported conditions: +cve_id(exact match) +cvss_score_v3(range condition) +severity(exact match) +repository_name(exact match) +project_id(exact match) +package(exact match) +tag(exact match) +digest(exact match) +*/ +func (a *Client) ListVulnerabilities(ctx context.Context, params *ListVulnerabilitiesParams) (*ListVulnerabilitiesOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "ListVulnerabilities", + Method: "GET", + PathPattern: "/security/vul", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListVulnerabilitiesReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListVulnerabilitiesOK: + return value, nil + case *ListVulnerabilitiesBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListVulnerabilitiesUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListVulnerabilitiesInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for ListVulnerabilities: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetSecuritySummary gets vulnerability system summary + +Retrieve the vulnerability summary of the system +*/ +func (a *Client) GetSecuritySummary(ctx context.Context, params *GetSecuritySummaryParams) (*GetSecuritySummaryOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getSecuritySummary", + Method: "GET", + PathPattern: "/security/summary", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetSecuritySummaryReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetSecuritySummaryOK: + return value, nil + case *GetSecuritySummaryUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSecuritySummaryForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSecuritySummaryNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetSecuritySummaryInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for getSecuritySummary: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} diff --git a/pkg/harbor/client/system_cve_allowlist/put_system_cve_allowlist_parameters.go b/pkg/harbor/client/system_cve_allowlist/put_system_cve_allowlist_parameters.go index 837b6d7..73ead4d 100644 --- a/pkg/harbor/client/system_cve_allowlist/put_system_cve_allowlist_parameters.go +++ b/pkg/harbor/client/system_cve_allowlist/put_system_cve_allowlist_parameters.go @@ -63,6 +63,12 @@ PutSystemCVEAllowlistParams contains all the parameters to send to the API endpo */ type PutSystemCVEAllowlistParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Allowlist. The allowlist with new content @@ -122,6 +128,17 @@ func (o *PutSystemCVEAllowlistParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the put system CVE allowlist params +func (o *PutSystemCVEAllowlistParams) WithXRequestID(xRequestID *string) *PutSystemCVEAllowlistParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the put system CVE allowlist params +func (o *PutSystemCVEAllowlistParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithAllowlist adds the allowlist to the put system CVE allowlist params func (o *PutSystemCVEAllowlistParams) WithAllowlist(allowlist *models.CVEAllowlist) *PutSystemCVEAllowlistParams { o.SetAllowlist(allowlist) @@ -140,6 +157,14 @@ func (o *PutSystemCVEAllowlistParams) WriteToRequest(r runtime.ClientRequest, re return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Allowlist != nil { if err := r.SetBodyParam(o.Allowlist); err != nil { return err diff --git a/pkg/harbor/client/user/delete_user_parameters.go b/pkg/harbor/client/user/delete_user_parameters.go index 1527b67..16d6c05 100644 --- a/pkg/harbor/client/user/delete_user_parameters.go +++ b/pkg/harbor/client/user/delete_user_parameters.go @@ -62,6 +62,12 @@ DeleteUserParams contains all the parameters to send to the API endpoint */ type DeleteUserParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* UserID. User ID for marking as to be removed. @@ -123,6 +129,17 @@ func (o *DeleteUserParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the delete user params +func (o *DeleteUserParams) WithXRequestID(xRequestID *string) *DeleteUserParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the delete user params +func (o *DeleteUserParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithUserID adds the userID to the delete user params func (o *DeleteUserParams) WithUserID(userID int64) *DeleteUserParams { o.SetUserID(userID) @@ -142,6 +159,14 @@ func (o *DeleteUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + // path param user_id if err := r.SetPathParam("user_id", swag.FormatInt64(o.UserID)); err != nil { return err diff --git a/pkg/harbor/client/user/get_current_user_permissions_parameters.go b/pkg/harbor/client/user/get_current_user_permissions_parameters.go index 618ac25..f905363 100644 --- a/pkg/harbor/client/user/get_current_user_permissions_parameters.go +++ b/pkg/harbor/client/user/get_current_user_permissions_parameters.go @@ -62,6 +62,12 @@ GetCurrentUserPermissionsParams contains all the parameters to send to the API e */ type GetCurrentUserPermissionsParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Relative. If true, the resources in the response are relative to the scope, @@ -129,6 +135,17 @@ func (o *GetCurrentUserPermissionsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the get current user permissions params +func (o *GetCurrentUserPermissionsParams) WithXRequestID(xRequestID *string) *GetCurrentUserPermissionsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get current user permissions params +func (o *GetCurrentUserPermissionsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithRelative adds the relative to the get current user permissions params func (o *GetCurrentUserPermissionsParams) WithRelative(relative *bool) *GetCurrentUserPermissionsParams { o.SetRelative(relative) @@ -159,6 +176,14 @@ func (o *GetCurrentUserPermissionsParams) WriteToRequest(r runtime.ClientRequest } var res []error + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + if o.Relative != nil { // query param relative diff --git a/pkg/harbor/client/user/list_users_parameters.go b/pkg/harbor/client/user/list_users_parameters.go index 5f29003..13a603f 100644 --- a/pkg/harbor/client/user/list_users_parameters.go +++ b/pkg/harbor/client/user/list_users_parameters.go @@ -94,7 +94,7 @@ type ListUsersParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/user/set_user_sys_admin_parameters.go b/pkg/harbor/client/user/set_user_sys_admin_parameters.go index 100c07c..71064a8 100644 --- a/pkg/harbor/client/user/set_user_sys_admin_parameters.go +++ b/pkg/harbor/client/user/set_user_sys_admin_parameters.go @@ -64,6 +64,12 @@ SetUserSysAdminParams contains all the parameters to send to the API endpoint */ type SetUserSysAdminParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* SysadminFlag. Toggle a user to admin or not. @@ -128,6 +134,17 @@ func (o *SetUserSysAdminParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the set user sys admin params +func (o *SetUserSysAdminParams) WithXRequestID(xRequestID *string) *SetUserSysAdminParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the set user sys admin params +func (o *SetUserSysAdminParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithSysadminFlag adds the sysadminFlag to the set user sys admin params func (o *SetUserSysAdminParams) WithSysadminFlag(sysadminFlag *models.UserSysAdminFlag) *SetUserSysAdminParams { o.SetSysadminFlag(sysadminFlag) @@ -157,6 +174,14 @@ func (o *SetUserSysAdminParams) WriteToRequest(r runtime.ClientRequest, reg strf return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.SysadminFlag != nil { if err := r.SetBodyParam(o.SysadminFlag); err != nil { return err diff --git a/pkg/harbor/client/user/update_user_password_parameters.go b/pkg/harbor/client/user/update_user_password_parameters.go index e4ff541..39b260b 100644 --- a/pkg/harbor/client/user/update_user_password_parameters.go +++ b/pkg/harbor/client/user/update_user_password_parameters.go @@ -64,6 +64,12 @@ UpdateUserPasswordParams contains all the parameters to send to the API endpoint */ type UpdateUserPasswordParams struct { + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + /* Password. Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator. @@ -128,6 +134,17 @@ func (o *UpdateUserPasswordParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXRequestID adds the xRequestID to the update user password params +func (o *UpdateUserPasswordParams) WithXRequestID(xRequestID *string) *UpdateUserPasswordParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the update user password params +func (o *UpdateUserPasswordParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithPassword adds the password to the update user password params func (o *UpdateUserPasswordParams) WithPassword(password *models.PasswordReq) *UpdateUserPasswordParams { o.SetPassword(password) @@ -157,6 +174,14 @@ func (o *UpdateUserPasswordParams) WriteToRequest(r runtime.ClientRequest, reg s return err } var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } if o.Password != nil { if err := r.SetBodyParam(o.Password); err != nil { return err diff --git a/pkg/harbor/client/usergroup/list_user_groups_parameters.go b/pkg/harbor/client/usergroup/list_user_groups_parameters.go index 1195fa9..f7837b5 100644 --- a/pkg/harbor/client/usergroup/list_user_groups_parameters.go +++ b/pkg/harbor/client/usergroup/list_user_groups_parameters.go @@ -14,6 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListUserGroupsParams creates a new ListUserGroupsParams object, @@ -67,6 +68,36 @@ type ListUserGroupsParams struct { */ XRequestID *string `js:"xRequestID"` + /* GroupName. + + group name need to search, fuzzy matches + */ + GroupName *string `js:"groupName"` + + /* LdapGroupDn. + + search with ldap group DN + */ + LdapGroupDn *string `js:"ldapGroupDn"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + timeout time.Duration Context context.Context `js:"context"` HTTPClient *http.Client `js:"httpClient"` @@ -84,7 +115,21 @@ func (o *ListUserGroupsParams) WithDefaults() *ListUserGroupsParams { // // All values with no default are reset to their zero value. func (o *ListUserGroupsParams) SetDefaults() { - // no default values defined for this parameter + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := ListUserGroupsParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val } // WithTimeout adds the timeout to the list user groups params @@ -131,6 +176,50 @@ func (o *ListUserGroupsParams) SetXRequestID(xRequestID *string) { o.XRequestID = xRequestID } +// WithGroupName adds the groupName to the list user groups params +func (o *ListUserGroupsParams) WithGroupName(groupName *string) *ListUserGroupsParams { + o.SetGroupName(groupName) + return o +} + +// SetGroupName adds the groupName to the list user groups params +func (o *ListUserGroupsParams) SetGroupName(groupName *string) { + o.GroupName = groupName +} + +// WithLdapGroupDn adds the ldapGroupDn to the list user groups params +func (o *ListUserGroupsParams) WithLdapGroupDn(ldapGroupDn *string) *ListUserGroupsParams { + o.SetLdapGroupDn(ldapGroupDn) + return o +} + +// SetLdapGroupDn adds the ldapGroupDn to the list user groups params +func (o *ListUserGroupsParams) SetLdapGroupDn(ldapGroupDn *string) { + o.LdapGroupDn = ldapGroupDn +} + +// WithPage adds the page to the list user groups params +func (o *ListUserGroupsParams) WithPage(page *int64) *ListUserGroupsParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list user groups params +func (o *ListUserGroupsParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list user groups params +func (o *ListUserGroupsParams) WithPageSize(pageSize *int64) *ListUserGroupsParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list user groups params +func (o *ListUserGroupsParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + // WriteToRequest writes these params to a swagger request func (o *ListUserGroupsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -147,6 +236,74 @@ func (o *ListUserGroupsParams) WriteToRequest(r runtime.ClientRequest, reg strfm } } + if o.GroupName != nil { + + // query param group_name + var qrGroupName string + + if o.GroupName != nil { + qrGroupName = *o.GroupName + } + qGroupName := qrGroupName + if qGroupName != "" { + + if err := r.SetQueryParam("group_name", qGroupName); err != nil { + return err + } + } + } + + if o.LdapGroupDn != nil { + + // query param ldap_group_dn + var qrLdapGroupDn string + + if o.LdapGroupDn != nil { + qrLdapGroupDn = *o.LdapGroupDn + } + qLdapGroupDn := qrLdapGroupDn + if qLdapGroupDn != "" { + + if err := r.SetQueryParam("ldap_group_dn", qLdapGroupDn); err != nil { + return err + } + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/pkg/harbor/client/usergroup/list_user_groups_responses.go b/pkg/harbor/client/usergroup/list_user_groups_responses.go index 2e1047c..fa5e13e 100644 --- a/pkg/harbor/client/usergroup/list_user_groups_responses.go +++ b/pkg/harbor/client/usergroup/list_user_groups_responses.go @@ -9,8 +9,10 @@ import ( "fmt" "io" + "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" "github.com/goharbor/xk6-harbor/pkg/harbor/models" ) @@ -63,6 +65,15 @@ ListUserGroupsOK describes a response with status code 200, with default header Get user group successfully. */ type ListUserGroupsOK struct { + + /* Link to previous page and next page + */ + Link string + + /* The total count of available items + */ + XTotalCount int64 + Payload []*models.UserGroup } @@ -110,6 +121,24 @@ func (o *ListUserGroupsOK) GetPayload() []*models.UserGroup { func (o *ListUserGroupsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + // response payload if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { return err diff --git a/pkg/harbor/client/usergroup/search_user_groups_parameters.go b/pkg/harbor/client/usergroup/search_user_groups_parameters.go new file mode 100644 index 0000000..f09839e --- /dev/null +++ b/pkg/harbor/client/usergroup/search_user_groups_parameters.go @@ -0,0 +1,270 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewSearchUserGroupsParams creates a new SearchUserGroupsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewSearchUserGroupsParams() *SearchUserGroupsParams { + return &SearchUserGroupsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewSearchUserGroupsParamsWithTimeout creates a new SearchUserGroupsParams object +// with the ability to set a timeout on a request. +func NewSearchUserGroupsParamsWithTimeout(timeout time.Duration) *SearchUserGroupsParams { + return &SearchUserGroupsParams{ + timeout: timeout, + } +} + +// NewSearchUserGroupsParamsWithContext creates a new SearchUserGroupsParams object +// with the ability to set a context for a request. +func NewSearchUserGroupsParamsWithContext(ctx context.Context) *SearchUserGroupsParams { + return &SearchUserGroupsParams{ + Context: ctx, + } +} + +// NewSearchUserGroupsParamsWithHTTPClient creates a new SearchUserGroupsParams object +// with the ability to set a custom HTTPClient for a request. +func NewSearchUserGroupsParamsWithHTTPClient(client *http.Client) *SearchUserGroupsParams { + return &SearchUserGroupsParams{ + HTTPClient: client, + } +} + +/* +SearchUserGroupsParams contains all the parameters to send to the API endpoint + + for the search user groups operation. + + Typically these are written to a http.Request. +*/ +type SearchUserGroupsParams struct { + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Groupname. + + Group name for filtering results. + */ + Groupname string `js:"groupname"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the search user groups params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SearchUserGroupsParams) WithDefaults() *SearchUserGroupsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the search user groups params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *SearchUserGroupsParams) SetDefaults() { + var ( + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := SearchUserGroupsParams{ + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the search user groups params +func (o *SearchUserGroupsParams) WithTimeout(timeout time.Duration) *SearchUserGroupsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the search user groups params +func (o *SearchUserGroupsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the search user groups params +func (o *SearchUserGroupsParams) WithContext(ctx context.Context) *SearchUserGroupsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the search user groups params +func (o *SearchUserGroupsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the search user groups params +func (o *SearchUserGroupsParams) WithHTTPClient(client *http.Client) *SearchUserGroupsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the search user groups params +func (o *SearchUserGroupsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXRequestID adds the xRequestID to the search user groups params +func (o *SearchUserGroupsParams) WithXRequestID(xRequestID *string) *SearchUserGroupsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the search user groups params +func (o *SearchUserGroupsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithGroupname adds the groupname to the search user groups params +func (o *SearchUserGroupsParams) WithGroupname(groupname string) *SearchUserGroupsParams { + o.SetGroupname(groupname) + return o +} + +// SetGroupname adds the groupname to the search user groups params +func (o *SearchUserGroupsParams) SetGroupname(groupname string) { + o.Groupname = groupname +} + +// WithPage adds the page to the search user groups params +func (o *SearchUserGroupsParams) WithPage(page *int64) *SearchUserGroupsParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the search user groups params +func (o *SearchUserGroupsParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the search user groups params +func (o *SearchUserGroupsParams) WithPageSize(pageSize *int64) *SearchUserGroupsParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the search user groups params +func (o *SearchUserGroupsParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WriteToRequest writes these params to a swagger request +func (o *SearchUserGroupsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // query param groupname + qrGroupname := o.Groupname + qGroupname := qrGroupname + if qGroupname != "" { + + if err := r.SetQueryParam("groupname", qGroupname); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/usergroup/search_user_groups_responses.go b/pkg/harbor/client/usergroup/search_user_groups_responses.go new file mode 100644 index 0000000..9daac02 --- /dev/null +++ b/pkg/harbor/client/usergroup/search_user_groups_responses.go @@ -0,0 +1,302 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package usergroup + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// SearchUserGroupsReader is a Reader for the SearchUserGroups structure. +type SearchUserGroupsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *SearchUserGroupsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewSearchUserGroupsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewSearchUserGroupsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewSearchUserGroupsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /usergroups/search] searchUserGroups", response, response.Code()) + } +} + +// NewSearchUserGroupsOK creates a SearchUserGroupsOK with default headers values +func NewSearchUserGroupsOK() *SearchUserGroupsOK { + return &SearchUserGroupsOK{} +} + +/* +SearchUserGroupsOK describes a response with status code 200, with default header values. + +Search groups successfully. +*/ +type SearchUserGroupsOK struct { + + /* Link to previous page and next page + */ + Link string + + /* The total count of available items + */ + XTotalCount int64 + + Payload []*models.UserGroupSearchItem +} + +// IsSuccess returns true when this search user groups o k response has a 2xx status code +func (o *SearchUserGroupsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this search user groups o k response has a 3xx status code +func (o *SearchUserGroupsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this search user groups o k response has a 4xx status code +func (o *SearchUserGroupsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this search user groups o k response has a 5xx status code +func (o *SearchUserGroupsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this search user groups o k response a status code equal to that given +func (o *SearchUserGroupsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the search user groups o k response +func (o *SearchUserGroupsOK) Code() int { + return 200 +} + +func (o *SearchUserGroupsOK) Error() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsOK %+v", 200, o.Payload) +} + +func (o *SearchUserGroupsOK) String() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsOK %+v", 200, o.Payload) +} + +func (o *SearchUserGroupsOK) GetPayload() []*models.UserGroupSearchItem { + return o.Payload +} + +func (o *SearchUserGroupsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewSearchUserGroupsUnauthorized creates a SearchUserGroupsUnauthorized with default headers values +func NewSearchUserGroupsUnauthorized() *SearchUserGroupsUnauthorized { + return &SearchUserGroupsUnauthorized{} +} + +/* +SearchUserGroupsUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type SearchUserGroupsUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this search user groups unauthorized response has a 2xx status code +func (o *SearchUserGroupsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this search user groups unauthorized response has a 3xx status code +func (o *SearchUserGroupsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this search user groups unauthorized response has a 4xx status code +func (o *SearchUserGroupsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this search user groups unauthorized response has a 5xx status code +func (o *SearchUserGroupsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this search user groups unauthorized response a status code equal to that given +func (o *SearchUserGroupsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the search user groups unauthorized response +func (o *SearchUserGroupsUnauthorized) Code() int { + return 401 +} + +func (o *SearchUserGroupsUnauthorized) Error() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsUnauthorized %+v", 401, o.Payload) +} + +func (o *SearchUserGroupsUnauthorized) String() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsUnauthorized %+v", 401, o.Payload) +} + +func (o *SearchUserGroupsUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *SearchUserGroupsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewSearchUserGroupsInternalServerError creates a SearchUserGroupsInternalServerError with default headers values +func NewSearchUserGroupsInternalServerError() *SearchUserGroupsInternalServerError { + return &SearchUserGroupsInternalServerError{} +} + +/* +SearchUserGroupsInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type SearchUserGroupsInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this search user groups internal server error response has a 2xx status code +func (o *SearchUserGroupsInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this search user groups internal server error response has a 3xx status code +func (o *SearchUserGroupsInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this search user groups internal server error response has a 4xx status code +func (o *SearchUserGroupsInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this search user groups internal server error response has a 5xx status code +func (o *SearchUserGroupsInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this search user groups internal server error response a status code equal to that given +func (o *SearchUserGroupsInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the search user groups internal server error response +func (o *SearchUserGroupsInternalServerError) Code() int { + return 500 +} + +func (o *SearchUserGroupsInternalServerError) Error() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsInternalServerError %+v", 500, o.Payload) +} + +func (o *SearchUserGroupsInternalServerError) String() string { + return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsInternalServerError %+v", 500, o.Payload) +} + +func (o *SearchUserGroupsInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *SearchUserGroupsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/usergroup/usergroup_client.go b/pkg/harbor/client/usergroup/usergroup_client.go index dd029b0..f79829b 100644 --- a/pkg/harbor/client/usergroup/usergroup_client.go +++ b/pkg/harbor/client/usergroup/usergroup_client.go @@ -36,8 +36,14 @@ type API interface { /* ListUserGroups gets all user groups information - Get all user groups information*/ + Get all user groups information, it is open for system admin*/ ListUserGroups(ctx context.Context, params *ListUserGroupsParams) (*ListUserGroupsOK, error) + /* + SearchUserGroups searches groups by groupname + + This endpoint is to search groups by group name. It's open for all authenticated requests. + */ + SearchUserGroups(ctx context.Context, params *SearchUserGroupsParams) (*SearchUserGroupsOK, error) /* UpdateUserGroup updates group information @@ -190,7 +196,7 @@ func (a *Client) GetUserGroup(ctx context.Context, params *GetUserGroupParams) ( /* ListUserGroups gets all user groups information -Get all user groups information +Get all user groups information, it is open for system admin */ func (a *Client) ListUserGroups(ctx context.Context, params *ListUserGroupsParams) (*ListUserGroupsOK, error) { @@ -225,6 +231,42 @@ func (a *Client) ListUserGroups(ctx context.Context, params *ListUserGroupsParam panic(msg) } +/* +SearchUserGroups searches groups by groupname + +This endpoint is to search groups by group name. It's open for all authenticated requests. +*/ +func (a *Client) SearchUserGroups(ctx context.Context, params *SearchUserGroupsParams) (*SearchUserGroupsOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "searchUserGroups", + Method: "GET", + PathPattern: "/usergroups/search", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &SearchUserGroupsReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *SearchUserGroupsOK: + return value, nil + case *SearchUserGroupsUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *SearchUserGroupsInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for searchUserGroups: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* UpdateUserGroup updates group information diff --git a/pkg/harbor/client/webhook/get_logs_of_webhook_task_parameters.go b/pkg/harbor/client/webhook/get_logs_of_webhook_task_parameters.go new file mode 100644 index 0000000..61aad41 --- /dev/null +++ b/pkg/harbor/client/webhook/get_logs_of_webhook_task_parameters.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogsOfWebhookTaskParams creates a new GetLogsOfWebhookTaskParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetLogsOfWebhookTaskParams() *GetLogsOfWebhookTaskParams { + return &GetLogsOfWebhookTaskParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetLogsOfWebhookTaskParamsWithTimeout creates a new GetLogsOfWebhookTaskParams object +// with the ability to set a timeout on a request. +func NewGetLogsOfWebhookTaskParamsWithTimeout(timeout time.Duration) *GetLogsOfWebhookTaskParams { + return &GetLogsOfWebhookTaskParams{ + timeout: timeout, + } +} + +// NewGetLogsOfWebhookTaskParamsWithContext creates a new GetLogsOfWebhookTaskParams object +// with the ability to set a context for a request. +func NewGetLogsOfWebhookTaskParamsWithContext(ctx context.Context) *GetLogsOfWebhookTaskParams { + return &GetLogsOfWebhookTaskParams{ + Context: ctx, + } +} + +// NewGetLogsOfWebhookTaskParamsWithHTTPClient creates a new GetLogsOfWebhookTaskParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetLogsOfWebhookTaskParamsWithHTTPClient(client *http.Client) *GetLogsOfWebhookTaskParams { + return &GetLogsOfWebhookTaskParams{ + HTTPClient: client, + } +} + +/* +GetLogsOfWebhookTaskParams contains all the parameters to send to the API endpoint + + for the get logs of webhook task operation. + + Typically these are written to a http.Request. +*/ +type GetLogsOfWebhookTaskParams struct { + + /* XIsResourceName. + + The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + */ + XIsResourceName *bool `js:"xIsResourceName"` + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* ExecutionID. + + Execution ID + */ + ExecutionID int64 `js:"executionID"` + + /* ProjectNameOrID. + + The name or id of the project + */ + ProjectNameOrID string `js:"projectNameOrID"` + + /* TaskID. + + Task ID + */ + TaskID int64 `js:"taskID"` + + /* WebhookPolicyID. + + The ID of the webhook policy + + Format: int64 + */ + WebhookPolicyID int64 `js:"webhookPolicyID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the get logs of webhook task params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetLogsOfWebhookTaskParams) WithDefaults() *GetLogsOfWebhookTaskParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get logs of webhook task params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetLogsOfWebhookTaskParams) SetDefaults() { + var ( + xIsResourceNameDefault = bool(false) + ) + + val := GetLogsOfWebhookTaskParams{ + XIsResourceName: &xIsResourceNameDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithTimeout(timeout time.Duration) *GetLogsOfWebhookTaskParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithContext(ctx context.Context) *GetLogsOfWebhookTaskParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithHTTPClient(client *http.Client) *GetLogsOfWebhookTaskParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXIsResourceName adds the xIsResourceName to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithXIsResourceName(xIsResourceName *bool) *GetLogsOfWebhookTaskParams { + o.SetXIsResourceName(xIsResourceName) + return o +} + +// SetXIsResourceName adds the xIsResourceName to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetXIsResourceName(xIsResourceName *bool) { + o.XIsResourceName = xIsResourceName +} + +// WithXRequestID adds the xRequestID to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithXRequestID(xRequestID *string) *GetLogsOfWebhookTaskParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithExecutionID adds the executionID to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithExecutionID(executionID int64) *GetLogsOfWebhookTaskParams { + o.SetExecutionID(executionID) + return o +} + +// SetExecutionID adds the executionId to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetExecutionID(executionID int64) { + o.ExecutionID = executionID +} + +// WithProjectNameOrID adds the projectNameOrID to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithProjectNameOrID(projectNameOrID string) *GetLogsOfWebhookTaskParams { + o.SetProjectNameOrID(projectNameOrID) + return o +} + +// SetProjectNameOrID adds the projectNameOrId to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetProjectNameOrID(projectNameOrID string) { + o.ProjectNameOrID = projectNameOrID +} + +// WithTaskID adds the taskID to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithTaskID(taskID int64) *GetLogsOfWebhookTaskParams { + o.SetTaskID(taskID) + return o +} + +// SetTaskID adds the taskId to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetTaskID(taskID int64) { + o.TaskID = taskID +} + +// WithWebhookPolicyID adds the webhookPolicyID to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) WithWebhookPolicyID(webhookPolicyID int64) *GetLogsOfWebhookTaskParams { + o.SetWebhookPolicyID(webhookPolicyID) + return o +} + +// SetWebhookPolicyID adds the webhookPolicyId to the get logs of webhook task params +func (o *GetLogsOfWebhookTaskParams) SetWebhookPolicyID(webhookPolicyID int64) { + o.WebhookPolicyID = webhookPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetLogsOfWebhookTaskParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XIsResourceName != nil { + + // header param X-Is-Resource-Name + if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil { + return err + } + } + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param execution_id + if err := r.SetPathParam("execution_id", swag.FormatInt64(o.ExecutionID)); err != nil { + return err + } + + // path param project_name_or_id + if err := r.SetPathParam("project_name_or_id", o.ProjectNameOrID); err != nil { + return err + } + + // path param task_id + if err := r.SetPathParam("task_id", swag.FormatInt64(o.TaskID)); err != nil { + return err + } + + // path param webhook_policy_id + if err := r.SetPathParam("webhook_policy_id", swag.FormatInt64(o.WebhookPolicyID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/webhook/get_logs_of_webhook_task_responses.go b/pkg/harbor/client/webhook/get_logs_of_webhook_task_responses.go new file mode 100644 index 0000000..cf7c5e8 --- /dev/null +++ b/pkg/harbor/client/webhook/get_logs_of_webhook_task_responses.go @@ -0,0 +1,543 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// GetLogsOfWebhookTaskReader is a Reader for the GetLogsOfWebhookTask structure. +type GetLogsOfWebhookTaskReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetLogsOfWebhookTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetLogsOfWebhookTaskOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewGetLogsOfWebhookTaskBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewGetLogsOfWebhookTaskUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetLogsOfWebhookTaskForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewGetLogsOfWebhookTaskNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetLogsOfWebhookTaskInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log] GetLogsOfWebhookTask", response, response.Code()) + } +} + +// NewGetLogsOfWebhookTaskOK creates a GetLogsOfWebhookTaskOK with default headers values +func NewGetLogsOfWebhookTaskOK() *GetLogsOfWebhookTaskOK { + return &GetLogsOfWebhookTaskOK{} +} + +/* +GetLogsOfWebhookTaskOK describes a response with status code 200, with default header values. + +Get log success +*/ +type GetLogsOfWebhookTaskOK struct { + + /* Content type of response + */ + ContentType string + + Payload string +} + +// IsSuccess returns true when this get logs of webhook task o k response has a 2xx status code +func (o *GetLogsOfWebhookTaskOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get logs of webhook task o k response has a 3xx status code +func (o *GetLogsOfWebhookTaskOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task o k response has a 4xx status code +func (o *GetLogsOfWebhookTaskOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get logs of webhook task o k response has a 5xx status code +func (o *GetLogsOfWebhookTaskOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get logs of webhook task o k response a status code equal to that given +func (o *GetLogsOfWebhookTaskOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get logs of webhook task o k response +func (o *GetLogsOfWebhookTaskOK) Code() int { + return 200 +} + +func (o *GetLogsOfWebhookTaskOK) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskOK %+v", 200, o.Payload) +} + +func (o *GetLogsOfWebhookTaskOK) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskOK %+v", 200, o.Payload) +} + +func (o *GetLogsOfWebhookTaskOK) GetPayload() string { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Content-Type + hdrContentType := response.GetHeader("Content-Type") + + if hdrContentType != "" { + o.ContentType = hdrContentType + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogsOfWebhookTaskBadRequest creates a GetLogsOfWebhookTaskBadRequest with default headers values +func NewGetLogsOfWebhookTaskBadRequest() *GetLogsOfWebhookTaskBadRequest { + return &GetLogsOfWebhookTaskBadRequest{} +} + +/* +GetLogsOfWebhookTaskBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type GetLogsOfWebhookTaskBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get logs of webhook task bad request response has a 2xx status code +func (o *GetLogsOfWebhookTaskBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get logs of webhook task bad request response has a 3xx status code +func (o *GetLogsOfWebhookTaskBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task bad request response has a 4xx status code +func (o *GetLogsOfWebhookTaskBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this get logs of webhook task bad request response has a 5xx status code +func (o *GetLogsOfWebhookTaskBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this get logs of webhook task bad request response a status code equal to that given +func (o *GetLogsOfWebhookTaskBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the get logs of webhook task bad request response +func (o *GetLogsOfWebhookTaskBadRequest) Code() int { + return 400 +} + +func (o *GetLogsOfWebhookTaskBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskBadRequest %+v", 400, o.Payload) +} + +func (o *GetLogsOfWebhookTaskBadRequest) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskBadRequest %+v", 400, o.Payload) +} + +func (o *GetLogsOfWebhookTaskBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogsOfWebhookTaskUnauthorized creates a GetLogsOfWebhookTaskUnauthorized with default headers values +func NewGetLogsOfWebhookTaskUnauthorized() *GetLogsOfWebhookTaskUnauthorized { + return &GetLogsOfWebhookTaskUnauthorized{} +} + +/* +GetLogsOfWebhookTaskUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type GetLogsOfWebhookTaskUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get logs of webhook task unauthorized response has a 2xx status code +func (o *GetLogsOfWebhookTaskUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get logs of webhook task unauthorized response has a 3xx status code +func (o *GetLogsOfWebhookTaskUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task unauthorized response has a 4xx status code +func (o *GetLogsOfWebhookTaskUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get logs of webhook task unauthorized response has a 5xx status code +func (o *GetLogsOfWebhookTaskUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get logs of webhook task unauthorized response a status code equal to that given +func (o *GetLogsOfWebhookTaskUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get logs of webhook task unauthorized response +func (o *GetLogsOfWebhookTaskUnauthorized) Code() int { + return 401 +} + +func (o *GetLogsOfWebhookTaskUnauthorized) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskUnauthorized %+v", 401, o.Payload) +} + +func (o *GetLogsOfWebhookTaskUnauthorized) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskUnauthorized %+v", 401, o.Payload) +} + +func (o *GetLogsOfWebhookTaskUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogsOfWebhookTaskForbidden creates a GetLogsOfWebhookTaskForbidden with default headers values +func NewGetLogsOfWebhookTaskForbidden() *GetLogsOfWebhookTaskForbidden { + return &GetLogsOfWebhookTaskForbidden{} +} + +/* +GetLogsOfWebhookTaskForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetLogsOfWebhookTaskForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get logs of webhook task forbidden response has a 2xx status code +func (o *GetLogsOfWebhookTaskForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get logs of webhook task forbidden response has a 3xx status code +func (o *GetLogsOfWebhookTaskForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task forbidden response has a 4xx status code +func (o *GetLogsOfWebhookTaskForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get logs of webhook task forbidden response has a 5xx status code +func (o *GetLogsOfWebhookTaskForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get logs of webhook task forbidden response a status code equal to that given +func (o *GetLogsOfWebhookTaskForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get logs of webhook task forbidden response +func (o *GetLogsOfWebhookTaskForbidden) Code() int { + return 403 +} + +func (o *GetLogsOfWebhookTaskForbidden) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskForbidden %+v", 403, o.Payload) +} + +func (o *GetLogsOfWebhookTaskForbidden) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskForbidden %+v", 403, o.Payload) +} + +func (o *GetLogsOfWebhookTaskForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogsOfWebhookTaskNotFound creates a GetLogsOfWebhookTaskNotFound with default headers values +func NewGetLogsOfWebhookTaskNotFound() *GetLogsOfWebhookTaskNotFound { + return &GetLogsOfWebhookTaskNotFound{} +} + +/* +GetLogsOfWebhookTaskNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type GetLogsOfWebhookTaskNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get logs of webhook task not found response has a 2xx status code +func (o *GetLogsOfWebhookTaskNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get logs of webhook task not found response has a 3xx status code +func (o *GetLogsOfWebhookTaskNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task not found response has a 4xx status code +func (o *GetLogsOfWebhookTaskNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get logs of webhook task not found response has a 5xx status code +func (o *GetLogsOfWebhookTaskNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get logs of webhook task not found response a status code equal to that given +func (o *GetLogsOfWebhookTaskNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get logs of webhook task not found response +func (o *GetLogsOfWebhookTaskNotFound) Code() int { + return 404 +} + +func (o *GetLogsOfWebhookTaskNotFound) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskNotFound %+v", 404, o.Payload) +} + +func (o *GetLogsOfWebhookTaskNotFound) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskNotFound %+v", 404, o.Payload) +} + +func (o *GetLogsOfWebhookTaskNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetLogsOfWebhookTaskInternalServerError creates a GetLogsOfWebhookTaskInternalServerError with default headers values +func NewGetLogsOfWebhookTaskInternalServerError() *GetLogsOfWebhookTaskInternalServerError { + return &GetLogsOfWebhookTaskInternalServerError{} +} + +/* +GetLogsOfWebhookTaskInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetLogsOfWebhookTaskInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this get logs of webhook task internal server error response has a 2xx status code +func (o *GetLogsOfWebhookTaskInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get logs of webhook task internal server error response has a 3xx status code +func (o *GetLogsOfWebhookTaskInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get logs of webhook task internal server error response has a 4xx status code +func (o *GetLogsOfWebhookTaskInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get logs of webhook task internal server error response has a 5xx status code +func (o *GetLogsOfWebhookTaskInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get logs of webhook task internal server error response a status code equal to that given +func (o *GetLogsOfWebhookTaskInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get logs of webhook task internal server error response +func (o *GetLogsOfWebhookTaskInternalServerError) Code() int { + return 500 +} + +func (o *GetLogsOfWebhookTaskInternalServerError) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskInternalServerError %+v", 500, o.Payload) +} + +func (o *GetLogsOfWebhookTaskInternalServerError) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log][%d] getLogsOfWebhookTaskInternalServerError %+v", 500, o.Payload) +} + +func (o *GetLogsOfWebhookTaskInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *GetLogsOfWebhookTaskInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/webhook/list_executions_of_webhook_policy_parameters.go b/pkg/harbor/client/webhook/list_executions_of_webhook_policy_parameters.go new file mode 100644 index 0000000..1aa57b4 --- /dev/null +++ b/pkg/harbor/client/webhook/list_executions_of_webhook_policy_parameters.go @@ -0,0 +1,385 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListExecutionsOfWebhookPolicyParams creates a new ListExecutionsOfWebhookPolicyParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListExecutionsOfWebhookPolicyParams() *ListExecutionsOfWebhookPolicyParams { + return &ListExecutionsOfWebhookPolicyParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListExecutionsOfWebhookPolicyParamsWithTimeout creates a new ListExecutionsOfWebhookPolicyParams object +// with the ability to set a timeout on a request. +func NewListExecutionsOfWebhookPolicyParamsWithTimeout(timeout time.Duration) *ListExecutionsOfWebhookPolicyParams { + return &ListExecutionsOfWebhookPolicyParams{ + timeout: timeout, + } +} + +// NewListExecutionsOfWebhookPolicyParamsWithContext creates a new ListExecutionsOfWebhookPolicyParams object +// with the ability to set a context for a request. +func NewListExecutionsOfWebhookPolicyParamsWithContext(ctx context.Context) *ListExecutionsOfWebhookPolicyParams { + return &ListExecutionsOfWebhookPolicyParams{ + Context: ctx, + } +} + +// NewListExecutionsOfWebhookPolicyParamsWithHTTPClient creates a new ListExecutionsOfWebhookPolicyParams object +// with the ability to set a custom HTTPClient for a request. +func NewListExecutionsOfWebhookPolicyParamsWithHTTPClient(client *http.Client) *ListExecutionsOfWebhookPolicyParams { + return &ListExecutionsOfWebhookPolicyParams{ + HTTPClient: client, + } +} + +/* +ListExecutionsOfWebhookPolicyParams contains all the parameters to send to the API endpoint + + for the list executions of webhook policy operation. + + Typically these are written to a http.Request. +*/ +type ListExecutionsOfWebhookPolicyParams struct { + + /* XIsResourceName. + + The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + */ + XIsResourceName *bool `js:"xIsResourceName"` + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + /* ProjectNameOrID. + + The name or id of the project + */ + ProjectNameOrID string `js:"projectNameOrID"` + + /* Q. + + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + */ + Q *string `js:"q"` + + /* Sort. + + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" + */ + Sort *string `js:"sort"` + + /* WebhookPolicyID. + + The ID of the webhook policy + + Format: int64 + */ + WebhookPolicyID int64 `js:"webhookPolicyID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list executions of webhook policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListExecutionsOfWebhookPolicyParams) WithDefaults() *ListExecutionsOfWebhookPolicyParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list executions of webhook policy params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListExecutionsOfWebhookPolicyParams) SetDefaults() { + var ( + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := ListExecutionsOfWebhookPolicyParams{ + XIsResourceName: &xIsResourceNameDefault, + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithTimeout(timeout time.Duration) *ListExecutionsOfWebhookPolicyParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithContext(ctx context.Context) *ListExecutionsOfWebhookPolicyParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithHTTPClient(client *http.Client) *ListExecutionsOfWebhookPolicyParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXIsResourceName adds the xIsResourceName to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithXIsResourceName(xIsResourceName *bool) *ListExecutionsOfWebhookPolicyParams { + o.SetXIsResourceName(xIsResourceName) + return o +} + +// SetXIsResourceName adds the xIsResourceName to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetXIsResourceName(xIsResourceName *bool) { + o.XIsResourceName = xIsResourceName +} + +// WithXRequestID adds the xRequestID to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithXRequestID(xRequestID *string) *ListExecutionsOfWebhookPolicyParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithPage adds the page to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithPage(page *int64) *ListExecutionsOfWebhookPolicyParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithPageSize(pageSize *int64) *ListExecutionsOfWebhookPolicyParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithProjectNameOrID adds the projectNameOrID to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithProjectNameOrID(projectNameOrID string) *ListExecutionsOfWebhookPolicyParams { + o.SetProjectNameOrID(projectNameOrID) + return o +} + +// SetProjectNameOrID adds the projectNameOrId to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetProjectNameOrID(projectNameOrID string) { + o.ProjectNameOrID = projectNameOrID +} + +// WithQ adds the q to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithQ(q *string) *ListExecutionsOfWebhookPolicyParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetQ(q *string) { + o.Q = q +} + +// WithSort adds the sort to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithSort(sort *string) *ListExecutionsOfWebhookPolicyParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetSort(sort *string) { + o.Sort = sort +} + +// WithWebhookPolicyID adds the webhookPolicyID to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) WithWebhookPolicyID(webhookPolicyID int64) *ListExecutionsOfWebhookPolicyParams { + o.SetWebhookPolicyID(webhookPolicyID) + return o +} + +// SetWebhookPolicyID adds the webhookPolicyId to the list executions of webhook policy params +func (o *ListExecutionsOfWebhookPolicyParams) SetWebhookPolicyID(webhookPolicyID int64) { + o.WebhookPolicyID = webhookPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListExecutionsOfWebhookPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XIsResourceName != nil { + + // header param X-Is-Resource-Name + if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil { + return err + } + } + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + // path param project_name_or_id + if err := r.SetPathParam("project_name_or_id", o.ProjectNameOrID); err != nil { + return err + } + + if o.Q != nil { + + // query param q + var qrQ string + + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + } + + if o.Sort != nil { + + // query param sort + var qrSort string + + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + } + + // path param webhook_policy_id + if err := r.SetPathParam("webhook_policy_id", swag.FormatInt64(o.WebhookPolicyID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/webhook/list_executions_of_webhook_policy_responses.go b/pkg/harbor/client/webhook/list_executions_of_webhook_policy_responses.go new file mode 100644 index 0000000..d3775c3 --- /dev/null +++ b/pkg/harbor/client/webhook/list_executions_of_webhook_policy_responses.go @@ -0,0 +1,560 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListExecutionsOfWebhookPolicyReader is a Reader for the ListExecutionsOfWebhookPolicy structure. +type ListExecutionsOfWebhookPolicyReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListExecutionsOfWebhookPolicyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListExecutionsOfWebhookPolicyOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListExecutionsOfWebhookPolicyBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListExecutionsOfWebhookPolicyUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListExecutionsOfWebhookPolicyForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListExecutionsOfWebhookPolicyNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListExecutionsOfWebhookPolicyInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions] ListExecutionsOfWebhookPolicy", response, response.Code()) + } +} + +// NewListExecutionsOfWebhookPolicyOK creates a ListExecutionsOfWebhookPolicyOK with default headers values +func NewListExecutionsOfWebhookPolicyOK() *ListExecutionsOfWebhookPolicyOK { + return &ListExecutionsOfWebhookPolicyOK{} +} + +/* +ListExecutionsOfWebhookPolicyOK describes a response with status code 200, with default header values. + +List webhook executions success +*/ +type ListExecutionsOfWebhookPolicyOK struct { + + /* Link refers to the previous page and next page + */ + Link string + + /* The total count of executions + */ + XTotalCount int64 + + Payload []*models.Execution +} + +// IsSuccess returns true when this list executions of webhook policy o k response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list executions of webhook policy o k response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy o k response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list executions of webhook policy o k response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list executions of webhook policy o k response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list executions of webhook policy o k response +func (o *ListExecutionsOfWebhookPolicyOK) Code() int { + return 200 +} + +func (o *ListExecutionsOfWebhookPolicyOK) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyOK %+v", 200, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyOK) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyOK %+v", 200, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyOK) GetPayload() []*models.Execution { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListExecutionsOfWebhookPolicyBadRequest creates a ListExecutionsOfWebhookPolicyBadRequest with default headers values +func NewListExecutionsOfWebhookPolicyBadRequest() *ListExecutionsOfWebhookPolicyBadRequest { + return &ListExecutionsOfWebhookPolicyBadRequest{} +} + +/* +ListExecutionsOfWebhookPolicyBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type ListExecutionsOfWebhookPolicyBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list executions of webhook policy bad request response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list executions of webhook policy bad request response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy bad request response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list executions of webhook policy bad request response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list executions of webhook policy bad request response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list executions of webhook policy bad request response +func (o *ListExecutionsOfWebhookPolicyBadRequest) Code() int { + return 400 +} + +func (o *ListExecutionsOfWebhookPolicyBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyBadRequest %+v", 400, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyBadRequest) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyBadRequest %+v", 400, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListExecutionsOfWebhookPolicyUnauthorized creates a ListExecutionsOfWebhookPolicyUnauthorized with default headers values +func NewListExecutionsOfWebhookPolicyUnauthorized() *ListExecutionsOfWebhookPolicyUnauthorized { + return &ListExecutionsOfWebhookPolicyUnauthorized{} +} + +/* +ListExecutionsOfWebhookPolicyUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListExecutionsOfWebhookPolicyUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list executions of webhook policy unauthorized response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list executions of webhook policy unauthorized response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy unauthorized response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list executions of webhook policy unauthorized response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list executions of webhook policy unauthorized response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list executions of webhook policy unauthorized response +func (o *ListExecutionsOfWebhookPolicyUnauthorized) Code() int { + return 401 +} + +func (o *ListExecutionsOfWebhookPolicyUnauthorized) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyUnauthorized %+v", 401, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyUnauthorized) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyUnauthorized %+v", 401, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListExecutionsOfWebhookPolicyForbidden creates a ListExecutionsOfWebhookPolicyForbidden with default headers values +func NewListExecutionsOfWebhookPolicyForbidden() *ListExecutionsOfWebhookPolicyForbidden { + return &ListExecutionsOfWebhookPolicyForbidden{} +} + +/* +ListExecutionsOfWebhookPolicyForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ListExecutionsOfWebhookPolicyForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list executions of webhook policy forbidden response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list executions of webhook policy forbidden response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy forbidden response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list executions of webhook policy forbidden response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list executions of webhook policy forbidden response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list executions of webhook policy forbidden response +func (o *ListExecutionsOfWebhookPolicyForbidden) Code() int { + return 403 +} + +func (o *ListExecutionsOfWebhookPolicyForbidden) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyForbidden %+v", 403, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyForbidden) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyForbidden %+v", 403, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListExecutionsOfWebhookPolicyNotFound creates a ListExecutionsOfWebhookPolicyNotFound with default headers values +func NewListExecutionsOfWebhookPolicyNotFound() *ListExecutionsOfWebhookPolicyNotFound { + return &ListExecutionsOfWebhookPolicyNotFound{} +} + +/* +ListExecutionsOfWebhookPolicyNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ListExecutionsOfWebhookPolicyNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list executions of webhook policy not found response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list executions of webhook policy not found response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy not found response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list executions of webhook policy not found response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list executions of webhook policy not found response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list executions of webhook policy not found response +func (o *ListExecutionsOfWebhookPolicyNotFound) Code() int { + return 404 +} + +func (o *ListExecutionsOfWebhookPolicyNotFound) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyNotFound %+v", 404, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyNotFound) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyNotFound %+v", 404, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListExecutionsOfWebhookPolicyInternalServerError creates a ListExecutionsOfWebhookPolicyInternalServerError with default headers values +func NewListExecutionsOfWebhookPolicyInternalServerError() *ListExecutionsOfWebhookPolicyInternalServerError { + return &ListExecutionsOfWebhookPolicyInternalServerError{} +} + +/* +ListExecutionsOfWebhookPolicyInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListExecutionsOfWebhookPolicyInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list executions of webhook policy internal server error response has a 2xx status code +func (o *ListExecutionsOfWebhookPolicyInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list executions of webhook policy internal server error response has a 3xx status code +func (o *ListExecutionsOfWebhookPolicyInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list executions of webhook policy internal server error response has a 4xx status code +func (o *ListExecutionsOfWebhookPolicyInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list executions of webhook policy internal server error response has a 5xx status code +func (o *ListExecutionsOfWebhookPolicyInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list executions of webhook policy internal server error response a status code equal to that given +func (o *ListExecutionsOfWebhookPolicyInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list executions of webhook policy internal server error response +func (o *ListExecutionsOfWebhookPolicyInternalServerError) Code() int { + return 500 +} + +func (o *ListExecutionsOfWebhookPolicyInternalServerError) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyInternalServerError %+v", 500, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyInternalServerError) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions][%d] listExecutionsOfWebhookPolicyInternalServerError %+v", 500, o.Payload) +} + +func (o *ListExecutionsOfWebhookPolicyInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListExecutionsOfWebhookPolicyInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_parameters.go b/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_parameters.go new file mode 100644 index 0000000..e1a5549 --- /dev/null +++ b/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_parameters.go @@ -0,0 +1,407 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListTasksOfWebhookExecutionParams creates a new ListTasksOfWebhookExecutionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListTasksOfWebhookExecutionParams() *ListTasksOfWebhookExecutionParams { + return &ListTasksOfWebhookExecutionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListTasksOfWebhookExecutionParamsWithTimeout creates a new ListTasksOfWebhookExecutionParams object +// with the ability to set a timeout on a request. +func NewListTasksOfWebhookExecutionParamsWithTimeout(timeout time.Duration) *ListTasksOfWebhookExecutionParams { + return &ListTasksOfWebhookExecutionParams{ + timeout: timeout, + } +} + +// NewListTasksOfWebhookExecutionParamsWithContext creates a new ListTasksOfWebhookExecutionParams object +// with the ability to set a context for a request. +func NewListTasksOfWebhookExecutionParamsWithContext(ctx context.Context) *ListTasksOfWebhookExecutionParams { + return &ListTasksOfWebhookExecutionParams{ + Context: ctx, + } +} + +// NewListTasksOfWebhookExecutionParamsWithHTTPClient creates a new ListTasksOfWebhookExecutionParams object +// with the ability to set a custom HTTPClient for a request. +func NewListTasksOfWebhookExecutionParamsWithHTTPClient(client *http.Client) *ListTasksOfWebhookExecutionParams { + return &ListTasksOfWebhookExecutionParams{ + HTTPClient: client, + } +} + +/* +ListTasksOfWebhookExecutionParams contains all the parameters to send to the API endpoint + + for the list tasks of webhook execution operation. + + Typically these are written to a http.Request. +*/ +type ListTasksOfWebhookExecutionParams struct { + + /* XIsResourceName. + + The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. + */ + XIsResourceName *bool `js:"xIsResourceName"` + + /* XRequestID. + + An unique ID for the request + */ + XRequestID *string `js:"xRequestID"` + + /* ExecutionID. + + Execution ID + */ + ExecutionID int64 `js:"executionID"` + + /* Page. + + The page number + + Format: int64 + Default: 1 + */ + Page *int64 `js:"page"` + + /* PageSize. + + The size of per page + + Format: int64 + Default: 10 + */ + PageSize *int64 `js:"pageSize"` + + /* ProjectNameOrID. + + The name or id of the project + */ + ProjectNameOrID string `js:"projectNameOrID"` + + /* Q. + + Query string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max] + */ + Q *string `js:"q"` + + /* Sort. + + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" + */ + Sort *string `js:"sort"` + + /* WebhookPolicyID. + + The ID of the webhook policy + + Format: int64 + */ + WebhookPolicyID int64 `js:"webhookPolicyID"` + + timeout time.Duration + Context context.Context `js:"context"` + HTTPClient *http.Client `js:"httpClient"` +} + +// WithDefaults hydrates default values in the list tasks of webhook execution params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListTasksOfWebhookExecutionParams) WithDefaults() *ListTasksOfWebhookExecutionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list tasks of webhook execution params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListTasksOfWebhookExecutionParams) SetDefaults() { + var ( + xIsResourceNameDefault = bool(false) + + pageDefault = int64(1) + + pageSizeDefault = int64(10) + ) + + val := ListTasksOfWebhookExecutionParams{ + XIsResourceName: &xIsResourceNameDefault, + Page: &pageDefault, + PageSize: &pageSizeDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val +} + +// WithTimeout adds the timeout to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithTimeout(timeout time.Duration) *ListTasksOfWebhookExecutionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithContext(ctx context.Context) *ListTasksOfWebhookExecutionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithHTTPClient(client *http.Client) *ListTasksOfWebhookExecutionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithXIsResourceName adds the xIsResourceName to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithXIsResourceName(xIsResourceName *bool) *ListTasksOfWebhookExecutionParams { + o.SetXIsResourceName(xIsResourceName) + return o +} + +// SetXIsResourceName adds the xIsResourceName to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetXIsResourceName(xIsResourceName *bool) { + o.XIsResourceName = xIsResourceName +} + +// WithXRequestID adds the xRequestID to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithXRequestID(xRequestID *string) *ListTasksOfWebhookExecutionParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + +// WithExecutionID adds the executionID to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithExecutionID(executionID int64) *ListTasksOfWebhookExecutionParams { + o.SetExecutionID(executionID) + return o +} + +// SetExecutionID adds the executionId to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetExecutionID(executionID int64) { + o.ExecutionID = executionID +} + +// WithPage adds the page to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithPage(page *int64) *ListTasksOfWebhookExecutionParams { + o.SetPage(page) + return o +} + +// SetPage adds the page to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetPage(page *int64) { + o.Page = page +} + +// WithPageSize adds the pageSize to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithPageSize(pageSize *int64) *ListTasksOfWebhookExecutionParams { + o.SetPageSize(pageSize) + return o +} + +// SetPageSize adds the pageSize to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetPageSize(pageSize *int64) { + o.PageSize = pageSize +} + +// WithProjectNameOrID adds the projectNameOrID to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithProjectNameOrID(projectNameOrID string) *ListTasksOfWebhookExecutionParams { + o.SetProjectNameOrID(projectNameOrID) + return o +} + +// SetProjectNameOrID adds the projectNameOrId to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetProjectNameOrID(projectNameOrID string) { + o.ProjectNameOrID = projectNameOrID +} + +// WithQ adds the q to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithQ(q *string) *ListTasksOfWebhookExecutionParams { + o.SetQ(q) + return o +} + +// SetQ adds the q to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetQ(q *string) { + o.Q = q +} + +// WithSort adds the sort to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithSort(sort *string) *ListTasksOfWebhookExecutionParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetSort(sort *string) { + o.Sort = sort +} + +// WithWebhookPolicyID adds the webhookPolicyID to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) WithWebhookPolicyID(webhookPolicyID int64) *ListTasksOfWebhookExecutionParams { + o.SetWebhookPolicyID(webhookPolicyID) + return o +} + +// SetWebhookPolicyID adds the webhookPolicyId to the list tasks of webhook execution params +func (o *ListTasksOfWebhookExecutionParams) SetWebhookPolicyID(webhookPolicyID int64) { + o.WebhookPolicyID = webhookPolicyID +} + +// WriteToRequest writes these params to a swagger request +func (o *ListTasksOfWebhookExecutionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.XIsResourceName != nil { + + // header param X-Is-Resource-Name + if err := r.SetHeaderParam("X-Is-Resource-Name", swag.FormatBool(*o.XIsResourceName)); err != nil { + return err + } + } + + if o.XRequestID != nil { + + // header param X-Request-Id + if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil { + return err + } + } + + // path param execution_id + if err := r.SetPathParam("execution_id", swag.FormatInt64(o.ExecutionID)); err != nil { + return err + } + + if o.Page != nil { + + // query param page + var qrPage int64 + + if o.Page != nil { + qrPage = *o.Page + } + qPage := swag.FormatInt64(qrPage) + if qPage != "" { + + if err := r.SetQueryParam("page", qPage); err != nil { + return err + } + } + } + + if o.PageSize != nil { + + // query param page_size + var qrPageSize int64 + + if o.PageSize != nil { + qrPageSize = *o.PageSize + } + qPageSize := swag.FormatInt64(qrPageSize) + if qPageSize != "" { + + if err := r.SetQueryParam("page_size", qPageSize); err != nil { + return err + } + } + } + + // path param project_name_or_id + if err := r.SetPathParam("project_name_or_id", o.ProjectNameOrID); err != nil { + return err + } + + if o.Q != nil { + + // query param q + var qrQ string + + if o.Q != nil { + qrQ = *o.Q + } + qQ := qrQ + if qQ != "" { + + if err := r.SetQueryParam("q", qQ); err != nil { + return err + } + } + } + + if o.Sort != nil { + + // query param sort + var qrSort string + + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + } + + // path param webhook_policy_id + if err := r.SetPathParam("webhook_policy_id", swag.FormatInt64(o.WebhookPolicyID)); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_responses.go b/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_responses.go new file mode 100644 index 0000000..6b1f50f --- /dev/null +++ b/pkg/harbor/client/webhook/list_tasks_of_webhook_execution_responses.go @@ -0,0 +1,560 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package webhook + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/goharbor/xk6-harbor/pkg/harbor/models" +) + +// ListTasksOfWebhookExecutionReader is a Reader for the ListTasksOfWebhookExecution structure. +type ListTasksOfWebhookExecutionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListTasksOfWebhookExecutionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListTasksOfWebhookExecutionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListTasksOfWebhookExecutionBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListTasksOfWebhookExecutionUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewListTasksOfWebhookExecutionForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewListTasksOfWebhookExecutionNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListTasksOfWebhookExecutionInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks] ListTasksOfWebhookExecution", response, response.Code()) + } +} + +// NewListTasksOfWebhookExecutionOK creates a ListTasksOfWebhookExecutionOK with default headers values +func NewListTasksOfWebhookExecutionOK() *ListTasksOfWebhookExecutionOK { + return &ListTasksOfWebhookExecutionOK{} +} + +/* +ListTasksOfWebhookExecutionOK describes a response with status code 200, with default header values. + +List tasks of webhook executions success +*/ +type ListTasksOfWebhookExecutionOK struct { + + /* Link refers to the previous page and next page + */ + Link string + + /* The total count of tasks + */ + XTotalCount int64 + + Payload []*models.Task +} + +// IsSuccess returns true when this list tasks of webhook execution o k response has a 2xx status code +func (o *ListTasksOfWebhookExecutionOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list tasks of webhook execution o k response has a 3xx status code +func (o *ListTasksOfWebhookExecutionOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution o k response has a 4xx status code +func (o *ListTasksOfWebhookExecutionOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list tasks of webhook execution o k response has a 5xx status code +func (o *ListTasksOfWebhookExecutionOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list tasks of webhook execution o k response a status code equal to that given +func (o *ListTasksOfWebhookExecutionOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list tasks of webhook execution o k response +func (o *ListTasksOfWebhookExecutionOK) Code() int { + return 200 +} + +func (o *ListTasksOfWebhookExecutionOK) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionOK %+v", 200, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionOK) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionOK %+v", 200, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionOK) GetPayload() []*models.Task { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header Link + hdrLink := response.GetHeader("Link") + + if hdrLink != "" { + o.Link = hdrLink + } + + // hydrates response header X-Total-Count + hdrXTotalCount := response.GetHeader("X-Total-Count") + + if hdrXTotalCount != "" { + valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) + if err != nil { + return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) + } + o.XTotalCount = valxTotalCount + } + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListTasksOfWebhookExecutionBadRequest creates a ListTasksOfWebhookExecutionBadRequest with default headers values +func NewListTasksOfWebhookExecutionBadRequest() *ListTasksOfWebhookExecutionBadRequest { + return &ListTasksOfWebhookExecutionBadRequest{} +} + +/* +ListTasksOfWebhookExecutionBadRequest describes a response with status code 400, with default header values. + +Bad request +*/ +type ListTasksOfWebhookExecutionBadRequest struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list tasks of webhook execution bad request response has a 2xx status code +func (o *ListTasksOfWebhookExecutionBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list tasks of webhook execution bad request response has a 3xx status code +func (o *ListTasksOfWebhookExecutionBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution bad request response has a 4xx status code +func (o *ListTasksOfWebhookExecutionBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this list tasks of webhook execution bad request response has a 5xx status code +func (o *ListTasksOfWebhookExecutionBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this list tasks of webhook execution bad request response a status code equal to that given +func (o *ListTasksOfWebhookExecutionBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the list tasks of webhook execution bad request response +func (o *ListTasksOfWebhookExecutionBadRequest) Code() int { + return 400 +} + +func (o *ListTasksOfWebhookExecutionBadRequest) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionBadRequest %+v", 400, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionBadRequest) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionBadRequest %+v", 400, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionBadRequest) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListTasksOfWebhookExecutionUnauthorized creates a ListTasksOfWebhookExecutionUnauthorized with default headers values +func NewListTasksOfWebhookExecutionUnauthorized() *ListTasksOfWebhookExecutionUnauthorized { + return &ListTasksOfWebhookExecutionUnauthorized{} +} + +/* +ListTasksOfWebhookExecutionUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type ListTasksOfWebhookExecutionUnauthorized struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list tasks of webhook execution unauthorized response has a 2xx status code +func (o *ListTasksOfWebhookExecutionUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list tasks of webhook execution unauthorized response has a 3xx status code +func (o *ListTasksOfWebhookExecutionUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution unauthorized response has a 4xx status code +func (o *ListTasksOfWebhookExecutionUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list tasks of webhook execution unauthorized response has a 5xx status code +func (o *ListTasksOfWebhookExecutionUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list tasks of webhook execution unauthorized response a status code equal to that given +func (o *ListTasksOfWebhookExecutionUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list tasks of webhook execution unauthorized response +func (o *ListTasksOfWebhookExecutionUnauthorized) Code() int { + return 401 +} + +func (o *ListTasksOfWebhookExecutionUnauthorized) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionUnauthorized %+v", 401, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionUnauthorized) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionUnauthorized %+v", 401, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionUnauthorized) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListTasksOfWebhookExecutionForbidden creates a ListTasksOfWebhookExecutionForbidden with default headers values +func NewListTasksOfWebhookExecutionForbidden() *ListTasksOfWebhookExecutionForbidden { + return &ListTasksOfWebhookExecutionForbidden{} +} + +/* +ListTasksOfWebhookExecutionForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type ListTasksOfWebhookExecutionForbidden struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list tasks of webhook execution forbidden response has a 2xx status code +func (o *ListTasksOfWebhookExecutionForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list tasks of webhook execution forbidden response has a 3xx status code +func (o *ListTasksOfWebhookExecutionForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution forbidden response has a 4xx status code +func (o *ListTasksOfWebhookExecutionForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this list tasks of webhook execution forbidden response has a 5xx status code +func (o *ListTasksOfWebhookExecutionForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this list tasks of webhook execution forbidden response a status code equal to that given +func (o *ListTasksOfWebhookExecutionForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the list tasks of webhook execution forbidden response +func (o *ListTasksOfWebhookExecutionForbidden) Code() int { + return 403 +} + +func (o *ListTasksOfWebhookExecutionForbidden) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionForbidden %+v", 403, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionForbidden) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionForbidden %+v", 403, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionForbidden) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListTasksOfWebhookExecutionNotFound creates a ListTasksOfWebhookExecutionNotFound with default headers values +func NewListTasksOfWebhookExecutionNotFound() *ListTasksOfWebhookExecutionNotFound { + return &ListTasksOfWebhookExecutionNotFound{} +} + +/* +ListTasksOfWebhookExecutionNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type ListTasksOfWebhookExecutionNotFound struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list tasks of webhook execution not found response has a 2xx status code +func (o *ListTasksOfWebhookExecutionNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list tasks of webhook execution not found response has a 3xx status code +func (o *ListTasksOfWebhookExecutionNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution not found response has a 4xx status code +func (o *ListTasksOfWebhookExecutionNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this list tasks of webhook execution not found response has a 5xx status code +func (o *ListTasksOfWebhookExecutionNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this list tasks of webhook execution not found response a status code equal to that given +func (o *ListTasksOfWebhookExecutionNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the list tasks of webhook execution not found response +func (o *ListTasksOfWebhookExecutionNotFound) Code() int { + return 404 +} + +func (o *ListTasksOfWebhookExecutionNotFound) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionNotFound %+v", 404, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionNotFound) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionNotFound %+v", 404, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionNotFound) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListTasksOfWebhookExecutionInternalServerError creates a ListTasksOfWebhookExecutionInternalServerError with default headers values +func NewListTasksOfWebhookExecutionInternalServerError() *ListTasksOfWebhookExecutionInternalServerError { + return &ListTasksOfWebhookExecutionInternalServerError{} +} + +/* +ListTasksOfWebhookExecutionInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type ListTasksOfWebhookExecutionInternalServerError struct { + + /* The ID of the corresponding request for the response + */ + XRequestID string + + Payload *models.Errors +} + +// IsSuccess returns true when this list tasks of webhook execution internal server error response has a 2xx status code +func (o *ListTasksOfWebhookExecutionInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list tasks of webhook execution internal server error response has a 3xx status code +func (o *ListTasksOfWebhookExecutionInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list tasks of webhook execution internal server error response has a 4xx status code +func (o *ListTasksOfWebhookExecutionInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list tasks of webhook execution internal server error response has a 5xx status code +func (o *ListTasksOfWebhookExecutionInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list tasks of webhook execution internal server error response a status code equal to that given +func (o *ListTasksOfWebhookExecutionInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list tasks of webhook execution internal server error response +func (o *ListTasksOfWebhookExecutionInternalServerError) Code() int { + return 500 +} + +func (o *ListTasksOfWebhookExecutionInternalServerError) Error() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionInternalServerError %+v", 500, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionInternalServerError) String() string { + return fmt.Sprintf("[GET /projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks][%d] listTasksOfWebhookExecutionInternalServerError %+v", 500, o.Payload) +} + +func (o *ListTasksOfWebhookExecutionInternalServerError) GetPayload() *models.Errors { + return o.Payload +} + +func (o *ListTasksOfWebhookExecutionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // hydrates response header X-Request-Id + hdrXRequestID := response.GetHeader("X-Request-Id") + + if hdrXRequestID != "" { + o.XRequestID = hdrXRequestID + } + + o.Payload = new(models.Errors) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/harbor/client/webhook/list_webhook_policies_of_project_parameters.go b/pkg/harbor/client/webhook/list_webhook_policies_of_project_parameters.go index c806464..dd20f0c 100644 --- a/pkg/harbor/client/webhook/list_webhook_policies_of_project_parameters.go +++ b/pkg/harbor/client/webhook/list_webhook_policies_of_project_parameters.go @@ -106,7 +106,7 @@ type ListWebhookPoliciesOfProjectParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/client/webhook/webhook_client.go b/pkg/harbor/client/webhook/webhook_client.go index dddbb2d..cab8289 100644 --- a/pkg/harbor/client/webhook/webhook_client.go +++ b/pkg/harbor/client/webhook/webhook_client.go @@ -30,10 +30,16 @@ type API interface { This endpoint is aimed to delete webhookpolicy of a project. */ DeleteWebhookPolicyOfProject(ctx context.Context, params *DeleteWebhookPolicyOfProjectParams) (*DeleteWebhookPolicyOfProjectOK, error) + /* + GetLogsOfWebhookTask gets logs for a specific webhook task + + This endpoint returns the logs of a specific webhook task. + */ + GetLogsOfWebhookTask(ctx context.Context, params *GetLogsOfWebhookTaskParams) (*GetLogsOfWebhookTaskOK, error) /* GetSupportedEventTypes gets supported event types and notify types - Get supportted event types and notify types.*/ + Get supported event types and notify types.*/ GetSupportedEventTypes(ctx context.Context, params *GetSupportedEventTypesParams) (*GetSupportedEventTypesOK, error) /* GetWebhookPolicyOfProject gets project webhook policy @@ -47,6 +53,18 @@ type API interface { This endpoint returns last trigger information of project webhook policy. */ LastTrigger(ctx context.Context, params *LastTriggerParams) (*LastTriggerOK, error) + /* + ListExecutionsOfWebhookPolicy lists executions for a specific webhook policy + + This endpoint returns the executions of a specific webhook policy. + */ + ListExecutionsOfWebhookPolicy(ctx context.Context, params *ListExecutionsOfWebhookPolicyParams) (*ListExecutionsOfWebhookPolicyOK, error) + /* + ListTasksOfWebhookExecution lists tasks for a specific webhook execution + + This endpoint returns the tasks of a specific webhook execution. + */ + ListTasksOfWebhookExecution(ctx context.Context, params *ListTasksOfWebhookExecutionParams) (*ListTasksOfWebhookExecutionOK, error) /* ListWebhookPoliciesOfProject lists project webhook policies @@ -161,10 +179,52 @@ func (a *Client) DeleteWebhookPolicyOfProject(ctx context.Context, params *Delet panic(msg) } +/* +GetLogsOfWebhookTask gets logs for a specific webhook task + +This endpoint returns the logs of a specific webhook task. +*/ +func (a *Client) GetLogsOfWebhookTask(ctx context.Context, params *GetLogsOfWebhookTaskParams) (*GetLogsOfWebhookTaskOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "GetLogsOfWebhookTask", + Method: "GET", + PathPattern: "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log", + ProducesMediaTypes: []string{"text/plain"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetLogsOfWebhookTaskReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *GetLogsOfWebhookTaskOK: + return value, nil + case *GetLogsOfWebhookTaskBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetLogsOfWebhookTaskUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetLogsOfWebhookTaskForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetLogsOfWebhookTaskNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *GetLogsOfWebhookTaskInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for GetLogsOfWebhookTask: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* GetSupportedEventTypes gets supported event types and notify types -Get supportted event types and notify types. +Get supported event types and notify types. */ func (a *Client) GetSupportedEventTypes(ctx context.Context, params *GetSupportedEventTypesParams) (*GetSupportedEventTypesOK, error) { @@ -281,6 +341,90 @@ func (a *Client) LastTrigger(ctx context.Context, params *LastTriggerParams) (*L panic(msg) } +/* +ListExecutionsOfWebhookPolicy lists executions for a specific webhook policy + +This endpoint returns the executions of a specific webhook policy. +*/ +func (a *Client) ListExecutionsOfWebhookPolicy(ctx context.Context, params *ListExecutionsOfWebhookPolicyParams) (*ListExecutionsOfWebhookPolicyOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "ListExecutionsOfWebhookPolicy", + Method: "GET", + PathPattern: "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListExecutionsOfWebhookPolicyReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListExecutionsOfWebhookPolicyOK: + return value, nil + case *ListExecutionsOfWebhookPolicyBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListExecutionsOfWebhookPolicyUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListExecutionsOfWebhookPolicyForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListExecutionsOfWebhookPolicyNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListExecutionsOfWebhookPolicyInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for ListExecutionsOfWebhookPolicy: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +ListTasksOfWebhookExecution lists tasks for a specific webhook execution + +This endpoint returns the tasks of a specific webhook execution. +*/ +func (a *Client) ListTasksOfWebhookExecution(ctx context.Context, params *ListTasksOfWebhookExecutionParams) (*ListTasksOfWebhookExecutionOK, error) { + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "ListTasksOfWebhookExecution", + Method: "GET", + PathPattern: "/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListTasksOfWebhookExecutionReader{formats: a.formats}, + AuthInfo: a.authInfo, + Context: ctx, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + switch value := result.(type) { + case *ListTasksOfWebhookExecutionOK: + return value, nil + case *ListTasksOfWebhookExecutionBadRequest: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListTasksOfWebhookExecutionUnauthorized: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListTasksOfWebhookExecutionForbidden: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListTasksOfWebhookExecutionNotFound: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + case *ListTasksOfWebhookExecutionInternalServerError: + return nil, runtime.NewAPIError("unsuccessful response", value, value.Code()) + } + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for ListTasksOfWebhookExecution: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* ListWebhookPoliciesOfProject lists project webhook policies diff --git a/pkg/harbor/client/webhookjob/list_webhook_jobs_parameters.go b/pkg/harbor/client/webhookjob/list_webhook_jobs_parameters.go index d4e4254..1b0aa70 100644 --- a/pkg/harbor/client/webhookjob/list_webhook_jobs_parameters.go +++ b/pkg/harbor/client/webhookjob/list_webhook_jobs_parameters.go @@ -114,7 +114,7 @@ type ListWebhookJobsParams struct { /* Sort. - Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" */ Sort *string `js:"sort"` diff --git a/pkg/harbor/models/access.go b/pkg/harbor/models/access.go index 79375c6..9565682 100644 --- a/pkg/harbor/models/access.go +++ b/pkg/harbor/models/access.go @@ -17,13 +17,13 @@ import ( // swagger:model Access type Access struct { - // The action of the access + // The action of the access. Possible actions are *, pull, push, create, read, update, delete, list, operate, scanner-pull and stop. Action string `json:"action,omitempty" js:"action"` // The effect of the access Effect string `json:"effect,omitempty" js:"effect"` - // The resource of the access + // The resource of the access. Possible resources are listed here for system and project level https://github.com/goharbor/harbor/blob/main/src/common/rbac/const.go Resource string `json:"resource,omitempty" js:"resource"` } diff --git a/pkg/harbor/models/accessory.go b/pkg/harbor/models/accessory.go new file mode 100644 index 0000000..6f442c1 --- /dev/null +++ b/pkg/harbor/models/accessory.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Accessory The accessory of the artifact +// +// swagger:model Accessory +type Accessory struct { + + // The artifact id of the accessory + ArtifactID int64 `json:"artifact_id" js:"artifactID"` + + // The creation time of the accessory + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` + + // The artifact digest of the accessory + Digest string `json:"digest" js:"digest"` + + // The icon of the accessory + Icon string `json:"icon" js:"icon"` + + // The ID of the accessory + ID int64 `json:"id,omitempty" js:"id"` + + // The artifact size of the accessory + Size int64 `json:"size" js:"size"` + + // The subject artifact digest of the accessory + SubjectArtifactDigest string `json:"subject_artifact_digest" js:"subjectArtifactDigest"` + + // Going to be deprecated, use repo and digest for insteand. The subject artifact id of the accessory. + SubjectArtifactID int64 `json:"subject_artifact_id,omitempty" js:"subjectArtifactID"` + + // The subject artifact repository name of the accessory + SubjectArtifactRepo string `json:"subject_artifact_repo" js:"subjectArtifactRepo"` + + // The artifact size of the accessory + Type string `json:"type" js:"type"` +} + +// Validate validates this accessory +func (m *Accessory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Accessory) validateCreationTime(formats strfmt.Registry) error { + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this accessory based on context it is used +func (m *Accessory) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Accessory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Accessory) UnmarshalBinary(b []byte) error { + var res Accessory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/action_request.go b/pkg/harbor/models/action_request.go new file mode 100644 index 0000000..bd3b5f4 --- /dev/null +++ b/pkg/harbor/models/action_request.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ActionRequest The request to stop, pause or resume +// +// swagger:model ActionRequest +type ActionRequest struct { + + // The action of the request, should be stop, pause or resume + // Enum: [stop pause resume] + Action string `json:"action,omitempty" js:"action"` +} + +// Validate validates this action request +func (m *ActionRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAction(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var actionRequestTypeActionPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["stop","pause","resume"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + actionRequestTypeActionPropEnum = append(actionRequestTypeActionPropEnum, v) + } +} + +const ( + + // ActionRequestActionStop captures enum value "stop" + ActionRequestActionStop string = "stop" + + // ActionRequestActionPause captures enum value "pause" + ActionRequestActionPause string = "pause" + + // ActionRequestActionResume captures enum value "resume" + ActionRequestActionResume string = "resume" +) + +// prop value enum +func (m *ActionRequest) validateActionEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, actionRequestTypeActionPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ActionRequest) validateAction(formats strfmt.Registry) error { + if swag.IsZero(m.Action) { // not required + return nil + } + + // value enum + if err := m.validateActionEnum("action", "body", m.Action); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this action request based on context it is used +func (m *ActionRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ActionRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionRequest) UnmarshalBinary(b []byte) error { + var res ActionRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/artifact.go b/pkg/harbor/models/artifact.go index 4a04346..b6aeca8 100644 --- a/pkg/harbor/models/artifact.go +++ b/pkg/harbor/models/artifact.go @@ -20,6 +20,9 @@ import ( // swagger:model Artifact type Artifact struct { + // accessories + Accessories []*Accessory `json:"accessories" js:"accessories"` + // addition links AdditionLinks AdditionLinks `json:"addition_links,omitempty" js:"additionLinks"` @@ -64,6 +67,9 @@ type Artifact struct { // The ID of the repository that the artifact belongs to RepositoryID int64 `json:"repository_id,omitempty" js:"repositoryID"` + // The overview of the generating SBOM progress + SbomOverview *SBOMOverview `json:"sbom_overview,omitempty" js:"sbomOverview"` + // The overview of the scan result. ScanOverview ScanOverview `json:"scan_overview,omitempty" js:"scanOverview"` @@ -81,6 +87,10 @@ type Artifact struct { func (m *Artifact) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAccessories(formats); err != nil { + res = append(res, err) + } + if err := m.validateAdditionLinks(formats); err != nil { res = append(res, err) } @@ -109,6 +119,10 @@ func (m *Artifact) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSbomOverview(formats); err != nil { + res = append(res, err) + } + if err := m.validateScanOverview(formats); err != nil { res = append(res, err) } @@ -123,6 +137,32 @@ func (m *Artifact) Validate(formats strfmt.Registry) error { return nil } +func (m *Artifact) validateAccessories(formats strfmt.Registry) error { + if swag.IsZero(m.Accessories) { // not required + return nil + } + + for i := 0; i < len(m.Accessories); i++ { + if swag.IsZero(m.Accessories[i]) { // not required + continue + } + + if m.Accessories[i] != nil { + if err := m.Accessories[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("accessories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Artifact) validateAdditionLinks(formats strfmt.Registry) error { if swag.IsZero(m.AdditionLinks) { // not required return nil @@ -256,6 +296,25 @@ func (m *Artifact) validateReferences(formats strfmt.Registry) error { return nil } +func (m *Artifact) validateSbomOverview(formats strfmt.Registry) error { + if swag.IsZero(m.SbomOverview) { // not required + return nil + } + + if m.SbomOverview != nil { + if err := m.SbomOverview.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sbom_overview") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sbom_overview") + } + return err + } + } + + return nil +} + func (m *Artifact) validateScanOverview(formats strfmt.Registry) error { if swag.IsZero(m.ScanOverview) { // not required return nil @@ -305,6 +364,10 @@ func (m *Artifact) validateTags(formats strfmt.Registry) error { func (m *Artifact) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateAccessories(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateAdditionLinks(ctx, formats); err != nil { res = append(res, err) } @@ -325,6 +388,10 @@ func (m *Artifact) ContextValidate(ctx context.Context, formats strfmt.Registry) res = append(res, err) } + if err := m.contextValidateSbomOverview(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateScanOverview(ctx, formats); err != nil { res = append(res, err) } @@ -339,6 +406,31 @@ func (m *Artifact) ContextValidate(ctx context.Context, formats strfmt.Registry) return nil } +func (m *Artifact) contextValidateAccessories(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Accessories); i++ { + + if m.Accessories[i] != nil { + + if swag.IsZero(m.Accessories[i]) { // not required + return nil + } + + if err := m.Accessories[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("accessories" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Artifact) contextValidateAdditionLinks(ctx context.Context, formats strfmt.Registry) error { if swag.IsZero(m.AdditionLinks) { // not required @@ -443,6 +535,27 @@ func (m *Artifact) contextValidateReferences(ctx context.Context, formats strfmt return nil } +func (m *Artifact) contextValidateSbomOverview(ctx context.Context, formats strfmt.Registry) error { + + if m.SbomOverview != nil { + + if swag.IsZero(m.SbomOverview) { // not required + return nil + } + + if err := m.SbomOverview.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sbom_overview") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sbom_overview") + } + return err + } + } + + return nil +} + func (m *Artifact) contextValidateScanOverview(ctx context.Context, formats strfmt.Registry) error { if swag.IsZero(m.ScanOverview) { // not required diff --git a/pkg/harbor/models/audit_log.go b/pkg/harbor/models/audit_log.go index 0f7ca68..b43112e 100644 --- a/pkg/harbor/models/audit_log.go +++ b/pkg/harbor/models/audit_log.go @@ -23,7 +23,7 @@ type AuditLog struct { ID int64 `json:"id,omitempty" js:"id"` // The time when this operation is triggered. - // Example: 2006-01-02T15:04:05 + // Example: 2006-01-02T15:04:05Z // Format: date-time OpTime strfmt.DateTime `json:"op_time,omitempty" js:"opTime"` diff --git a/pkg/harbor/models/bool_config_item.go b/pkg/harbor/models/bool_config_item.go index 6667e26..a99d544 100644 --- a/pkg/harbor/models/bool_config_item.go +++ b/pkg/harbor/models/bool_config_item.go @@ -18,10 +18,10 @@ import ( type BoolConfigItem struct { // The configure item can be updated or not - Editable bool `json:"editable,omitempty" js:"editable"` + Editable bool `json:"editable" js:"editable"` // The boolean value of current config item - Value bool `json:"value,omitempty" js:"value"` + Value bool `json:"value" js:"value"` } // Validate validates this bool config item diff --git a/pkg/harbor/models/chart_metadata.go b/pkg/harbor/models/chart_metadata.go deleted file mode 100644 index 3eab11a..0000000 --- a/pkg/harbor/models/chart_metadata.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ChartMetadata The metadata of chart version -// -// swagger:model ChartMetadata -type ChartMetadata struct { - - // The API version of this chart - // Required: true - APIVersion *string `json:"apiVersion" js:"apiVersion"` - - // The version of the application enclosed in the chart - // Required: true - AppVersion *string `json:"appVersion" js:"appVersion"` - - // Whether or not this chart is deprecated - Deprecated bool `json:"deprecated,omitempty" js:"deprecated"` - - // A one-sentence description of chart - Description string `json:"description,omitempty" js:"description"` - - // The name of template engine - // Required: true - Engine *string `json:"engine" js:"engine"` - - // The URL to the relevant project page - Home string `json:"home,omitempty" js:"home"` - - // The URL to an icon file - // Required: true - Icon *string `json:"icon" js:"icon"` - - // A list of string keywords - Keywords []string `json:"keywords" js:"keywords"` - - // The name of the chart - // Required: true - Name *string `json:"name" js:"name"` - - // The URL to the source code of chart - Sources []string `json:"sources" js:"sources"` - - // A SemVer 2 version of chart - // Required: true - Version *string `json:"version" js:"version"` -} - -// Validate validates this chart metadata -func (m *ChartMetadata) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAPIVersion(formats); err != nil { - res = append(res, err) - } - - if err := m.validateAppVersion(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEngine(formats); err != nil { - res = append(res, err) - } - - if err := m.validateIcon(formats); err != nil { - res = append(res, err) - } - - if err := m.validateName(formats); err != nil { - res = append(res, err) - } - - if err := m.validateVersion(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ChartMetadata) validateAPIVersion(formats strfmt.Registry) error { - - if err := validate.Required("apiVersion", "body", m.APIVersion); err != nil { - return err - } - - return nil -} - -func (m *ChartMetadata) validateAppVersion(formats strfmt.Registry) error { - - if err := validate.Required("appVersion", "body", m.AppVersion); err != nil { - return err - } - - return nil -} - -func (m *ChartMetadata) validateEngine(formats strfmt.Registry) error { - - if err := validate.Required("engine", "body", m.Engine); err != nil { - return err - } - - return nil -} - -func (m *ChartMetadata) validateIcon(formats strfmt.Registry) error { - - if err := validate.Required("icon", "body", m.Icon); err != nil { - return err - } - - return nil -} - -func (m *ChartMetadata) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - return nil -} - -func (m *ChartMetadata) validateVersion(formats strfmt.Registry) error { - - if err := validate.Required("version", "body", m.Version); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this chart metadata based on context it is used -func (m *ChartMetadata) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ChartMetadata) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ChartMetadata) UnmarshalBinary(b []byte) error { - var res ChartMetadata - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/harbor/models/chart_version.go b/pkg/harbor/models/chart_version.go deleted file mode 100644 index a59c02f..0000000 --- a/pkg/harbor/models/chart_version.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ChartVersion A specified chart entry -// -// swagger:model ChartVersion -type ChartVersion struct { - ChartMetadata - - // The created time of the chart entry - Created string `json:"created,omitempty" js:"created"` - - // The digest value of the chart entry - Digest string `json:"digest,omitempty" js:"digest"` - - // A flag to indicate if the chart entry is removed - Removed bool `json:"removed,omitempty" js:"removed"` - - // The urls of the chart entry - Urls []string `json:"urls" js:"urls"` - - // A list of label - Labels []*Label `json:"labels" js:"labels"` -} - -// UnmarshalJSON unmarshals this object from a JSON structure -func (m *ChartVersion) UnmarshalJSON(raw []byte) error { - // AO0 - var aO0 ChartMetadata - if err := swag.ReadJSON(raw, &aO0); err != nil { - return err - } - m.ChartMetadata = aO0 - - // AO1 - var dataAO1 struct { - Created string `json:"created,omitempty" js:"created"` - - Digest string `json:"digest,omitempty" js:"digest"` - - Removed bool `json:"removed,omitempty" js:"removed"` - - Urls []string `json:"urls" js:"urls"` - } - if err := swag.ReadJSON(raw, &dataAO1); err != nil { - return err - } - - m.Created = dataAO1.Created - - m.Digest = dataAO1.Digest - - m.Removed = dataAO1.Removed - - m.Urls = dataAO1.Urls - - // now for regular properties - var propsChartVersion struct { - Labels []*Label `json:"labels" js:"labels"` - } - if err := swag.ReadJSON(raw, &propsChartVersion); err != nil { - return err - } - m.Labels = propsChartVersion.Labels - - return nil -} - -// MarshalJSON marshals this object to a JSON structure -func (m ChartVersion) MarshalJSON() ([]byte, error) { - _parts := make([][]byte, 0, 2) - - aO0, err := swag.WriteJSON(m.ChartMetadata) - if err != nil { - return nil, err - } - _parts = append(_parts, aO0) - var dataAO1 struct { - Created string `json:"created,omitempty" js:"created"` - - Digest string `json:"digest,omitempty" js:"digest"` - - Removed bool `json:"removed,omitempty" js:"removed"` - - Urls []string `json:"urls" js:"urls"` - } - - dataAO1.Created = m.Created - - dataAO1.Digest = m.Digest - - dataAO1.Removed = m.Removed - - dataAO1.Urls = m.Urls - - jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) - if errAO1 != nil { - return nil, errAO1 - } - _parts = append(_parts, jsonDataAO1) - - // now for regular properties - var propsChartVersion struct { - Labels []*Label `json:"labels" js:"labels"` - } - propsChartVersion.Labels = m.Labels - - jsonDataPropsChartVersion, errChartVersion := swag.WriteJSON(propsChartVersion) - if errChartVersion != nil { - return nil, errChartVersion - } - _parts = append(_parts, jsonDataPropsChartVersion) - return swag.ConcatJSON(_parts...), nil -} - -// Validate validates this chart version -func (m *ChartVersion) Validate(formats strfmt.Registry) error { - var res []error - - // validation for a type composition with ChartMetadata - if err := m.ChartMetadata.Validate(formats); err != nil { - res = append(res, err) - } - - if err := m.validateLabels(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ChartVersion) validateLabels(formats strfmt.Registry) error { - if swag.IsZero(m.Labels) { // not required - return nil - } - - for i := 0; i < len(m.Labels); i++ { - if swag.IsZero(m.Labels[i]) { // not required - continue - } - - if m.Labels[i] != nil { - if err := m.Labels[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("labels" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("labels" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this chart version based on the context it is used -func (m *ChartVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - // validation for a type composition with ChartMetadata - if err := m.ChartMetadata.ContextValidate(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateLabels(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ChartVersion) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Labels); i++ { - - if m.Labels[i] != nil { - - if swag.IsZero(m.Labels[i]) { // not required - return nil - } - - if err := m.Labels[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("labels" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("labels" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ChartVersion) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ChartVersion) UnmarshalBinary(b []byte) error { - var res ChartVersion - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/harbor/models/component_health_status.go b/pkg/harbor/models/component_health_status.go index c16ce58..eafba42 100644 --- a/pkg/harbor/models/component_health_status.go +++ b/pkg/harbor/models/component_health_status.go @@ -23,7 +23,7 @@ type ComponentHealthStatus struct { // The component name Name string `json:"name,omitempty" js:"name"` - // The health status of component + // The health status of component. Is either "healthy" or "unhealthy". Status string `json:"status,omitempty" js:"status"` } diff --git a/pkg/harbor/models/configurations.go b/pkg/harbor/models/configurations.go index b6ab95a..c0db422 100644 --- a/pkg/harbor/models/configurations.go +++ b/pkg/harbor/models/configurations.go @@ -9,19 +9,201 @@ import ( "context" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // Configurations configurations // // swagger:model Configurations -type Configurations map[string]interface{} +type Configurations struct { + + // The audit log forward endpoint + AuditLogForwardEndpoint *string `json:"audit_log_forward_endpoint,omitempty" js:"auditLogForwardEndpoint"` + + // The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" + AuthMode *string `json:"auth_mode,omitempty" js:"authMode"` + + // The banner message for the UI.It is the stringified result of the banner message object + BannerMessage *string `json:"banner_message,omitempty" js:"bannerMessage"` + + // The group which has the harbor admin privileges + HTTPAuthproxyAdminGroups *string `json:"http_authproxy_admin_groups,omitempty" js:"httpAuthproxyAdminGroups"` + + // The username which has the harbor admin privileges + HTTPAuthproxyAdminUsernames *string `json:"http_authproxy_admin_usernames,omitempty" js:"httpAuthproxyAdminUsernames"` + + // The endpoint of the HTTP auth + HTTPAuthproxyEndpoint *string `json:"http_authproxy_endpoint,omitempty" js:"httpAuthproxyEndpoint"` + + // The certificate of the HTTP auth provider + HTTPAuthproxyServerCertificate *string `json:"http_authproxy_server_certificate,omitempty" js:"httpAuthproxyServerCertificate"` + + // Search user before onboard + HTTPAuthproxySkipSearch *bool `json:"http_authproxy_skip_search,omitempty" js:"httpAuthproxySkipSearch"` + + // The token review endpoint + HTTPAuthproxyTokenreviewEndpoint *string `json:"http_authproxy_tokenreview_endpoint,omitempty" js:"httpAuthproxyTokenreviewEndpoint"` + + // Verify the HTTP auth provider's certificate + HTTPAuthproxyVerifyCert *bool `json:"http_authproxy_verify_cert,omitempty" js:"httpAuthproxyVerifyCert"` + + // The Base DN for LDAP binding. + LdapBaseDn *string `json:"ldap_base_dn,omitempty" js:"ldapBaseDn"` + + // The filter for LDAP search + LdapFilter *string `json:"ldap_filter,omitempty" js:"ldapFilter"` + + // Specify the ldap group which have the same privilege with Harbor admin + LdapGroupAdminDn *string `json:"ldap_group_admin_dn,omitempty" js:"ldapGroupAdminDn"` + + // The attribute which is used as identity of the LDAP group, default is cn.' + LdapGroupAttributeName *string `json:"ldap_group_attribute_name,omitempty" js:"ldapGroupAttributeName"` + + // The base DN to search LDAP group. + LdapGroupBaseDn *string `json:"ldap_group_base_dn,omitempty" js:"ldapGroupBaseDn"` + + // The user attribute to identify the group membership + LdapGroupMembershipAttribute *string `json:"ldap_group_membership_attribute,omitempty" js:"ldapGroupMembershipAttribute"` + + // The filter to search the ldap group + LdapGroupSearchFilter *string `json:"ldap_group_search_filter,omitempty" js:"ldapGroupSearchFilter"` + + // The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'' + LdapGroupSearchScope *int64 `json:"ldap_group_search_scope,omitempty" js:"ldapGroupSearchScope"` + + // The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE' + LdapScope *int64 `json:"ldap_scope,omitempty" js:"ldapScope"` + + // The DN of the user to do the search. + LdapSearchDn *string `json:"ldap_search_dn,omitempty" js:"ldapSearchDn"` + + // The password of the ldap search dn + LdapSearchPassword *string `json:"ldap_search_password,omitempty" js:"ldapSearchPassword"` + + // Timeout in seconds for connection to LDAP server + LdapTimeout *int64 `json:"ldap_timeout,omitempty" js:"ldapTimeout"` + + // The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname" + LdapUID *string `json:"ldap_uid,omitempty" js:"ldapUID"` + + // The URL of LDAP server + LdapURL *string `json:"ldap_url,omitempty" js:"ldapURL"` + + // Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate. + LdapVerifyCert *bool `json:"ldap_verify_cert,omitempty" js:"ldapVerifyCert"` + + // Enable notification + NotificationEnable *bool `json:"notification_enable,omitempty" js:"notificationEnable"` + + // The OIDC group which has the harbor admin privileges + OIDCAdminGroup *string `json:"oidc_admin_group,omitempty" js:"oidcAdminGroup"` + + // Auto onboard the OIDC user + OIDCAutoOnboard *bool `json:"oidc_auto_onboard,omitempty" js:"oidcAutoOnboard"` + + // The client ID of the OIDC provider + OIDCClientID *string `json:"oidc_client_id,omitempty" js:"oidcClientID"` + + // The OIDC provider secret + OIDCClientSecret *string `json:"oidc_client_secret,omitempty" js:"oidcClientSecret"` + + // The endpoint of the OIDC provider + OIDCEndpoint *string `json:"oidc_endpoint,omitempty" js:"oidcEndpoint"` + + // Extra parameters to add when redirect request to OIDC provider + OIDCExtraRedirectParms *string `json:"oidc_extra_redirect_parms,omitempty" js:"oidcExtraRedirectParms"` + + // The OIDC group filter which filters out the group name doesn't match the regular expression + OIDCGroupFilter *string `json:"oidc_group_filter,omitempty" js:"oidcGroupFilter"` + + // The attribute claims the group name + OIDCGroupsClaim *string `json:"oidc_groups_claim,omitempty" js:"oidcGroupsClaim"` + + // The OIDC provider name + OIDCName *string `json:"oidc_name,omitempty" js:"oidcName"` + + // The scope of the OIDC provider + OIDCScope *string `json:"oidc_scope,omitempty" js:"oidcScope"` + + // The attribute claims the username + OIDCUserClaim *string `json:"oidc_user_claim,omitempty" js:"oidcUserClaim"` + + // Verify the OIDC provider's certificate' + OIDCVerifyCert *bool `json:"oidc_verify_cert,omitempty" js:"oidcVerifyCert"` + + // The flag to indicate whether the current auth mode should consider as a primary one. + PrimaryAuthMode *bool `json:"primary_auth_mode,omitempty" js:"primaryAuthMode"` + + // Indicate who can create projects, it could be ''adminonly'' or ''everyone''. + ProjectCreationRestriction *string `json:"project_creation_restriction,omitempty" js:"projectCreationRestriction"` + + // Enable quota per project + QuotaPerProjectEnable *bool `json:"quota_per_project_enable,omitempty" js:"quotaPerProjectEnable"` + + // The flag to indicate whether Harbor is in readonly mode. + ReadOnly *bool `json:"read_only,omitempty" js:"readOnly"` + + // The rebot account name prefix + RobotNamePrefix *string `json:"robot_name_prefix,omitempty" js:"robotNamePrefix"` + + // The robot account token duration in days + RobotTokenDuration *int64 `json:"robot_token_duration,omitempty" js:"robotTokenDuration"` + + // Whether or not to skip update pull time for scanner + ScannerSkipUpdatePulltime *bool `json:"scanner_skip_update_pulltime,omitempty" js:"scannerSkipUpdatePulltime"` + + // Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance. + SelfRegistration *bool `json:"self_registration,omitempty" js:"selfRegistration"` + + // The session timeout for harbor, in minutes. + SessionTimeout *int64 `json:"session_timeout,omitempty" js:"sessionTimeout"` + + // Skip audit log database + SkipAuditLogDatabase *bool `json:"skip_audit_log_database,omitempty" js:"skipAuditLogDatabase"` + + // The storage quota per project + StoragePerProject *int64 `json:"storage_per_project,omitempty" js:"storagePerProject"` + + // The expiration time of the token for internal Registry, in minutes. + TokenExpiration *int64 `json:"token_expiration,omitempty" js:"tokenExpiration"` + + // The client id of UAA + UaaClientID *string `json:"uaa_client_id,omitempty" js:"uaaClientID"` + + // The client secret of the UAA + UaaClientSecret *string `json:"uaa_client_secret,omitempty" js:"uaaClientSecret"` + + // The endpoint of the UAA + UaaEndpoint *string `json:"uaa_endpoint,omitempty" js:"uaaEndpoint"` + + // Verify the certificate in UAA server + UaaVerifyCert *bool `json:"uaa_verify_cert,omitempty" js:"uaaVerifyCert"` +} // Validate validates this configurations -func (m Configurations) Validate(formats strfmt.Registry) error { +func (m *Configurations) Validate(formats strfmt.Registry) error { return nil } // ContextValidate validates this configurations based on context it is used -func (m Configurations) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +func (m *Configurations) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Configurations) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Configurations) UnmarshalBinary(b []byte) error { + var res Configurations + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res return nil } diff --git a/pkg/harbor/models/configurations_response.go b/pkg/harbor/models/configurations_response.go index c89542f..6eb5647 100644 --- a/pkg/harbor/models/configurations_response.go +++ b/pkg/harbor/models/configurations_response.go @@ -18,29 +18,14 @@ import ( // swagger:model ConfigurationsResponse type ConfigurationsResponse struct { + // The endpoint of the audit log forwarder + AuditLogForwardEndpoint *StringConfigItem `json:"audit_log_forward_endpoint,omitempty" js:"auditLogForwardEndpoint"` + // The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" AuthMode *StringConfigItem `json:"auth_mode,omitempty" js:"authMode"` - // The sender name for Email notification. - EmailFrom *StringConfigItem `json:"email_from,omitempty" js:"emailFrom"` - - // The hostname of SMTP server that sends Email notification. - EmailHost *StringConfigItem `json:"email_host,omitempty" js:"emailHost"` - - // By default it's empty so the email_username is picked - EmailIdentity *StringConfigItem `json:"email_identity,omitempty" js:"emailIdentity"` - - // Whether or not the certificate will be verified when Harbor tries to access the email server. - EmailInsecure *BoolConfigItem `json:"email_insecure,omitempty" js:"emailInsecure"` - - // The port of SMTP server - EmailPort *IntegerConfigItem `json:"email_port,omitempty" js:"emailPort"` - - // When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side. - EmailSsl *BoolConfigItem `json:"email_ssl,omitempty" js:"emailSsl"` - - // The username for authenticate against SMTP server - EmailUsername *StringConfigItem `json:"email_username,omitempty" js:"emailUsername"` + // The banner message for the UI.It is the stringified result of the banner message object + BannerMessage *StringConfigItem `json:"banner_message,omitempty" js:"bannerMessage"` // The group which has the harbor admin privileges HTTPAuthproxyAdminGroups *StringConfigItem `json:"http_authproxy_admin_groups,omitempty" js:"httpAuthproxyAdminGroups"` @@ -123,6 +108,9 @@ type ConfigurationsResponse struct { // Extra parameters to add when redirect request to OIDC provider OIDCExtraRedirectParms *StringConfigItem `json:"oidc_extra_redirect_parms,omitempty" js:"oidcExtraRedirectParms"` + // The OIDC group filter which filters out the group doesn't match the regular expression + OIDCGroupFilter *StringConfigItem `json:"oidc_group_filter,omitempty" js:"oidcGroupFilter"` + // The attribute claims the group name OIDCGroupsClaim *StringConfigItem `json:"oidc_groups_claim,omitempty" js:"oidcGroupsClaim"` @@ -138,6 +126,9 @@ type ConfigurationsResponse struct { // Verify the OIDC provider's certificate' OIDCVerifyCert *BoolConfigItem `json:"oidc_verify_cert,omitempty" js:"oidcVerifyCert"` + // The flag to indicate whether the current auth mode should consider as a primary one. + PrimaryAuthMode *BoolConfigItem `json:"primary_auth_mode,omitempty" js:"primaryAuthMode"` + // Indicate who can create projects, it could be ''adminonly'' or ''everyone''. ProjectCreationRestriction *StringConfigItem `json:"project_creation_restriction,omitempty" js:"projectCreationRestriction"` @@ -156,9 +147,18 @@ type ConfigurationsResponse struct { // scan all policy ScanAllPolicy *ConfigurationsResponseScanAllPolicy `json:"scan_all_policy,omitempty" js:"scanAllPolicy"` + // Whether or not to skip update the pull time for scanner + ScannerSkipUpdatePulltime *BoolConfigItem `json:"scanner_skip_update_pulltime,omitempty" js:"scannerSkipUpdatePulltime"` + // Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance. SelfRegistration *BoolConfigItem `json:"self_registration,omitempty" js:"selfRegistration"` + // The session timeout in minutes + SessionTimeout *IntegerConfigItem `json:"session_timeout,omitempty" js:"sessionTimeout"` + + // Whether skip the audit log in database + SkipAuditLogDatabase *BoolConfigItem `json:"skip_audit_log_database,omitempty" js:"skipAuditLogDatabase"` + // The storage quota per project StoragePerProject *IntegerConfigItem `json:"storage_per_project,omitempty" js:"storagePerProject"` @@ -182,35 +182,15 @@ type ConfigurationsResponse struct { func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAuthMode(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEmailFrom(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEmailHost(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEmailIdentity(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEmailInsecure(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEmailPort(formats); err != nil { + if err := m.validateAuditLogForwardEndpoint(formats); err != nil { res = append(res, err) } - if err := m.validateEmailSsl(formats); err != nil { + if err := m.validateAuthMode(formats); err != nil { res = append(res, err) } - if err := m.validateEmailUsername(formats); err != nil { + if err := m.validateBannerMessage(formats); err != nil { res = append(res, err) } @@ -322,6 +302,10 @@ func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateOIDCGroupFilter(formats); err != nil { + res = append(res, err) + } + if err := m.validateOIDCGroupsClaim(formats); err != nil { res = append(res, err) } @@ -342,6 +326,10 @@ func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validatePrimaryAuthMode(formats); err != nil { + res = append(res, err) + } + if err := m.validateProjectCreationRestriction(formats); err != nil { res = append(res, err) } @@ -366,10 +354,22 @@ func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateScannerSkipUpdatePulltime(formats); err != nil { + res = append(res, err) + } + if err := m.validateSelfRegistration(formats); err != nil { res = append(res, err) } + if err := m.validateSessionTimeout(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSkipAuditLogDatabase(formats); err != nil { + res = append(res, err) + } + if err := m.validateStoragePerProject(formats); err != nil { res = append(res, err) } @@ -400,112 +400,17 @@ func (m *ConfigurationsResponse) Validate(formats strfmt.Registry) error { return nil } -func (m *ConfigurationsResponse) validateAuthMode(formats strfmt.Registry) error { - if swag.IsZero(m.AuthMode) { // not required - return nil - } - - if m.AuthMode != nil { - if err := m.AuthMode.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("auth_mode") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("auth_mode") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) validateEmailFrom(formats strfmt.Registry) error { - if swag.IsZero(m.EmailFrom) { // not required - return nil - } - - if m.EmailFrom != nil { - if err := m.EmailFrom.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_from") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_from") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) validateEmailHost(formats strfmt.Registry) error { - if swag.IsZero(m.EmailHost) { // not required - return nil - } - - if m.EmailHost != nil { - if err := m.EmailHost.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_host") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_host") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) validateEmailIdentity(formats strfmt.Registry) error { - if swag.IsZero(m.EmailIdentity) { // not required - return nil - } - - if m.EmailIdentity != nil { - if err := m.EmailIdentity.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_identity") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_identity") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) validateEmailInsecure(formats strfmt.Registry) error { - if swag.IsZero(m.EmailInsecure) { // not required - return nil - } - - if m.EmailInsecure != nil { - if err := m.EmailInsecure.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_insecure") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_insecure") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) validateEmailPort(formats strfmt.Registry) error { - if swag.IsZero(m.EmailPort) { // not required +func (m *ConfigurationsResponse) validateAuditLogForwardEndpoint(formats strfmt.Registry) error { + if swag.IsZero(m.AuditLogForwardEndpoint) { // not required return nil } - if m.EmailPort != nil { - if err := m.EmailPort.Validate(formats); err != nil { + if m.AuditLogForwardEndpoint != nil { + if err := m.AuditLogForwardEndpoint.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_port") + return ve.ValidateName("audit_log_forward_endpoint") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_port") + return ce.ValidateName("audit_log_forward_endpoint") } return err } @@ -514,17 +419,17 @@ func (m *ConfigurationsResponse) validateEmailPort(formats strfmt.Registry) erro return nil } -func (m *ConfigurationsResponse) validateEmailSsl(formats strfmt.Registry) error { - if swag.IsZero(m.EmailSsl) { // not required +func (m *ConfigurationsResponse) validateAuthMode(formats strfmt.Registry) error { + if swag.IsZero(m.AuthMode) { // not required return nil } - if m.EmailSsl != nil { - if err := m.EmailSsl.Validate(formats); err != nil { + if m.AuthMode != nil { + if err := m.AuthMode.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_ssl") + return ve.ValidateName("auth_mode") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_ssl") + return ce.ValidateName("auth_mode") } return err } @@ -533,17 +438,17 @@ func (m *ConfigurationsResponse) validateEmailSsl(formats strfmt.Registry) error return nil } -func (m *ConfigurationsResponse) validateEmailUsername(formats strfmt.Registry) error { - if swag.IsZero(m.EmailUsername) { // not required +func (m *ConfigurationsResponse) validateBannerMessage(formats strfmt.Registry) error { + if swag.IsZero(m.BannerMessage) { // not required return nil } - if m.EmailUsername != nil { - if err := m.EmailUsername.Validate(formats); err != nil { + if m.BannerMessage != nil { + if err := m.BannerMessage.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_username") + return ve.ValidateName("banner_message") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_username") + return ce.ValidateName("banner_message") } return err } @@ -1065,6 +970,25 @@ func (m *ConfigurationsResponse) validateOIDCExtraRedirectParms(formats strfmt.R return nil } +func (m *ConfigurationsResponse) validateOIDCGroupFilter(formats strfmt.Registry) error { + if swag.IsZero(m.OIDCGroupFilter) { // not required + return nil + } + + if m.OIDCGroupFilter != nil { + if err := m.OIDCGroupFilter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_group_filter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oidc_group_filter") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) validateOIDCGroupsClaim(formats strfmt.Registry) error { if swag.IsZero(m.OIDCGroupsClaim) { // not required return nil @@ -1160,6 +1084,25 @@ func (m *ConfigurationsResponse) validateOIDCVerifyCert(formats strfmt.Registry) return nil } +func (m *ConfigurationsResponse) validatePrimaryAuthMode(formats strfmt.Registry) error { + if swag.IsZero(m.PrimaryAuthMode) { // not required + return nil + } + + if m.PrimaryAuthMode != nil { + if err := m.PrimaryAuthMode.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("primary_auth_mode") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("primary_auth_mode") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) validateProjectCreationRestriction(formats strfmt.Registry) error { if swag.IsZero(m.ProjectCreationRestriction) { // not required return nil @@ -1274,6 +1217,25 @@ func (m *ConfigurationsResponse) validateScanAllPolicy(formats strfmt.Registry) return nil } +func (m *ConfigurationsResponse) validateScannerSkipUpdatePulltime(formats strfmt.Registry) error { + if swag.IsZero(m.ScannerSkipUpdatePulltime) { // not required + return nil + } + + if m.ScannerSkipUpdatePulltime != nil { + if err := m.ScannerSkipUpdatePulltime.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner_skip_update_pulltime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scanner_skip_update_pulltime") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) validateSelfRegistration(formats strfmt.Registry) error { if swag.IsZero(m.SelfRegistration) { // not required return nil @@ -1293,6 +1255,44 @@ func (m *ConfigurationsResponse) validateSelfRegistration(formats strfmt.Registr return nil } +func (m *ConfigurationsResponse) validateSessionTimeout(formats strfmt.Registry) error { + if swag.IsZero(m.SessionTimeout) { // not required + return nil + } + + if m.SessionTimeout != nil { + if err := m.SessionTimeout.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("session_timeout") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("session_timeout") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) validateSkipAuditLogDatabase(formats strfmt.Registry) error { + if swag.IsZero(m.SkipAuditLogDatabase) { // not required + return nil + } + + if m.SkipAuditLogDatabase != nil { + if err := m.SkipAuditLogDatabase.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("skip_audit_log_database") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("skip_audit_log_database") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) validateStoragePerProject(formats strfmt.Registry) error { if swag.IsZero(m.StoragePerProject) { // not required return nil @@ -1411,35 +1411,15 @@ func (m *ConfigurationsResponse) validateUaaVerifyCert(formats strfmt.Registry) func (m *ConfigurationsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error - if err := m.contextValidateAuthMode(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEmailFrom(ctx, formats); err != nil { + if err := m.contextValidateAuditLogForwardEndpoint(ctx, formats); err != nil { res = append(res, err) } - if err := m.contextValidateEmailHost(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEmailIdentity(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEmailInsecure(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEmailPort(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEmailSsl(ctx, formats); err != nil { + if err := m.contextValidateAuthMode(ctx, formats); err != nil { res = append(res, err) } - if err := m.contextValidateEmailUsername(ctx, formats); err != nil { + if err := m.contextValidateBannerMessage(ctx, formats); err != nil { res = append(res, err) } @@ -1551,6 +1531,10 @@ func (m *ConfigurationsResponse) ContextValidate(ctx context.Context, formats st res = append(res, err) } + if err := m.contextValidateOIDCGroupFilter(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateOIDCGroupsClaim(ctx, formats); err != nil { res = append(res, err) } @@ -1571,6 +1555,10 @@ func (m *ConfigurationsResponse) ContextValidate(ctx context.Context, formats st res = append(res, err) } + if err := m.contextValidatePrimaryAuthMode(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateProjectCreationRestriction(ctx, formats); err != nil { res = append(res, err) } @@ -1595,10 +1583,22 @@ func (m *ConfigurationsResponse) ContextValidate(ctx context.Context, formats st res = append(res, err) } + if err := m.contextValidateScannerSkipUpdatePulltime(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSelfRegistration(ctx, formats); err != nil { res = append(res, err) } + if err := m.contextValidateSessionTimeout(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSkipAuditLogDatabase(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateStoragePerProject(ctx, formats); err != nil { res = append(res, err) } @@ -1629,124 +1629,19 @@ func (m *ConfigurationsResponse) ContextValidate(ctx context.Context, formats st return nil } -func (m *ConfigurationsResponse) contextValidateAuthMode(ctx context.Context, formats strfmt.Registry) error { - - if m.AuthMode != nil { - - if swag.IsZero(m.AuthMode) { // not required - return nil - } - - if err := m.AuthMode.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("auth_mode") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("auth_mode") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) contextValidateEmailFrom(ctx context.Context, formats strfmt.Registry) error { - - if m.EmailFrom != nil { - - if swag.IsZero(m.EmailFrom) { // not required - return nil - } - - if err := m.EmailFrom.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_from") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_from") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) contextValidateEmailHost(ctx context.Context, formats strfmt.Registry) error { - - if m.EmailHost != nil { - - if swag.IsZero(m.EmailHost) { // not required - return nil - } - - if err := m.EmailHost.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_host") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_host") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) contextValidateEmailIdentity(ctx context.Context, formats strfmt.Registry) error { - - if m.EmailIdentity != nil { - - if swag.IsZero(m.EmailIdentity) { // not required - return nil - } - - if err := m.EmailIdentity.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_identity") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_identity") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) contextValidateEmailInsecure(ctx context.Context, formats strfmt.Registry) error { - - if m.EmailInsecure != nil { - - if swag.IsZero(m.EmailInsecure) { // not required - return nil - } - - if err := m.EmailInsecure.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_insecure") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_insecure") - } - return err - } - } - - return nil -} - -func (m *ConfigurationsResponse) contextValidateEmailPort(ctx context.Context, formats strfmt.Registry) error { +func (m *ConfigurationsResponse) contextValidateAuditLogForwardEndpoint(ctx context.Context, formats strfmt.Registry) error { - if m.EmailPort != nil { + if m.AuditLogForwardEndpoint != nil { - if swag.IsZero(m.EmailPort) { // not required + if swag.IsZero(m.AuditLogForwardEndpoint) { // not required return nil } - if err := m.EmailPort.ContextValidate(ctx, formats); err != nil { + if err := m.AuditLogForwardEndpoint.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_port") + return ve.ValidateName("audit_log_forward_endpoint") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_port") + return ce.ValidateName("audit_log_forward_endpoint") } return err } @@ -1755,19 +1650,19 @@ func (m *ConfigurationsResponse) contextValidateEmailPort(ctx context.Context, f return nil } -func (m *ConfigurationsResponse) contextValidateEmailSsl(ctx context.Context, formats strfmt.Registry) error { +func (m *ConfigurationsResponse) contextValidateAuthMode(ctx context.Context, formats strfmt.Registry) error { - if m.EmailSsl != nil { + if m.AuthMode != nil { - if swag.IsZero(m.EmailSsl) { // not required + if swag.IsZero(m.AuthMode) { // not required return nil } - if err := m.EmailSsl.ContextValidate(ctx, formats); err != nil { + if err := m.AuthMode.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_ssl") + return ve.ValidateName("auth_mode") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_ssl") + return ce.ValidateName("auth_mode") } return err } @@ -1776,19 +1671,19 @@ func (m *ConfigurationsResponse) contextValidateEmailSsl(ctx context.Context, fo return nil } -func (m *ConfigurationsResponse) contextValidateEmailUsername(ctx context.Context, formats strfmt.Registry) error { +func (m *ConfigurationsResponse) contextValidateBannerMessage(ctx context.Context, formats strfmt.Registry) error { - if m.EmailUsername != nil { + if m.BannerMessage != nil { - if swag.IsZero(m.EmailUsername) { // not required + if swag.IsZero(m.BannerMessage) { // not required return nil } - if err := m.EmailUsername.ContextValidate(ctx, formats); err != nil { + if err := m.BannerMessage.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("email_username") + return ve.ValidateName("banner_message") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("email_username") + return ce.ValidateName("banner_message") } return err } @@ -2364,6 +2259,27 @@ func (m *ConfigurationsResponse) contextValidateOIDCExtraRedirectParms(ctx conte return nil } +func (m *ConfigurationsResponse) contextValidateOIDCGroupFilter(ctx context.Context, formats strfmt.Registry) error { + + if m.OIDCGroupFilter != nil { + + if swag.IsZero(m.OIDCGroupFilter) { // not required + return nil + } + + if err := m.OIDCGroupFilter.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("oidc_group_filter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("oidc_group_filter") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) contextValidateOIDCGroupsClaim(ctx context.Context, formats strfmt.Registry) error { if m.OIDCGroupsClaim != nil { @@ -2469,6 +2385,27 @@ func (m *ConfigurationsResponse) contextValidateOIDCVerifyCert(ctx context.Conte return nil } +func (m *ConfigurationsResponse) contextValidatePrimaryAuthMode(ctx context.Context, formats strfmt.Registry) error { + + if m.PrimaryAuthMode != nil { + + if swag.IsZero(m.PrimaryAuthMode) { // not required + return nil + } + + if err := m.PrimaryAuthMode.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("primary_auth_mode") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("primary_auth_mode") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) contextValidateProjectCreationRestriction(ctx context.Context, formats strfmt.Registry) error { if m.ProjectCreationRestriction != nil { @@ -2595,6 +2532,27 @@ func (m *ConfigurationsResponse) contextValidateScanAllPolicy(ctx context.Contex return nil } +func (m *ConfigurationsResponse) contextValidateScannerSkipUpdatePulltime(ctx context.Context, formats strfmt.Registry) error { + + if m.ScannerSkipUpdatePulltime != nil { + + if swag.IsZero(m.ScannerSkipUpdatePulltime) { // not required + return nil + } + + if err := m.ScannerSkipUpdatePulltime.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner_skip_update_pulltime") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scanner_skip_update_pulltime") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) contextValidateSelfRegistration(ctx context.Context, formats strfmt.Registry) error { if m.SelfRegistration != nil { @@ -2616,6 +2574,48 @@ func (m *ConfigurationsResponse) contextValidateSelfRegistration(ctx context.Con return nil } +func (m *ConfigurationsResponse) contextValidateSessionTimeout(ctx context.Context, formats strfmt.Registry) error { + + if m.SessionTimeout != nil { + + if swag.IsZero(m.SessionTimeout) { // not required + return nil + } + + if err := m.SessionTimeout.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("session_timeout") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("session_timeout") + } + return err + } + } + + return nil +} + +func (m *ConfigurationsResponse) contextValidateSkipAuditLogDatabase(ctx context.Context, formats strfmt.Registry) error { + + if m.SkipAuditLogDatabase != nil { + + if swag.IsZero(m.SkipAuditLogDatabase) { // not required + return nil + } + + if err := m.SkipAuditLogDatabase.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("skip_audit_log_database") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("skip_audit_log_database") + } + return err + } + } + + return nil +} + func (m *ConfigurationsResponse) contextValidateStoragePerProject(ctx context.Context, formats strfmt.Registry) error { if m.StoragePerProject != nil { @@ -2858,7 +2858,7 @@ func (m *ConfigurationsResponseScanAllPolicy) UnmarshalBinary(b []byte) error { return nil } -// ConfigurationsResponseScanAllPolicyParameter The parameters of the policy, the values are dependant on the type of the policy. +// ConfigurationsResponseScanAllPolicyParameter The parameters of the policy, the values are dependent on the type of the policy. // // swagger:model ConfigurationsResponseScanAllPolicyParameter type ConfigurationsResponseScanAllPolicyParameter struct { diff --git a/pkg/harbor/models/dangerous_artifact.go b/pkg/harbor/models/dangerous_artifact.go new file mode 100644 index 0000000..a052c91 --- /dev/null +++ b/pkg/harbor/models/dangerous_artifact.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DangerousArtifact the dangerous artifact information +// +// swagger:model DangerousArtifact +type DangerousArtifact struct { + + // the count of critical vulnerabilities + CriticalCnt int64 `json:"critical_cnt" js:"criticalCnt"` + + // the digest of the artifact + Digest string `json:"digest,omitempty" js:"digest"` + + // the count of high vulnerabilities + HighCnt int64 `json:"high_cnt" js:"highCnt"` + + // the count of medium vulnerabilities + MediumCnt int64 `json:"medium_cnt" js:"mediumCnt"` + + // the project id of the artifact + ProjectID int64 `json:"project_id,omitempty" js:"projectID"` + + // the repository name of the artifact + RepositoryName string `json:"repository_name,omitempty" js:"repositoryName"` +} + +// Validate validates this dangerous artifact +func (m *DangerousArtifact) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this dangerous artifact based on context it is used +func (m *DangerousArtifact) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DangerousArtifact) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DangerousArtifact) UnmarshalBinary(b []byte) error { + var res DangerousArtifact + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/dangerous_cve.go b/pkg/harbor/models/dangerous_cve.go new file mode 100644 index 0000000..2eb1e50 --- /dev/null +++ b/pkg/harbor/models/dangerous_cve.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DangerousCVE the dangerous CVE information +// +// swagger:model DangerousCVE +type DangerousCVE struct { + + // the cve id + CVEID string `json:"cve_id,omitempty" js:"cveid"` + + // the cvss score v3 + CvssScoreV3 float64 `json:"cvss_score_v3,omitempty" js:"cvssScoreV3"` + + // the description of the CVE + Desc string `json:"desc,omitempty" js:"desc"` + + // the package of the CVE + Package string `json:"package,omitempty" js:"package"` + + // the severity of the CVE + Severity string `json:"severity,omitempty" js:"severity"` + + // the version of the package + Version string `json:"version,omitempty" js:"version"` +} + +// Validate validates this dangerous CVE +func (m *DangerousCVE) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this dangerous CVE based on context it is used +func (m *DangerousCVE) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DangerousCVE) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DangerousCVE) UnmarshalBinary(b []byte) error { + var res DangerousCVE + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/event_type.go b/pkg/harbor/models/event_type.go index e27989a..e40f5dd 100644 --- a/pkg/harbor/models/event_type.go +++ b/pkg/harbor/models/event_type.go @@ -11,8 +11,8 @@ import ( "github.com/go-openapi/strfmt" ) -// EventType Webhook supportted event type. -// Example: pullImage +// EventType Webhook supported event type. +// Example: PULL_ARTIFACT // // swagger:model EventType type EventType string diff --git a/pkg/harbor/models/exec_history.go b/pkg/harbor/models/exec_history.go new file mode 100644 index 0000000..67727bb --- /dev/null +++ b/pkg/harbor/models/exec_history.go @@ -0,0 +1,168 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ExecHistory exec history +// +// swagger:model ExecHistory +type ExecHistory struct { + + // the creation time of purge job. + // Format: date-time + CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` + + // if purge job was deleted. + Deleted bool `json:"deleted,omitempty" js:"deleted"` + + // the id of purge job. + ID int64 `json:"id,omitempty" js:"id"` + + // the job kind of purge job. + JobKind string `json:"job_kind,omitempty" js:"jobKind"` + + // the job name of purge job. + JobName string `json:"job_name,omitempty" js:"jobName"` + + // the job parameters of purge job. + JobParameters string `json:"job_parameters,omitempty" js:"jobParameters"` + + // the status of purge job. + JobStatus string `json:"job_status,omitempty" js:"jobStatus"` + + // schedule + Schedule *ScheduleObj `json:"schedule,omitempty" js:"schedule"` + + // the update time of purge job. + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty" js:"updateTime"` +} + +// Validate validates this exec history +func (m *ExecHistory) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSchedule(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExecHistory) validateCreationTime(formats strfmt.Registry) error { + if swag.IsZero(m.CreationTime) { // not required + return nil + } + + if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ExecHistory) validateSchedule(formats strfmt.Registry) error { + if swag.IsZero(m.Schedule) { // not required + return nil + } + + if m.Schedule != nil { + if err := m.Schedule.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schedule") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("schedule") + } + return err + } + } + + return nil +} + +func (m *ExecHistory) validateUpdateTime(formats strfmt.Registry) error { + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this exec history based on the context it is used +func (m *ExecHistory) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSchedule(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExecHistory) contextValidateSchedule(ctx context.Context, formats strfmt.Registry) error { + + if m.Schedule != nil { + + if swag.IsZero(m.Schedule) { // not required + return nil + } + + if err := m.Schedule.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("schedule") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("schedule") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExecHistory) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExecHistory) UnmarshalBinary(b []byte) error { + var res ExecHistory + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/general_info.go b/pkg/harbor/models/general_info.go index d2a6556..6360015 100644 --- a/pkg/harbor/models/general_info.go +++ b/pkg/harbor/models/general_info.go @@ -11,6 +11,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // GeneralInfo general info @@ -24,6 +25,14 @@ type GeneralInfo struct { // The setting of auth proxy this is only available when Harbor relies on authproxy for authentication. AuthproxySettings *AuthproxySetting `json:"authproxy_settings,omitempty" js:"authproxySettings"` + // The banner message for the UI. It is the stringified result of the banner message object. + // Example: {\"closable\":true,\"message\":\"your banner message content\",\"type\":\"warning\",\"fromDate\":\"06/19/2023\",\"toDate\":\"06/21/2023\"} + BannerMessage *string `json:"banner_message,omitempty" js:"bannerMessage"` + + // The current time of the server. + // Format: date-time + CurrentTime *strfmt.DateTime `json:"current_time,omitempty" js:"currentTime"` + // The external URL of Harbor, with protocol. ExternalURL *string `json:"external_url,omitempty" js:"externalURL"` @@ -36,6 +45,12 @@ type GeneralInfo struct { // The flag to indicate whether notification mechanism is enabled on Harbor instance. NotificationEnable *bool `json:"notification_enable,omitempty" js:"notificationEnable"` + // The OIDC provider name, empty if current auth is not OIDC_auth or OIDC provider is not configured. + OIDCProviderName *string `json:"oidc_provider_name,omitempty" js:"oidcProviderName"` + + // The flag to indicate whether the current auth mode should consider as a primary one. + PrimaryAuthMode *bool `json:"primary_auth_mode,omitempty" js:"primaryAuthMode"` + // Indicate who can create projects, it could be 'adminonly' or 'everyone'. ProjectCreationRestriction *string `json:"project_creation_restriction,omitempty" js:"projectCreationRestriction"` @@ -50,12 +65,6 @@ type GeneralInfo struct { // Indicate whether the Harbor instance enable user to register himself. SelfRegistration *bool `json:"self_registration,omitempty" js:"selfRegistration"` - - // If the Harbor instance is deployed with nested chartmuseum. - WithChartmuseum *bool `json:"with_chartmuseum,omitempty" js:"withChartmuseum"` - - // If the Harbor instance is deployed with nested notary. - WithNotary *bool `json:"with_notary,omitempty" js:"withNotary"` } // Validate validates this general info @@ -66,6 +75,10 @@ func (m *GeneralInfo) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCurrentTime(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -91,6 +104,18 @@ func (m *GeneralInfo) validateAuthproxySettings(formats strfmt.Registry) error { return nil } +func (m *GeneralInfo) validateCurrentTime(formats strfmt.Registry) error { + if swag.IsZero(m.CurrentTime) { // not required + return nil + } + + if err := validate.FormatOf("current_time", "body", "date-time", m.CurrentTime.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this general info based on the context it is used func (m *GeneralInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/harbor/models/integer_config_item.go b/pkg/harbor/models/integer_config_item.go index 19998f0..c179aab 100644 --- a/pkg/harbor/models/integer_config_item.go +++ b/pkg/harbor/models/integer_config_item.go @@ -18,10 +18,10 @@ import ( type IntegerConfigItem struct { // The configure item can be updated or not - Editable bool `json:"editable,omitempty" js:"editable"` + Editable bool `json:"editable" js:"editable"` // The integer value of current config item - Value int64 `json:"value,omitempty" js:"value"` + Value int64 `json:"value" js:"value"` } // Validate validates this integer config item diff --git a/pkg/harbor/models/internal_configuration_value.go b/pkg/harbor/models/internal_configuration_value.go new file mode 100644 index 0000000..0c2c7fc --- /dev/null +++ b/pkg/harbor/models/internal_configuration_value.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// InternalConfigurationValue internal configuration value +// +// swagger:model InternalConfigurationValue +type InternalConfigurationValue struct { + + // The configure item can be updated or not + Editable bool `json:"editable" js:"editable"` + + // The value of current config item + Value interface{} `json:"value,omitempty" js:"value"` +} + +// Validate validates this internal configuration value +func (m *InternalConfigurationValue) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this internal configuration value based on context it is used +func (m *InternalConfigurationValue) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *InternalConfigurationValue) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InternalConfigurationValue) UnmarshalBinary(b []byte) error { + var res InternalConfigurationValue + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/internal_configurations_response.go b/pkg/harbor/models/internal_configurations_response.go index a8723d3..79db0de 100644 --- a/pkg/harbor/models/internal_configurations_response.go +++ b/pkg/harbor/models/internal_configurations_response.go @@ -5,7 +5,63 @@ package models // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + // InternalConfigurationsResponse internal configurations response // // swagger:model InternalConfigurationsResponse -type InternalConfigurationsResponse interface{} +type InternalConfigurationsResponse map[string]InternalConfigurationValue + +// Validate validates this internal configurations response +func (m InternalConfigurationsResponse) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(k) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(k) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this internal configurations response based on the context it is used +func (m InternalConfigurationsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/harbor/models/job_queue.go b/pkg/harbor/models/job_queue.go new file mode 100644 index 0000000..667971a --- /dev/null +++ b/pkg/harbor/models/job_queue.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// JobQueue the job queue info +// +// swagger:model JobQueue +type JobQueue struct { + + // The count of jobs in the job queue + Count int64 `json:"count,omitempty" js:"count"` + + // The type of the job queue + JobType string `json:"job_type,omitempty" js:"jobType"` + + // The latency the job queue (seconds) + Latency int64 `json:"latency,omitempty" js:"latency"` + + // The paused status of the job queue + Paused bool `json:"paused" js:"paused"` +} + +// Validate validates this job queue +func (m *JobQueue) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this job queue based on context it is used +func (m *JobQueue) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *JobQueue) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JobQueue) UnmarshalBinary(b []byte) error { + var res JobQueue + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/native_report_summary.go b/pkg/harbor/models/native_report_summary.go index e877f05..24af88b 100644 --- a/pkg/harbor/models/native_report_summary.go +++ b/pkg/harbor/models/native_report_summary.go @@ -28,7 +28,7 @@ type NativeReportSummary struct { Duration int64 `json:"duration,omitempty" js:"duration"` // The end time of the scan process that generating report - // Example: 2006-01-02T15:04:05 + // Example: 2006-01-02T15:04:05Z // Format: date-time EndTime strfmt.DateTime `json:"end_time,omitempty" js:"endTime"` @@ -48,7 +48,7 @@ type NativeReportSummary struct { Severity string `json:"severity,omitempty" js:"severity"` // The start time of the scan process that generating report - // Example: 2006-01-02T14:04:05 + // Example: 2006-01-02T14:04:05Z // Format: date-time StartTime strfmt.DateTime `json:"start_time,omitempty" js:"startTime"` diff --git a/pkg/harbor/models/notify_type.go b/pkg/harbor/models/notify_type.go index b06f447..3b6699a 100644 --- a/pkg/harbor/models/notify_type.go +++ b/pkg/harbor/models/notify_type.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/strfmt" ) -// NotifyType Webhook supportted notify type. +// NotifyType Webhook supported notify type. // Example: http // // swagger:model NotifyType diff --git a/pkg/harbor/models/payload_format.go b/pkg/harbor/models/payload_format.go new file mode 100644 index 0000000..615cc42 --- /dev/null +++ b/pkg/harbor/models/payload_format.go @@ -0,0 +1,159 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PayloadFormat Webhook supported payload format type collections. +// +// swagger:model PayloadFormat +type PayloadFormat struct { + + // The supported payload formats for this notify type. + Formats []PayloadFormatType `json:"formats" js:"formats"` + + // notify type + NotifyType NotifyType `json:"notify_type,omitempty" js:"notifyType"` +} + +// Validate validates this payload format +func (m *PayloadFormat) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFormats(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotifyType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PayloadFormat) validateFormats(formats strfmt.Registry) error { + if swag.IsZero(m.Formats) { // not required + return nil + } + + for i := 0; i < len(m.Formats); i++ { + + if err := m.Formats[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("formats" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("formats" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *PayloadFormat) validateNotifyType(formats strfmt.Registry) error { + if swag.IsZero(m.NotifyType) { // not required + return nil + } + + if err := m.NotifyType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("notify_type") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("notify_type") + } + return err + } + + return nil +} + +// ContextValidate validate this payload format based on the context it is used +func (m *PayloadFormat) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateFormats(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNotifyType(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PayloadFormat) contextValidateFormats(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Formats); i++ { + + if swag.IsZero(m.Formats[i]) { // not required + return nil + } + + if err := m.Formats[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("formats" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("formats" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *PayloadFormat) contextValidateNotifyType(ctx context.Context, formats strfmt.Registry) error { + + if swag.IsZero(m.NotifyType) { // not required + return nil + } + + if err := m.NotifyType.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("notify_type") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("notify_type") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PayloadFormat) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PayloadFormat) UnmarshalBinary(b []byte) error { + var res PayloadFormat + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/payload_format_type.go b/pkg/harbor/models/payload_format_type.go new file mode 100644 index 0000000..ab8ce55 --- /dev/null +++ b/pkg/harbor/models/payload_format_type.go @@ -0,0 +1,28 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// PayloadFormatType The type of webhook paylod format. +// Example: CloudEvents +// +// swagger:model PayloadFormatType +type PayloadFormatType string + +// Validate validates this payload format type +func (m PayloadFormatType) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this payload format type based on context it is used +func (m PayloadFormatType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/pkg/harbor/models/permissions.go b/pkg/harbor/models/permissions.go new file mode 100644 index 0000000..7f2c3bc --- /dev/null +++ b/pkg/harbor/models/permissions.go @@ -0,0 +1,183 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Permissions permissions +// +// swagger:model Permissions +type Permissions struct { + + // The project level permissions + Project []*Permission `json:"project" js:"project"` + + // The system level permissions + System []*Permission `json:"system" js:"system"` +} + +// Validate validates this permissions +func (m *Permissions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProject(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSystem(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Permissions) validateProject(formats strfmt.Registry) error { + if swag.IsZero(m.Project) { // not required + return nil + } + + for i := 0; i < len(m.Project); i++ { + if swag.IsZero(m.Project[i]) { // not required + continue + } + + if m.Project[i] != nil { + if err := m.Project[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Permissions) validateSystem(formats strfmt.Registry) error { + if swag.IsZero(m.System) { // not required + return nil + } + + for i := 0; i < len(m.System); i++ { + if swag.IsZero(m.System[i]) { // not required + continue + } + + if m.System[i] != nil { + if err := m.System[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("system" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("system" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this permissions based on the context it is used +func (m *Permissions) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProject(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSystem(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Permissions) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Project); i++ { + + if m.Project[i] != nil { + + if swag.IsZero(m.Project[i]) { // not required + return nil + } + + if err := m.Project[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("project" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("project" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Permissions) contextValidateSystem(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.System); i++ { + + if m.System[i] != nil { + + if swag.IsZero(m.System[i]) { // not required + return nil + } + + if err := m.System[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("system" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("system" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Permissions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Permissions) UnmarshalBinary(b []byte) error { + var res Permissions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/project.go b/pkg/harbor/models/project.go index 23eb7d3..55c3b63 100644 --- a/pkg/harbor/models/project.go +++ b/pkg/harbor/models/project.go @@ -19,9 +19,6 @@ import ( // swagger:model Project type Project struct { - // The total number of charts under this project. - ChartCount int64 `json:"chart_count,omitempty" js:"chartCount"` - // The creation time of the project. // Format: date-time CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` @@ -57,7 +54,7 @@ type Project struct { RegistryID int64 `json:"registry_id,omitempty" js:"registryID"` // The number of the repositories under this project. - RepoCount int64 `json:"repo_count,omitempty" js:"repoCount"` + RepoCount int64 `json:"repo_count" js:"repoCount"` // Correspond to the UI about whether the project's publicity is updatable (for UI) Togglable bool `json:"togglable,omitempty" js:"togglable"` diff --git a/pkg/harbor/models/project_metadata.go b/pkg/harbor/models/project_metadata.go index 51af809..447e516 100644 --- a/pkg/harbor/models/project_metadata.go +++ b/pkg/harbor/models/project_metadata.go @@ -17,12 +17,18 @@ import ( // swagger:model ProjectMetadata type ProjectMetadata struct { + // Whether generating SBOM automatically when pushing a subject artifact. The valid values are "true", "false". + AutoSbomGeneration *string `json:"auto_sbom_generation,omitempty" js:"autoSbomGeneration"` + // Whether scan images automatically when pushing. The valid values are "true", "false". AutoScan *string `json:"auto_scan,omitempty" js:"autoScan"` // Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are "true", "false". EnableContentTrust *string `json:"enable_content_trust,omitempty" js:"enableContentTrust"` + // Whether cosign content trust is enabled or not. If it is enabled, user can't pull images without cosign signature from this project. The valid values are "true", "false". + EnableContentTrustCosign *string `json:"enable_content_trust_cosign,omitempty" js:"enableContentTrustCosign"` + // Whether prevent the vulnerable images from running. The valid values are "true", "false". PreventVul *string `json:"prevent_vul,omitempty" js:"preventVul"` diff --git a/pkg/harbor/models/project_req.go b/pkg/harbor/models/project_req.go index ac49d63..c6d496f 100644 --- a/pkg/harbor/models/project_req.go +++ b/pkg/harbor/models/project_req.go @@ -11,6 +11,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // ProjectReq project req @@ -25,6 +26,7 @@ type ProjectReq struct { Metadata *ProjectMetadata `json:"metadata,omitempty" js:"metadata"` // The name of the project. + // Max Length: 255 ProjectName string `json:"project_name,omitempty" js:"projectName"` // deprecated, reserved for project creation in replication @@ -49,6 +51,10 @@ func (m *ProjectReq) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateProjectName(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -93,6 +99,18 @@ func (m *ProjectReq) validateMetadata(formats strfmt.Registry) error { return nil } +func (m *ProjectReq) validateProjectName(formats strfmt.Registry) error { + if swag.IsZero(m.ProjectName) { // not required + return nil + } + + if err := validate.MaxLength("project_name", "body", m.ProjectName, 255); err != nil { + return err + } + + return nil +} + // ContextValidate validate this project req based on the context it is used func (m *ProjectReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/harbor/models/project_summary.go b/pkg/harbor/models/project_summary.go index c6b33b4..7a8f53d 100644 --- a/pkg/harbor/models/project_summary.go +++ b/pkg/harbor/models/project_summary.go @@ -18,9 +18,6 @@ import ( // swagger:model ProjectSummary type ProjectSummary struct { - // The total number of charts under this project. - ChartCount int64 `json:"chart_count,omitempty" js:"chartCount"` - // The total number of developer members. DeveloperCount int64 `json:"developer_count,omitempty" js:"developerCount"` @@ -43,7 +40,7 @@ type ProjectSummary struct { Registry *Registry `json:"registry,omitempty" js:"registry"` // The number of the repositories under this project. - RepoCount int64 `json:"repo_count,omitempty" js:"repoCount"` + RepoCount int64 `json:"repo_count" js:"repoCount"` } // Validate validates this project summary diff --git a/pkg/harbor/models/registry_info.go b/pkg/harbor/models/registry_info.go index 520ed03..5d7e783 100644 --- a/pkg/harbor/models/registry_info.go +++ b/pkg/harbor/models/registry_info.go @@ -22,6 +22,9 @@ type RegistryInfo struct { // The description Description string `json:"description,omitempty" js:"description"` + // The registry whether support copy by chunk. + SupportedCopyByChunk *bool `json:"supported_copy_by_chunk,omitempty" js:"supportedCopyByChunk"` + // The filters that the registry supports SupportedResourceFilters []*FilterStyle `json:"supported_resource_filters" js:"supportedResourceFilters"` diff --git a/pkg/harbor/models/replication_filter.go b/pkg/harbor/models/replication_filter.go index 4a9463f..afaed12 100644 --- a/pkg/harbor/models/replication_filter.go +++ b/pkg/harbor/models/replication_filter.go @@ -17,6 +17,9 @@ import ( // swagger:model ReplicationFilter type ReplicationFilter struct { + // matches or excludes the result + Decoration string `json:"decoration,omitempty" js:"decoration"` + // The replication policy filter type. Type string `json:"type,omitempty" js:"type"` diff --git a/pkg/harbor/models/replication_policy.go b/pkg/harbor/models/replication_policy.go index 027ecb3..4593131 100644 --- a/pkg/harbor/models/replication_policy.go +++ b/pkg/harbor/models/replication_policy.go @@ -20,6 +20,9 @@ import ( // swagger:model ReplicationPolicy type ReplicationPolicy struct { + // Whether to enable copy by chunk. + CopyByChunk *bool `json:"copy_by_chunk,omitempty" js:"copyByChunk"` + // The create time of the policy. // Format: date-time CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` @@ -58,6 +61,9 @@ type ReplicationPolicy struct { // Whether to replicate the deletion operation. ReplicateDeletion bool `json:"replicate_deletion,omitempty" js:"replicateDeletion"` + // speed limit for each task + Speed *int32 `json:"speed,omitempty" js:"speed"` + // The source registry. SrcRegistry *Registry `json:"src_registry,omitempty" js:"srcRegistry"` diff --git a/pkg/harbor/models/repository.go b/pkg/harbor/models/repository.go index 1b45450..4278071 100644 --- a/pkg/harbor/models/repository.go +++ b/pkg/harbor/models/repository.go @@ -20,11 +20,11 @@ import ( type Repository struct { // The count of the artifacts inside the repository - ArtifactCount int64 `json:"artifact_count,omitempty" js:"artifactCount"` + ArtifactCount int64 `json:"artifact_count" js:"artifactCount"` // The creation time of the repository // Format: date-time - CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` + CreationTime *strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` // The description of the repository Description string `json:"description,omitempty" js:"description"` @@ -39,7 +39,7 @@ type Repository struct { ProjectID int64 `json:"project_id,omitempty" js:"projectID"` // The count that the artifact inside the repository pulled - PullCount int64 `json:"pull_count,omitempty" js:"pullCount"` + PullCount int64 `json:"pull_count" js:"pullCount"` // The update time of the repository // Format: date-time diff --git a/pkg/harbor/models/robot.go b/pkg/harbor/models/robot.go index cf95768..e772aac 100644 --- a/pkg/harbor/models/robot.go +++ b/pkg/harbor/models/robot.go @@ -30,13 +30,13 @@ type Robot struct { // The disable status of the robot Disable bool `json:"disable" js:"disable"` - // The duration of the robot in days - Duration int64 `json:"duration,omitempty" js:"duration"` + // The duration of the robot in days, duration must be either -1(Never) or a positive integer + Duration *int64 `json:"duration,omitempty" js:"duration"` // The editable status of the robot Editable bool `json:"editable" js:"editable"` - // The expiration data of the robot + // The expiration date of the robot ExpiresAt int64 `json:"expires_at,omitempty" js:"expiresAt"` // The ID of the robot @@ -45,7 +45,7 @@ type Robot struct { // The level of the robot, project or system Level string `json:"level,omitempty" js:"level"` - // The name of the tag + // The name of the robot Name string `json:"name,omitempty" js:"name"` // permissions diff --git a/pkg/harbor/models/robot_create.go b/pkg/harbor/models/robot_create.go index b0cb095..8bb7407 100644 --- a/pkg/harbor/models/robot_create.go +++ b/pkg/harbor/models/robot_create.go @@ -25,13 +25,13 @@ type RobotCreate struct { // The disable status of the robot Disable bool `json:"disable,omitempty" js:"disable"` - // The duration of the robot in days + // The duration of the robot in days, duration must be either -1(Never) or a positive integer Duration int64 `json:"duration,omitempty" js:"duration"` // The level of the robot, project or system Level string `json:"level,omitempty" js:"level"` - // The name of the tag + // The name of the robot Name string `json:"name,omitempty" js:"name"` // permissions diff --git a/pkg/harbor/models/robot_created.go b/pkg/harbor/models/robot_created.go index 7c93842..5f3d338 100644 --- a/pkg/harbor/models/robot_created.go +++ b/pkg/harbor/models/robot_created.go @@ -23,13 +23,13 @@ type RobotCreated struct { // Format: date-time CreationTime strfmt.DateTime `json:"creation_time,omitempty" js:"creationTime"` - // The expiration data of the robot + // The expiration date of the robot ExpiresAt int64 `json:"expires_at,omitempty" js:"expiresAt"` // The ID of the robot ID int64 `json:"id,omitempty" js:"id"` - // The name of the tag + // The name of the robot Name string `json:"name,omitempty" js:"name"` // The secret of the robot diff --git a/pkg/harbor/models/s_b_o_m_overview.go b/pkg/harbor/models/s_b_o_m_overview.go new file mode 100644 index 0000000..1dff796 --- /dev/null +++ b/pkg/harbor/models/s_b_o_m_overview.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SBOMOverview The generate SBOM overview information +// +// swagger:model SBOMOverview +type SBOMOverview struct { + + // Time in seconds required to create the report + // Example: 300 + Duration int64 `json:"duration,omitempty" js:"duration"` + + // The end time of the generating sbom report task + // Example: 2006-01-02T15:04:05Z + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty" js:"endTime"` + + // id of the native scan report + // Example: 5f62c830-f996-11e9-957f-0242c0a89008 + ReportID string `json:"report_id,omitempty" js:"reportID"` + + // The digest of the generated SBOM accessory + SbomDigest string `json:"sbom_digest,omitempty" js:"sbomDigest"` + + // The status of the generating SBOM task + ScanStatus string `json:"scan_status,omitempty" js:"scanStatus"` + + // scanner + Scanner *Scanner `json:"scanner,omitempty" js:"scanner"` + + // The start time of the generating sbom report task + // Example: 2006-01-02T14:04:05Z + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty" js:"startTime"` +} + +// Validate validates this s b o m overview +func (m *SBOMOverview) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanner(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SBOMOverview) validateEndTime(formats strfmt.Registry) error { + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *SBOMOverview) validateScanner(formats strfmt.Registry) error { + if swag.IsZero(m.Scanner) { // not required + return nil + } + + if m.Scanner != nil { + if err := m.Scanner.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scanner") + } + return err + } + } + + return nil +} + +func (m *SBOMOverview) validateStartTime(formats strfmt.Registry) error { + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this s b o m overview based on the context it is used +func (m *SBOMOverview) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateScanner(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SBOMOverview) contextValidateScanner(ctx context.Context, formats strfmt.Registry) error { + + if m.Scanner != nil { + + if swag.IsZero(m.Scanner) { // not required + return nil + } + + if err := m.Scanner.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("scanner") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("scanner") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SBOMOverview) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SBOMOverview) UnmarshalBinary(b []byte) error { + var res SBOMOverview + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scan_data_export_execution.go b/pkg/harbor/models/scan_data_export_execution.go new file mode 100644 index 0000000..a142661 --- /dev/null +++ b/pkg/harbor/models/scan_data_export_execution.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScanDataExportExecution The replication execution +// +// swagger:model ScanDataExportExecution +type ScanDataExportExecution struct { + + // The end time + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty" js:"endTime"` + + // Indicates whether the export artifact is present in registry + FilePresent bool `json:"file_present" js:"filePresent"` + + // The ID of the execution + ID int64 `json:"id,omitempty" js:"id"` + + // The start time + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty" js:"startTime"` + + // The status of the execution + Status string `json:"status,omitempty" js:"status"` + + // The status text + StatusText string `json:"status_text" js:"statusText"` + + // The trigger mode + Trigger string `json:"trigger,omitempty" js:"trigger"` + + // The ID if the user triggering the export job + UserID int64 `json:"user_id,omitempty" js:"userID"` + + // The name of the user triggering the job + UserName string `json:"user_name" js:"userName"` +} + +// Validate validates this scan data export execution +func (m *ScanDataExportExecution) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanDataExportExecution) validateEndTime(formats strfmt.Registry) error { + if swag.IsZero(m.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *ScanDataExportExecution) validateStartTime(formats strfmt.Registry) error { + if swag.IsZero(m.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this scan data export execution based on context it is used +func (m *ScanDataExportExecution) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportExecution) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportExecution) UnmarshalBinary(b []byte) error { + var res ScanDataExportExecution + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scan_data_export_execution_list.go b/pkg/harbor/models/scan_data_export_execution_list.go new file mode 100644 index 0000000..47c95b2 --- /dev/null +++ b/pkg/harbor/models/scan_data_export_execution_list.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportExecutionList The list of scan data export executions +// +// swagger:model ScanDataExportExecutionList +type ScanDataExportExecutionList struct { + + // The list of scan data export executions + Items []*ScanDataExportExecution `json:"items" js:"items"` +} + +// Validate validates this scan data export execution list +func (m *ScanDataExportExecutionList) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanDataExportExecutionList) validateItems(formats strfmt.Registry) error { + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this scan data export execution list based on the context it is used +func (m *ScanDataExportExecutionList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateItems(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanDataExportExecutionList) contextValidateItems(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Items); i++ { + + if m.Items[i] != nil { + + if swag.IsZero(m.Items[i]) { // not required + return nil + } + + if err := m.Items[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportExecutionList) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportExecutionList) UnmarshalBinary(b []byte) error { + var res ScanDataExportExecutionList + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scan_data_export_job.go b/pkg/harbor/models/scan_data_export_job.go new file mode 100644 index 0000000..be762eb --- /dev/null +++ b/pkg/harbor/models/scan_data_export_job.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportJob The metadata associated with the scan data export job +// +// swagger:model ScanDataExportJob +type ScanDataExportJob struct { + + // The id of the scan data export job + ID int64 `json:"id,omitempty" js:"id"` +} + +// Validate validates this scan data export job +func (m *ScanDataExportJob) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this scan data export job based on context it is used +func (m *ScanDataExportJob) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportJob) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportJob) UnmarshalBinary(b []byte) error { + var res ScanDataExportJob + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scan_data_export_request.go b/pkg/harbor/models/scan_data_export_request.go new file mode 100644 index 0000000..c899f8e --- /dev/null +++ b/pkg/harbor/models/scan_data_export_request.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ScanDataExportRequest The criteria to select the scan data to export. +// +// swagger:model ScanDataExportRequest +type ScanDataExportRequest struct { + + // CVE-IDs for which to export data. Multiple CVE-IDs can be specified by separating using ',' and enclosed between '{}'. Defaults to all if empty + CVEIds string `json:"cveIds,omitempty" js:"cveIds"` + + // Name of the scan data export job + JobName string `json:"job_name,omitempty" js:"jobName"` + + // A list of one or more labels for which to export the scan data, defaults to all if empty + Labels []int64 `json:"labels" js:"labels"` + + // A list of one or more projects for which to export the scan data, currently only one project is supported due to performance concerns, but define as array for extension in the future. + Projects []int64 `json:"projects" js:"projects"` + + // A list of repositories for which to export the scan data, defaults to all if empty + Repositories string `json:"repositories,omitempty" js:"repositories"` + + // A list of tags enclosed within '{}'. Defaults to all if empty + Tags string `json:"tags,omitempty" js:"tags"` +} + +// Validate validates this scan data export request +func (m *ScanDataExportRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this scan data export request based on context it is used +func (m *ScanDataExportRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanDataExportRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanDataExportRequest) UnmarshalBinary(b []byte) error { + var res ScanDataExportRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scan_type.go b/pkg/harbor/models/scan_type.go new file mode 100644 index 0000000..de3870f --- /dev/null +++ b/pkg/harbor/models/scan_type.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScanType scan type +// +// swagger:model ScanType +type ScanType struct { + + // The scan type for the scan request. Two options are currently supported, vulnerability and sbom + // Enum: [vulnerability sbom] + ScanType string `json:"scan_type,omitempty" js:"scanType"` +} + +// Validate validates this scan type +func (m *ScanType) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateScanType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var scanTypeTypeScanTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["vulnerability","sbom"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + scanTypeTypeScanTypePropEnum = append(scanTypeTypeScanTypePropEnum, v) + } +} + +const ( + + // ScanTypeScanTypeVulnerability captures enum value "vulnerability" + ScanTypeScanTypeVulnerability string = "vulnerability" + + // ScanTypeScanTypeSbom captures enum value "sbom" + ScanTypeScanTypeSbom string = "sbom" +) + +// prop value enum +func (m *ScanType) validateScanTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, scanTypeTypeScanTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ScanType) validateScanType(formats strfmt.Registry) error { + if swag.IsZero(m.ScanType) { // not required + return nil + } + + // value enum + if err := m.validateScanTypeEnum("scan_type", "body", m.ScanType); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this scan type based on context it is used +func (m *ScanType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScanType) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanType) UnmarshalBinary(b []byte) error { + var res ScanType + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scanner_capability.go b/pkg/harbor/models/scanner_capability.go index a88e8bf..e65ec36 100644 --- a/pkg/harbor/models/scanner_capability.go +++ b/pkg/harbor/models/scanner_capability.go @@ -22,6 +22,11 @@ type ScannerCapability struct { // produces mime types ProducesMimeTypes []string `json:"produces_mime_types" js:"producesMimeTypes"` + + // Specify the type of scanner capability, like vulnerability or sbom + // + // Example: sbom + Type string `json:"type" js:"type"` } // Validate validates this scanner capability diff --git a/pkg/harbor/models/scanner_registration.go b/pkg/harbor/models/scanner_registration.go index de5b527..7095c19 100644 --- a/pkg/harbor/models/scanner_registration.go +++ b/pkg/harbor/models/scanner_registration.go @@ -25,7 +25,7 @@ type ScannerRegistration struct { AccessCredential string `json:"access_credential" js:"accessCredential"` // Optional property to describe the name of the scanner registration - // Example: Clair + // Example: Trivy Adapter string `json:"adapter,omitempty" js:"adapter"` // Specify what authentication approach is adopted for the HTTP communications. @@ -34,6 +34,10 @@ type ScannerRegistration struct { // Example: Bearer Auth string `json:"auth" js:"auth"` + // Indicates the capabilities of the scanner, e.g. support_vulnerability or support_sbom. + // Example: {"support_sbom":true,"support_vulnerability":true} + Capabilities interface{} `json:"capabilities,omitempty" js:"capabilities"` + // The creation time of this registration // Format: date-time CreateTime strfmt.DateTime `json:"create_time,omitempty" js:"createTime"` @@ -65,7 +69,8 @@ type ScannerRegistration struct { // A base URL of the scanner adapter // Example: http://harbor-scanner-trivy:8080 - URL string `json:"url,omitempty" js:"url"` + // Format: uri + URL strfmt.URI `json:"url,omitempty" js:"url"` // Indicate whether use internal registry addr for the scanner to pull content or not UseInternalAddr *bool `json:"use_internal_addr" js:"useInternalAddr"` @@ -94,6 +99,10 @@ func (m *ScannerRegistration) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -124,6 +133,18 @@ func (m *ScannerRegistration) validateUpdateTime(formats strfmt.Registry) error return nil } +func (m *ScannerRegistration) validateURL(formats strfmt.Registry) error { + if swag.IsZero(m.URL) { // not required + return nil + } + + if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validates this scanner registration based on context it is used func (m *ScannerRegistration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil diff --git a/pkg/harbor/models/schedule_obj.go b/pkg/harbor/models/schedule_obj.go index 2faff50..412403c 100644 --- a/pkg/harbor/models/schedule_obj.go +++ b/pkg/harbor/models/schedule_obj.go @@ -23,10 +23,15 @@ type ScheduleObj struct { // A cron expression, a time-based job scheduler. Cron string `json:"cron,omitempty" js:"cron"` - // The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual' and 'None'. - // 'Manual' means to trigger it right away and 'None' means to cancel the schedule. + // The next time to schedule to run the job. + // Format: date-time + NextScheduledTime strfmt.DateTime `json:"next_scheduled_time,omitempty" js:"nextScheduledTime"` + + // The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual', 'None' and 'Schedule'. + // 'Manual' means to trigger it right away, 'Schedule' means to trigger it by a specified cron schedule and + // 'None' means to cancel the schedule. // - // Enum: [Hourly Daily Weekly Custom Manual None] + // Enum: [Hourly Daily Weekly Custom Manual None Schedule] Type string `json:"type,omitempty" js:"type"` } @@ -34,6 +39,10 @@ type ScheduleObj struct { func (m *ScheduleObj) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateNextScheduledTime(formats); err != nil { + res = append(res, err) + } + if err := m.validateType(formats); err != nil { res = append(res, err) } @@ -44,11 +53,23 @@ func (m *ScheduleObj) Validate(formats strfmt.Registry) error { return nil } +func (m *ScheduleObj) validateNextScheduledTime(formats strfmt.Registry) error { + if swag.IsZero(m.NextScheduledTime) { // not required + return nil + } + + if err := validate.FormatOf("next_scheduled_time", "body", "date-time", m.NextScheduledTime.String(), formats); err != nil { + return err + } + + return nil +} + var scheduleObjTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Hourly","Daily","Weekly","Custom","Manual","None"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Hourly","Daily","Weekly","Custom","Manual","None","Schedule"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -75,6 +96,9 @@ const ( // ScheduleObjTypeNone captures enum value "None" ScheduleObjTypeNone string = "None" + + // ScheduleObjTypeSchedule captures enum value "Schedule" + ScheduleObjTypeSchedule string = "Schedule" ) // prop value enum diff --git a/pkg/harbor/models/schedule_task.go b/pkg/harbor/models/schedule_task.go new file mode 100644 index 0000000..938e496 --- /dev/null +++ b/pkg/harbor/models/schedule_task.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScheduleTask the schedule task info +// +// swagger:model ScheduleTask +type ScheduleTask struct { + + // the cron of the current schedule task + Cron string `json:"cron,omitempty" js:"cron"` + + // the id of the Schedule task + ID int64 `json:"id,omitempty" js:"id"` + + // the update time of the schedule task + // Format: date-time + UpdateTime strfmt.DateTime `json:"update_time,omitempty" js:"updateTime"` + + // the vendor id of the current task + VendorID int64 `json:"vendor_id,omitempty" js:"vendorID"` + + // the vendor type of the current schedule task + VendorType string `json:"vendor_type,omitempty" js:"vendorType"` +} + +// Validate validates this schedule task +func (m *ScheduleTask) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateUpdateTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScheduleTask) validateUpdateTime(formats strfmt.Registry) error { + if swag.IsZero(m.UpdateTime) { // not required + return nil + } + + if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this schedule task based on context it is used +func (m *ScheduleTask) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ScheduleTask) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScheduleTask) UnmarshalBinary(b []byte) error { + var res ScheduleTask + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/scheduler_status.go b/pkg/harbor/models/scheduler_status.go new file mode 100644 index 0000000..ce6e9a6 --- /dev/null +++ b/pkg/harbor/models/scheduler_status.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SchedulerStatus the scheduler status +// +// swagger:model SchedulerStatus +type SchedulerStatus struct { + + // if the scheduler is paused + Paused bool `json:"paused" js:"paused"` +} + +// Validate validates this scheduler status +func (m *SchedulerStatus) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this scheduler status based on context it is used +func (m *SchedulerStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SchedulerStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SchedulerStatus) UnmarshalBinary(b []byte) error { + var res SchedulerStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/search.go b/pkg/harbor/models/search.go index b094a46..686aac3 100644 --- a/pkg/harbor/models/search.go +++ b/pkg/harbor/models/search.go @@ -19,9 +19,6 @@ import ( // swagger:model Search type Search struct { - // Search results of the charts that macthed the filter keywords. - Chart []*SearchResult `json:"chart,omitempty" js:"chart"` - // Search results of the projects that matched the filter keywords. Project []*Project `json:"project" js:"project"` @@ -33,10 +30,6 @@ type Search struct { func (m *Search) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateChart(formats); err != nil { - res = append(res, err) - } - if err := m.validateProject(formats); err != nil { res = append(res, err) } @@ -51,32 +44,6 @@ func (m *Search) Validate(formats strfmt.Registry) error { return nil } -func (m *Search) validateChart(formats strfmt.Registry) error { - if swag.IsZero(m.Chart) { // not required - return nil - } - - for i := 0; i < len(m.Chart); i++ { - if swag.IsZero(m.Chart[i]) { // not required - continue - } - - if m.Chart[i] != nil { - if err := m.Chart[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("chart" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("chart" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - func (m *Search) validateProject(formats strfmt.Registry) error { if swag.IsZero(m.Project) { // not required return nil @@ -133,10 +100,6 @@ func (m *Search) validateRepository(formats strfmt.Registry) error { func (m *Search) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error - if err := m.contextValidateChart(ctx, formats); err != nil { - res = append(res, err) - } - if err := m.contextValidateProject(ctx, formats); err != nil { res = append(res, err) } @@ -151,31 +114,6 @@ func (m *Search) ContextValidate(ctx context.Context, formats strfmt.Registry) e return nil } -func (m *Search) contextValidateChart(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Chart); i++ { - - if m.Chart[i] != nil { - - if swag.IsZero(m.Chart[i]) { // not required - return nil - } - - if err := m.Chart[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("chart" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("chart" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - func (m *Search) contextValidateProject(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Project); i++ { diff --git a/pkg/harbor/models/search_result.go b/pkg/harbor/models/search_result.go deleted file mode 100644 index bf9a8b9..0000000 --- a/pkg/harbor/models/search_result.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// SearchResult The chart search result item -// -// swagger:model SearchResult -type SearchResult struct { - - // chart - Chart *ChartVersion `json:"Chart,omitempty" js:"chart"` - - // The chart name with repo name - Name string `json:"Name,omitempty" js:"name"` - - // The matched level - Score int64 `json:"Score,omitempty" js:"score"` -} - -// Validate validates this search result -func (m *SearchResult) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateChart(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SearchResult) validateChart(formats strfmt.Registry) error { - if swag.IsZero(m.Chart) { // not required - return nil - } - - if m.Chart != nil { - if err := m.Chart.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("Chart") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("Chart") - } - return err - } - } - - return nil -} - -// ContextValidate validate this search result based on the context it is used -func (m *SearchResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateChart(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SearchResult) contextValidateChart(ctx context.Context, formats strfmt.Registry) error { - - if m.Chart != nil { - - if swag.IsZero(m.Chart) { // not required - return nil - } - - if err := m.Chart.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("Chart") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("Chart") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SearchResult) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SearchResult) UnmarshalBinary(b []byte) error { - var res SearchResult - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/harbor/models/security_summary.go b/pkg/harbor/models/security_summary.go new file mode 100644 index 0000000..158cc09 --- /dev/null +++ b/pkg/harbor/models/security_summary.go @@ -0,0 +1,213 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SecuritySummary the security summary +// +// swagger:model SecuritySummary +type SecuritySummary struct { + + // the count of critical vulnerabilities + CriticalCnt int64 `json:"critical_cnt" js:"criticalCnt"` + + // the list of dangerous artifacts + DangerousArtifacts []*DangerousArtifact `json:"dangerous_artifacts,omitempty" js:"dangerousArtifacts"` + + // the list of dangerous CVEs + DangerousCves []*DangerousCVE `json:"dangerous_cves,omitempty" js:"dangerousCves"` + + // the count of fixable vulnerabilities + FixableCnt int64 `json:"fixable_cnt" js:"fixableCnt"` + + // the count of high vulnerabilities + HighCnt int64 `json:"high_cnt,omitempty" js:"highCnt"` + + // the count of low vulnerabilities + LowCnt int64 `json:"low_cnt" js:"lowCnt"` + + // the count of medium vulnerabilities + MediumCnt int64 `json:"medium_cnt" js:"mediumCnt"` + + // the count of none vulnerabilities + NoneCnt int64 `json:"none_cnt,omitempty" js:"noneCnt"` + + // the count of scanned artifacts + ScannedCnt int64 `json:"scanned_cnt" js:"scannedCnt"` + + // the total count of artifacts + TotalArtifact int64 `json:"total_artifact" js:"totalArtifact"` + + // the count of total vulnerabilities + TotalVuls int64 `json:"total_vuls" js:"totalVuls"` + + // the count of unknown vulnerabilities + UnknownCnt int64 `json:"unknown_cnt,omitempty" js:"unknownCnt"` +} + +// Validate validates this security summary +func (m *SecuritySummary) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateDangerousArtifacts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDangerousCves(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SecuritySummary) validateDangerousArtifacts(formats strfmt.Registry) error { + if swag.IsZero(m.DangerousArtifacts) { // not required + return nil + } + + for i := 0; i < len(m.DangerousArtifacts); i++ { + if swag.IsZero(m.DangerousArtifacts[i]) { // not required + continue + } + + if m.DangerousArtifacts[i] != nil { + if err := m.DangerousArtifacts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SecuritySummary) validateDangerousCves(formats strfmt.Registry) error { + if swag.IsZero(m.DangerousCves) { // not required + return nil + } + + for i := 0; i < len(m.DangerousCves); i++ { + if swag.IsZero(m.DangerousCves[i]) { // not required + continue + } + + if m.DangerousCves[i] != nil { + if err := m.DangerousCves[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this security summary based on the context it is used +func (m *SecuritySummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDangerousArtifacts(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDangerousCves(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SecuritySummary) contextValidateDangerousArtifacts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.DangerousArtifacts); i++ { + + if m.DangerousArtifacts[i] != nil { + + if swag.IsZero(m.DangerousArtifacts[i]) { // not required + return nil + } + + if err := m.DangerousArtifacts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SecuritySummary) contextValidateDangerousCves(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.DangerousCves); i++ { + + if m.DangerousCves[i] != nil { + + if swag.IsZero(m.DangerousCves[i]) { // not required + return nil + } + + if err := m.DangerousCves[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SecuritySummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SecuritySummary) UnmarshalBinary(b []byte) error { + var res SecuritySummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/string_config_item.go b/pkg/harbor/models/string_config_item.go index 1593d84..fef7411 100644 --- a/pkg/harbor/models/string_config_item.go +++ b/pkg/harbor/models/string_config_item.go @@ -18,10 +18,10 @@ import ( type StringConfigItem struct { // The configure item can be updated or not - Editable bool `json:"editable,omitempty" js:"editable"` + Editable bool `json:"editable" js:"editable"` // The string value of current config item - Value string `json:"value,omitempty" js:"value"` + Value string `json:"value" js:"value"` } // Validate validates this string config item diff --git a/pkg/harbor/models/supported_webhook_event_types.go b/pkg/harbor/models/supported_webhook_event_types.go index 9333c5f..5f1bbc2 100644 --- a/pkg/harbor/models/supported_webhook_event_types.go +++ b/pkg/harbor/models/supported_webhook_event_types.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/swag" ) -// SupportedWebhookEventTypes Supportted webhook event types and notify types. +// SupportedWebhookEventTypes Supported webhook event types and notify types. // // swagger:model SupportedWebhookEventTypes type SupportedWebhookEventTypes struct { @@ -24,6 +24,9 @@ type SupportedWebhookEventTypes struct { // notify type NotifyType []NotifyType `json:"notify_type" js:"notifyType"` + + // payload formats + PayloadFormats []*PayloadFormat `json:"payload_formats" js:"payloadFormats"` } // Validate validates this supported webhook event types @@ -38,6 +41,10 @@ func (m *SupportedWebhookEventTypes) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validatePayloadFormats(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -86,6 +93,32 @@ func (m *SupportedWebhookEventTypes) validateNotifyType(formats strfmt.Registry) return nil } +func (m *SupportedWebhookEventTypes) validatePayloadFormats(formats strfmt.Registry) error { + if swag.IsZero(m.PayloadFormats) { // not required + return nil + } + + for i := 0; i < len(m.PayloadFormats); i++ { + if swag.IsZero(m.PayloadFormats[i]) { // not required + continue + } + + if m.PayloadFormats[i] != nil { + if err := m.PayloadFormats[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("payload_formats" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("payload_formats" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // ContextValidate validate this supported webhook event types based on the context it is used func (m *SupportedWebhookEventTypes) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error @@ -98,6 +131,10 @@ func (m *SupportedWebhookEventTypes) ContextValidate(ctx context.Context, format res = append(res, err) } + if err := m.contextValidatePayloadFormats(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -148,6 +185,31 @@ func (m *SupportedWebhookEventTypes) contextValidateNotifyType(ctx context.Conte return nil } +func (m *SupportedWebhookEventTypes) contextValidatePayloadFormats(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.PayloadFormats); i++ { + + if m.PayloadFormats[i] != nil { + + if swag.IsZero(m.PayloadFormats[i]) { // not required + return nil + } + + if err := m.PayloadFormats[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("payload_formats" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("payload_formats" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *SupportedWebhookEventTypes) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/pkg/harbor/models/tag.go b/pkg/harbor/models/tag.go index a959df2..9c0359b 100644 --- a/pkg/harbor/models/tag.go +++ b/pkg/harbor/models/tag.go @@ -41,9 +41,6 @@ type Tag struct { // The ID of the repository that the tag belongs to RepositoryID int64 `json:"repository_id,omitempty" js:"repositoryID"` - - // The attribute indicates whether the tag is signed or not - Signed bool `json:"signed" js:"signed"` } // Validate validates this tag diff --git a/pkg/harbor/models/user_creation_req.go b/pkg/harbor/models/user_creation_req.go index 0430904..192351e 100644 --- a/pkg/harbor/models/user_creation_req.go +++ b/pkg/harbor/models/user_creation_req.go @@ -8,8 +8,10 @@ package models import ( "context" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // UserCreationReq user creation req @@ -21,6 +23,7 @@ type UserCreationReq struct { Comment string `json:"comment,omitempty" js:"comment"` // email + // Max Length: 255 Email string `json:"email,omitempty" js:"email"` // password @@ -30,11 +33,49 @@ type UserCreationReq struct { Realname string `json:"realname,omitempty" js:"realname"` // username + // Max Length: 255 Username string `json:"username,omitempty" js:"username"` } // Validate validates this user creation req func (m *UserCreationReq) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsername(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserCreationReq) validateEmail(formats strfmt.Registry) error { + if swag.IsZero(m.Email) { // not required + return nil + } + + if err := validate.MaxLength("email", "body", m.Email, 255); err != nil { + return err + } + + return nil +} + +func (m *UserCreationReq) validateUsername(formats strfmt.Registry) error { + if swag.IsZero(m.Username) { // not required + return nil + } + + if err := validate.MaxLength("username", "body", m.Username, 255); err != nil { + return err + } + return nil } diff --git a/pkg/harbor/models/user_group.go b/pkg/harbor/models/user_group.go index 100b9b6..5191431 100644 --- a/pkg/harbor/models/user_group.go +++ b/pkg/harbor/models/user_group.go @@ -20,7 +20,7 @@ type UserGroup struct { // The name of the user group GroupName string `json:"group_name,omitempty" js:"groupName"` - // The group type, 1 for LDAP group, 2 for HTTP group. + // The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group. GroupType int64 `json:"group_type,omitempty" js:"groupType"` // The ID of the user group diff --git a/pkg/harbor/models/user_group_search_item.go b/pkg/harbor/models/user_group_search_item.go new file mode 100644 index 0000000..55c7855 --- /dev/null +++ b/pkg/harbor/models/user_group_search_item.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserGroupSearchItem user group search item +// +// swagger:model UserGroupSearchItem +type UserGroupSearchItem struct { + + // The name of the user group + GroupName string `json:"group_name,omitempty" js:"groupName"` + + // The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group. + GroupType int64 `json:"group_type,omitempty" js:"groupType"` + + // The ID of the user group + ID int64 `json:"id,omitempty" js:"id"` +} + +// Validate validates this user group search item +func (m *UserGroupSearchItem) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this user group search item based on context it is used +func (m *UserGroupSearchItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UserGroupSearchItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserGroupSearchItem) UnmarshalBinary(b []byte) error { + var res UserGroupSearchItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/vulnerability_item.go b/pkg/harbor/models/vulnerability_item.go new file mode 100644 index 0000000..4261b0c --- /dev/null +++ b/pkg/harbor/models/vulnerability_item.go @@ -0,0 +1,83 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VulnerabilityItem the vulnerability item info +// +// swagger:model VulnerabilityItem +type VulnerabilityItem struct { + + // the CVE id of the vulnerability. + CVEID string `json:"cve_id,omitempty" js:"cveid"` + + // the nvd cvss v3 score of the vulnerability + CvssV3Score float32 `json:"cvss_v3_score,omitempty" js:"cvssV3Score"` + + // The description of the vulnerability + Desc string `json:"desc,omitempty" js:"desc"` + + // the digest of the artifact + Digest string `json:"digest,omitempty" js:"digest"` + + // the fixed version of the package + FixedVersion string `json:"fixed_version,omitempty" js:"fixedVersion"` + + // Links of the vulnerability + Links []string `json:"links" js:"links"` + + // the package of the vulnerability + Package string `json:"package,omitempty" js:"package"` + + // the project ID of the artifact + ProjectID int64 `json:"project_id,omitempty" js:"projectID"` + + // the repository name of the artifact + RepositoryName string `json:"repository_name,omitempty" js:"repositoryName"` + + // the severity of the vulnerability + Severity string `json:"severity,omitempty" js:"severity"` + + // the tags of the artifact + Tags []string `json:"tags" js:"tags"` + + // the version of the package + Version string `json:"version,omitempty" js:"version"` +} + +// Validate validates this vulnerability item +func (m *VulnerabilityItem) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this vulnerability item based on context it is used +func (m *VulnerabilityItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VulnerabilityItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VulnerabilityItem) UnmarshalBinary(b []byte) error { + var res VulnerabilityItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/webhook_target_object.go b/pkg/harbor/models/webhook_target_object.go index f240747..7b30412 100644 --- a/pkg/harbor/models/webhook_target_object.go +++ b/pkg/harbor/models/webhook_target_object.go @@ -8,6 +8,7 @@ package models import ( "context" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -23,6 +24,9 @@ type WebhookTargetObject struct { // The webhook auth header. AuthHeader string `json:"auth_header,omitempty" js:"authHeader"` + // The payload format of webhook, by default is Default for http type. + PayloadFormat PayloadFormatType `json:"payload_format,omitempty" js:"payloadFormat"` + // Whether or not to skip cert verify. SkipCertVerify bool `json:"skip_cert_verify,omitempty" js:"skipCertVerify"` @@ -32,11 +36,64 @@ type WebhookTargetObject struct { // Validate validates this webhook target object func (m *WebhookTargetObject) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePayloadFormat(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookTargetObject) validatePayloadFormat(formats strfmt.Registry) error { + if swag.IsZero(m.PayloadFormat) { // not required + return nil + } + + if err := m.PayloadFormat.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("payload_format") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("payload_format") + } + return err + } + return nil } -// ContextValidate validates this webhook target object based on context it is used +// ContextValidate validate this webhook target object based on the context it is used func (m *WebhookTargetObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePayloadFormat(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookTargetObject) contextValidatePayloadFormat(ctx context.Context, formats strfmt.Registry) error { + + if swag.IsZero(m.PayloadFormat) { // not required + return nil + } + + if err := m.PayloadFormat.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("payload_format") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("payload_format") + } + return err + } + return nil } diff --git a/pkg/harbor/models/worker.go b/pkg/harbor/models/worker.go new file mode 100644 index 0000000..60a2d8c --- /dev/null +++ b/pkg/harbor/models/worker.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Worker worker in the pool +// +// swagger:model Worker +type Worker struct { + + // the checkin of the running job in the worker + CheckIn string `json:"check_in,omitempty" js:"checkIn"` + + // The checkin time of the worker + // Format: date-time + CheckinAt *strfmt.DateTime `json:"checkin_at,omitempty" js:"checkinAt"` + + // the id of the worker + ID string `json:"id,omitempty" js:"id"` + + // the id of the running job in the worker + JobID string `json:"job_id,omitempty" js:"jobID"` + + // the name of the running job in the worker + JobName string `json:"job_name,omitempty" js:"jobName"` + + // the id of the worker pool + PoolID string `json:"pool_id,omitempty" js:"poolID"` + + // The start time of the worker + // Format: date-time + StartAt *strfmt.DateTime `json:"start_at,omitempty" js:"startAt"` +} + +// Validate validates this worker +func (m *Worker) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCheckinAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Worker) validateCheckinAt(formats strfmt.Registry) error { + if swag.IsZero(m.CheckinAt) { // not required + return nil + } + + if err := validate.FormatOf("checkin_at", "body", "date-time", m.CheckinAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Worker) validateStartAt(formats strfmt.Registry) error { + if swag.IsZero(m.StartAt) { // not required + return nil + } + + if err := validate.FormatOf("start_at", "body", "date-time", m.StartAt.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this worker based on context it is used +func (m *Worker) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Worker) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Worker) UnmarshalBinary(b []byte) error { + var res Worker + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/models/worker_pool.go b/pkg/harbor/models/worker_pool.go new file mode 100644 index 0000000..b19cf65 --- /dev/null +++ b/pkg/harbor/models/worker_pool.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// WorkerPool the worker pool of job service +// +// swagger:model WorkerPool +type WorkerPool struct { + + // The concurrency of the work pool + Concurrency int64 `json:"concurrency,omitempty" js:"concurrency"` + + // The heartbeat time of the work pool + // Format: date-time + HeartbeatAt strfmt.DateTime `json:"heartbeat_at,omitempty" js:"heartbeatAt"` + + // The host of the work pool + Host string `json:"host,omitempty" js:"host"` + + // the process id of jobservice + Pid int64 `json:"pid,omitempty" js:"pid"` + + // The start time of the work pool + // Format: date-time + StartAt strfmt.DateTime `json:"start_at,omitempty" js:"startAt"` + + // the id of the worker pool + WorkerPoolID string `json:"worker_pool_id,omitempty" js:"workerPoolID"` +} + +// Validate validates this worker pool +func (m *WorkerPool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHeartbeatAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WorkerPool) validateHeartbeatAt(formats strfmt.Registry) error { + if swag.IsZero(m.HeartbeatAt) { // not required + return nil + } + + if err := validate.FormatOf("heartbeat_at", "body", "date-time", m.HeartbeatAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *WorkerPool) validateStartAt(formats strfmt.Registry) error { + if swag.IsZero(m.StartAt) { // not required + return nil + } + + if err := validate.FormatOf("start_at", "body", "date-time", m.StartAt.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this worker pool based on context it is used +func (m *WorkerPool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *WorkerPool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WorkerPool) UnmarshalBinary(b []byte) error { + var res WorkerPool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/harbor/swagger.yaml b/pkg/harbor/swagger.yaml index 773b758..ef59bb4 100644 --- a/pkg/harbor/swagger.yaml +++ b/pkg/harbor/swagger.yaml @@ -5,29 +5,29 @@ info: version: '2.0' host: localhost schemes: - - http - - https +- http +- https basePath: /api/v2.0 produces: - - application/json +- application/json consumes: - - application/json +- application/json securityDefinitions: basic: type: basic security: - - basic: [] - - {} +- basic: [] +- {} paths: /health: get: summary: Check the status of Harbor components - description: Check the status of Harbor components + description: Check the status of Harbor components. This path does not require authentication. tags: - - health + - health operationId: getHealth parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: The health status of Harbor components @@ -37,18 +37,18 @@ paths: $ref: '#/responses/500' /search: get: - summary: 'Search for projects, repositories and helm charts' + summary: 'Search for projects and repositories' description: |- - The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order. + The Search endpoint returns information about the projects and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order. parameters: - - $ref: '#/parameters/requestId' - - name: q - in: query - description: Search parameter for project and repository name. - required: true - type: string + - $ref: '#/parameters/requestId' + - name: q + in: query + description: Search parameter for project and repository name. + required: true + type: string tags: - - search + - search operationId: search responses: '200': @@ -62,10 +62,10 @@ paths: summary: Get the statistic information about the projects and repositories description: Get the statistic information about the projects and repositories tags: - - statistic + - statistic operationId: getStatistic parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: The statistic information @@ -82,14 +82,15 @@ paths: description: | This endpoint ping the available ldap service for test related configuration parameters. parameters: - - name: ldapconf - in: body - description: 'ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.' - required: false - schema: - $ref: '#/definitions/LdapConf' + - $ref: '#/parameters/requestId' + - name: ldapconf + in: body + description: 'ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.' + required: false + schema: + $ref: '#/definitions/LdapConf' tags: - - Ldap + - Ldap responses: '200': description: Ping ldap service successfully. @@ -110,13 +111,14 @@ paths: description: | This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter. parameters: - - name: username - in: query - type: string - required: false - description: Registered user ID + - $ref: '#/parameters/requestId' + - name: username + in: query + type: string + required: false + description: Registered user ID tags: - - Ldap + - Ldap responses: '200': description: Search ldap users successfully. @@ -139,14 +141,15 @@ paths: description: | This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason. parameters: - - name: uid_list - in: body - description: The uid listed for importing. This list will check users validity of ldap service based on configuration from the system. - required: true - schema: - $ref: '#/definitions/LdapImportUsers' + - $ref: '#/parameters/requestId' + - name: uid_list + in: body + description: The uid listed for importing. This list will check users validity of ldap service based on configuration from the system. + required: true + schema: + $ref: '#/definitions/LdapImportUsers' tags: - - Ldap + - Ldap responses: '200': description: Add ldap users successfully. @@ -171,18 +174,19 @@ paths: description: | This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn. parameters: - - name: groupname - in: query - type: string - required: false - description: Ldap group name - - name: groupdn - in: query - type: string - required: false - description: The LDAP group DN + - $ref: '#/parameters/requestId' + - name: groupname + in: query + type: string + required: false + description: Ldap group name + - name: groupdn + in: query + type: string + required: false + description: The LDAP group DN tags: - - Ldap + - Ldap responses: '200': description: Search ldap group successfully. @@ -205,9 +209,9 @@ paths: description: | This endpoint is for retrieving system configurations that only provides for internal api call. tags: - - configure + - configure parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get system configurations successfully. The response body is a map. @@ -226,16 +230,16 @@ paths: description: | This endpoint is for retrieving system configurations that only provides for admin user. tags: - - configure + - configure parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get system configurations successfully. The response body is a map. schema: $ref: '#/definitions/ConfigurationsResponse' '401': - description: User need to log in first.ß + description: User need to log in first. '403': description: User does not have permission of admin role. '500': @@ -246,15 +250,15 @@ paths: description: | This endpoint is for modifying system configurations that only provides for admin user. tags: - - configure + - configure parameters: - - $ref: '#/parameters/requestId' - - name: configurations - in: body - required: true - schema: - $ref: '#/definitions/Configurations' - description: 'The configuration map can contain a subset of the attributes of the schema, which are to be updated.' + - $ref: '#/parameters/requestId' + - name: configurations + in: body + required: true + schema: + $ref: '#/definitions/Configurations' + description: 'The configuration map can contain a subset of the attributes of the schema, which are to be updated.' responses: '200': description: Modify system configurations successfully. @@ -269,36 +273,35 @@ paths: summary: List projects description: This endpoint returns projects created by Harbor. tags: - - project + - project operationId: listProjects parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/sort' - - name: name - in: query - description: The name of project. - required: false - type: string - - name: public - in: query - description: The project is public or private. - required: false - type: boolean - format: int32 - - name: owner - in: query - description: The name of project owner. - required: false - type: string - - name: with_detail - in: query - description: Bool value indicating whether return detailed information of the project - type: boolean - required: false - default: true + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/sort' + - name: name + in: query + description: The name of project. + required: false + type: string + - name: public + in: query + description: The project is public or private. + required: false + type: boolean + - name: owner + in: query + description: The name of project owner. + required: false + type: string + - name: with_detail + in: query + description: Bool value indicating whether return detailed information of the project + type: boolean + required: false + default: true responses: '200': description: Return all matched projects. @@ -321,15 +324,15 @@ paths: summary: Check if the project name user provided already exists. description: This endpoint is used to check if the project name provided already exist. tags: - - project + - project operationId: headProject parameters: - - $ref: '#/parameters/requestId' - - name: project_name - in: query - description: Project name for checking exists. - required: true - type: string + - $ref: '#/parameters/requestId' + - name: project_name + in: query + description: Project name for checking exists. + required: true + type: string responses: '200': $ref: '#/responses/200' @@ -341,17 +344,17 @@ paths: summary: Create a new project. description: This endpoint is for user to create a new project. tags: - - project + - project operationId: createProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/resourceNameInLocation' - - name: project - in: body - description: New created project. - required: true - schema: - $ref: '#/definitions/ProjectReq' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/resourceNameInLocation' + - name: project + in: body + description: New created project. + required: true + schema: + $ref: '#/definitions/ProjectReq' responses: '201': $ref: '#/responses/201' @@ -368,12 +371,12 @@ paths: summary: Return specific project detail information description: This endpoint returns specific project information by project ID. tags: - - project + - project operationId: getProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': description: Return matched project information. @@ -387,18 +390,18 @@ paths: summary: Update properties for a selected project. description: This endpoint is aimed to update the properties of a project. tags: - - project + - project operationId: updateProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: project - in: body - required: true - schema: - $ref: '#/definitions/ProjectReq' - description: Updates of project. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: project + in: body + required: true + schema: + $ref: '#/definitions/ProjectReq' + description: Updates of project. responses: '200': $ref: '#/responses/200' @@ -416,12 +419,12 @@ paths: summary: Delete project by projectID description: This endpoint is aimed to delete project by project ID. tags: - - project + - project operationId: deleteProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': $ref: '#/responses/200' @@ -440,12 +443,12 @@ paths: summary: Get the deletable status of the project description: Get the deletable status of the project tags: - - project + - project operationId: getProjectDeletable parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': description: Return deletable status of the project. @@ -464,12 +467,12 @@ paths: summary: Get summary of the project. description: Get summary of the project. tags: - - project + - project operationId: getProjectSummary parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': description: Get summary of the project successfully. @@ -491,17 +494,17 @@ paths: description: Get all project member information operationId: listProjectMembers parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: entityname - in: query - type: string - description: The entity name to search. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: entityname + in: query + type: string + description: The entity name to search. tags: - - member + - member responses: '200': description: Get project members successfully. @@ -532,15 +535,15 @@ paths: operationId: createProjectMember description: 'Create project member relationship, the member can be one of the user_member and group_member, The user_member need to specify user_id or username. If the user already exist in harbor DB, specify the user_id, If does not exist in harbor DB, it will SearchAndOnBoard the user. The group_member need to specify id or ldap_group_dn. If the group already exist in harbor DB. specify the user group''s id, If does not exist, it will SearchAndOnBoard the group. ' tags: - - member + - member parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: project_member - in: body - schema: - $ref: '#/definitions/ProjectMember' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: project_member + in: body + schema: + $ref: '#/definitions/ProjectMember' responses: '201': description: Project member created successfully. @@ -564,17 +567,17 @@ paths: description: Get the project member information operationId: getProjectMember tags: - - member + - member parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: mid - in: path - type: integer - format: int64 - required: true - description: The member ID + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: mid + in: path + type: integer + format: int64 + required: true + description: The member ID responses: '200': description: Project member retrieved successfully. @@ -595,21 +598,21 @@ paths: description: Update project member relationship operationId: updateProjectMember tags: - - member + - member parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: mid - in: path - type: integer - format: int64 - required: true - description: Member ID. - - name: role - in: body - schema: - $ref: '#/definitions/RoleRequest' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: mid + in: path + type: integer + format: int64 + required: true + description: Member ID. + - name: role + in: body + schema: + $ref: '#/definitions/RoleRequest' responses: '200': $ref: '#/responses/200' @@ -627,17 +630,17 @@ paths: summary: Delete project member operationId: deleteProjectMember tags: - - member + - member parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: mid - in: path - type: integer - format: int64 - required: true - description: Member ID. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: mid + in: path + type: integer + format: int64 + required: true + description: Member ID. responses: '200': $ref: '#/responses/200' @@ -655,11 +658,11 @@ paths: description: Get the metadata of the specific project operationId: listProjectMetadatas parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' tags: - - projectMetadata + - projectMetadata responses: '200': description: Success @@ -682,17 +685,17 @@ paths: operationId: addProjectMetadatas description: Add metadata for the specific project tags: - - projectMetadata + - projectMetadata parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: metadata - in: body - schema: - type: object - additionalProperties: - type: string + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: metadata + in: body + schema: + type: object + additionalProperties: + type: string responses: '200': $ref: '#/responses/200' @@ -714,16 +717,16 @@ paths: description: Get the specific metadata of the specific project operationId: getProjectMetadata parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: meta_name - in: path - description: The name of metadata. - required: true - type: string + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: meta_name + in: path + description: The name of metadata. + required: true + type: string tags: - - projectMetadata + - projectMetadata responses: '200': description: Success @@ -746,22 +749,22 @@ paths: description: Update the specific metadata for the specific project operationId: updateProjectMetadata tags: - - projectMetadata + - projectMetadata parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: meta_name - in: path - description: The name of metadata. - required: true - type: string - - name: metadata - in: body - schema: - type: object - additionalProperties: - type: string + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: meta_name + in: path + description: The name of metadata. + required: true + type: string + - name: metadata + in: body + schema: + type: object + additionalProperties: + type: string responses: '200': $ref: '#/responses/200' @@ -782,16 +785,16 @@ paths: description: Delete the specific metadata for the specific project operationId: deleteProjectMetadata tags: - - projectMetadata + - projectMetadata parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: meta_name - in: path - description: The name of metadata. - required: true - type: string + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: meta_name + in: path + description: The name of metadata. + required: true + type: string responses: '200': $ref: '#/responses/200' @@ -812,14 +815,14 @@ paths: summary: List all authorized repositories description: List all authorized repositories tags: - - repository + - repository operationId: listAllRepositories parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -843,15 +846,15 @@ paths: summary: List repositories description: List repositories of the specified project tags: - - repository + - repository operationId: listRepositories parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -881,12 +884,12 @@ paths: summary: Get repository description: Get the repository specified by name tags: - - repository + - repository operationId: getRepository parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' responses: '200': description: Success @@ -906,18 +909,18 @@ paths: summary: Update repository description: Update the repository specified by name tags: - - repository + - repository operationId: updateRepository parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - name: repository - in: body - description: The JSON object of repository. - required: true - schema: - $ref: '#/definitions/Repository' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - name: repository + in: body + description: The JSON object of repository. + required: true + schema: + $ref: '#/definitions/Repository' responses: '200': $ref: '#/responses/200' @@ -935,12 +938,12 @@ paths: summary: Delete repository description: Delete the repository specified by name tags: - - repository + - repository operationId: deleteRepository parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' responses: '200': $ref: '#/responses/200' @@ -959,47 +962,59 @@ paths: summary: List artifacts description: List artifacts under the specific project and repository. Except the basic properties, the other supported queries in "q" includes "tags=*" to list only tagged artifacts, "tags=nil" to list only untagged artifacts, "tags=~v" to list artifacts whose tag fuzzy matches "v", "tags=v" to list artifact whose tag exactly matches "v", "labels=(id1, id2)" to list artifacts that both labels with id1 and id2 are added to tags: - - artifact + - artifact operationId: listArtifacts parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/acceptVulnerabilities' - - name: with_tag - in: query - description: Specify whether the tags are included inside the returning artifacts - type: boolean - required: false - default: true - - name: with_label - in: query - description: Specify whether the labels are included inside the returning artifacts - type: boolean - required: false - default: false - - name: with_scan_overview - in: query - description: Specify whether the scan overview is included inside the returning artifacts - type: boolean - required: false - default: false - - name: with_signature - in: query - description: Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" - type: boolean - required: false - default: false - - name: with_immutable_status - in: query - description: Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" - type: boolean - required: false - default: false + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/acceptVulnerabilities' + - name: with_tag + in: query + description: Specify whether the tags are included inside the returning artifacts + type: boolean + required: false + default: true + - name: with_label + in: query + description: Specify whether the labels are included inside the returning artifacts + type: boolean + required: false + default: false + - name: with_scan_overview + in: query + description: Specify whether the scan overview is included inside the returning artifacts + type: boolean + required: false + default: false + - name: with_sbom_overview + in: query + description: Specify whether the SBOM overview is included in returning artifacts, when this option is true, the SBOM overview will be included in the response + type: boolean + required: false + default: false + - name: with_signature + in: query + description: Specify whether the signature is included inside the tags of the returning artifacts. Only works when setting "with_tag=true" + type: boolean + required: false + default: false + - name: with_immutable_status + in: query + description: Specify whether the immutable status is included inside the tags of the returning artifacts. Only works when setting "with_immutable_status=true" + type: boolean + required: false + default: false + - name: with_accessory + in: query + description: Specify whether the accessories are included of the returning artifacts. Only works when setting "with_accessory=true" + type: boolean + required: false + default: false responses: '200': description: Success @@ -1028,17 +1043,17 @@ paths: summary: Copy artifact description: Copy the artifact specified in the "from" parameter to the repository. tags: - - artifact + - artifact operationId: CopyArtifact parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - name: from - in: query - description: The artifact from which the new artifact is copied from, the format should be "project/repository:tag" or "project/repository@digest". - type: string - required: true + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - name: from + in: query + description: The artifact from which the new artifact is copied from, the format should be "project/repository:tag" or "project/repository@digest". + type: string + required: true responses: '201': $ref: '#/responses/201' @@ -1059,47 +1074,59 @@ paths: summary: Get the specific artifact description: Get the artifact specified by the reference under the project and repository. The reference can be digest or tag. tags: - - artifact + - artifact operationId: getArtifact parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/acceptVulnerabilities' - - name: with_tag - in: query - description: Specify whether the tags are inclued inside the returning artifacts - type: boolean - required: false - default: true - - name: with_label - in: query - description: Specify whether the labels are inclued inside the returning artifacts - type: boolean - required: false - default: false - - name: with_scan_overview - in: query - description: Specify whether the scan overview is inclued inside the returning artifacts - type: boolean - required: false - default: false - # should be in tag level - - name: with_signature - in: query - description: Specify whether the signature is inclued inside the returning artifacts - type: boolean - required: false - default: false - - name: with_immutable_status - in: query - description: Specify whether the immutable status is inclued inside the tags of the returning artifacts. Only works when setting "with_tag=true" - type: boolean - required: false - default: false + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/acceptVulnerabilities' + - name: with_tag + in: query + description: Specify whether the tags are inclued inside the returning artifacts + type: boolean + required: false + default: true + - name: with_label + in: query + description: Specify whether the labels are inclued inside the returning artifacts + type: boolean + required: false + default: false + - name: with_scan_overview + in: query + description: Specify whether the scan overview is inclued inside the returning artifacts + type: boolean + required: false + default: false + - name: with_sbom_overview + in: query + description: Specify whether the SBOM overview is included in returning artifact, when this option is true, the SBOM overview will be included in the response + type: boolean + required: false + default: false + - name: with_accessory + in: query + description: Specify whether the accessories are included of the returning artifacts. + type: boolean + required: false + default: false + # should be in tag level + - name: with_signature + in: query + description: Specify whether the signature is inclued inside the returning artifacts + type: boolean + required: false + default: false + - name: with_immutable_status + in: query + description: Specify whether the immutable status is inclued inside the tags of the returning artifacts. + type: boolean + required: false + default: false responses: '200': description: Success @@ -1119,13 +1146,13 @@ paths: summary: Delete the specific artifact description: Delete the artifact specified by the reference under the project and repository. The reference can be digest or tag tags: - - artifact + - artifact operationId: deleteArtifact parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' responses: '200': $ref: '#/responses/200' @@ -1142,13 +1169,51 @@ paths: summary: Scan the artifact description: Scan the specified artifact tags: - - scan + - scan operationId: scanArtifact parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: scanType + in: body + required: false + schema: + $ref: '#/definitions/ScanType' + responses: + '202': + $ref: '#/responses/202' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '422': + $ref: '#/responses/422' + '500': + $ref: '#/responses/500' + /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stop: + post: + summary: Cancelling a scan job for a particular artifact + description: Cancelling a scan job for a particular artifact + tags: + - scan + operationId: stopScanArtifact + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: scanType + in: body + required: true + schema: + $ref: '#/definitions/ScanType' + description: 'The scan type: Vulnerabilities, SBOM' responses: '202': $ref: '#/responses/202' @@ -1160,6 +1225,8 @@ paths: $ref: '#/responses/403' '404': $ref: '#/responses/404' + '422': + $ref: '#/responses/422' '500': $ref: '#/responses/500' /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log: @@ -1167,25 +1234,27 @@ paths: summary: Get the log of the scan report description: Get the log of the scan report tags: - - scan + - scan operationId: getReportLog produces: - - text/plain + - text/plain parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - name: report_id - type: string - in: path - required: true - description: The report id to get the log + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: report_id + type: string + in: path + required: true + description: The report id to get the log responses: '200': description: Successfully get scan log file schema: type: string + '400': + $ref: '#/responses/400' '401': $ref: '#/responses/401' '403': @@ -1199,19 +1268,19 @@ paths: summary: Create tag description: Create a tag for the specified artifact tags: - - artifact + - artifact operationId: createTag parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - name: tag - in: body - description: The JSON object of tag. - required: true - schema: - $ref: '#/definitions/Tag' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: tag + in: body + description: The JSON object of tag. + required: true + schema: + $ref: '#/definitions/Tag' responses: '201': $ref: '#/responses/201' @@ -1233,29 +1302,29 @@ paths: summary: List tags description: List tags of the specific artifact tags: - - artifact + - artifact operationId: listTags parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: with_signature - in: query - description: Specify whether the signature is included inside the returning tags - type: boolean - required: false - default: false - - name: with_immutable_status - in: query - description: Specify whether the immutable status is included inside the returning tags - type: boolean - required: false - default: false + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: with_signature + in: query + description: Specify whether the signature is included inside the returning tags + type: boolean + required: false + default: false + - name: with_immutable_status + in: query + description: Specify whether the immutable status is included inside the returning tags + type: boolean + required: false + default: false responses: '200': description: Success @@ -1285,14 +1354,14 @@ paths: summary: Delete tag description: Delete the tag of the specified artifact tags: - - artifact + - artifact operationId: deleteTag parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - $ref: '#/parameters/tagName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - $ref: '#/parameters/tagName' responses: '200': $ref: '#/responses/200' @@ -1304,19 +1373,59 @@ paths: $ref: '#/responses/404' '500': $ref: '#/responses/500' + /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/accessories: + get: + summary: List accessories + description: List accessories of the specific artifact + tags: + - artifact + operationId: listAccessories + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + responses: + '200': + description: Success + headers: + X-Total-Count: + description: The total count of accessories + type: integer + Link: + description: Link refers to the previous page and next page + type: string + schema: + type: array + items: + $ref: '#/definitions/Accessory' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities: get: summary: Get the vulnerabilities addition of the specific artifact description: Get the vulnerabilities addition of the artifact specified by the reference under the project and repository. tags: - - artifact + - artifact operationId: getVulnerabilitiesAddition parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - $ref: '#/parameters/acceptVulnerabilities' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - $ref: '#/parameters/acceptVulnerabilities' responses: '200': description: Success @@ -1341,19 +1450,19 @@ paths: summary: Get the addition of the specific artifact description: Get the addition of the artifact specified by the reference under the project and repository. tags: - - artifact + - artifact operationId: getAddition parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - name: addition - in: path - description: The type of addition. - type: string - enum: [build_history, values.yaml, readme.md, dependencies] - required: true + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: addition + in: path + description: The type of addition. + type: string + enum: [build_history, values.yaml, readme.md, dependencies, sbom] + required: true responses: '200': description: Success @@ -1371,6 +1480,8 @@ paths: $ref: '#/responses/403' '404': $ref: '#/responses/404' + '422': + $ref: '#/responses/422' '500': $ref: '#/responses/500' /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/labels: @@ -1378,19 +1489,19 @@ paths: summary: Add label to artifact description: Add label to the specified artiact. tags: - - artifact + - artifact operationId: addLabel parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - name: label - in: body - description: The label that added to the artifact. Only the ID property is needed. - required: true - schema: - $ref: '#/definitions/Label' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: label + in: body + description: The label that added to the artifact. Only the ID property is needed. + required: true + schema: + $ref: '#/definitions/Label' responses: '200': $ref: '#/responses/200' @@ -1411,19 +1522,19 @@ paths: summary: Remove label from artifact description: Remove the label from the specified artiact. tags: - - artifact + - artifact operationId: removeLabel parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/repositoryName' - - $ref: '#/parameters/reference' - - name: label_id - in: path - description: The ID of the label that removed from the artifact. - type: integer - format: int64 - required: true + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/repositoryName' + - $ref: '#/parameters/reference' + - name: label_id + in: path + description: The ID of the label that removed from the artifact. + type: integer + format: int64 + required: true responses: '200': $ref: '#/responses/200' @@ -1442,12 +1553,12 @@ paths: summary: Get project level scanner description: Get the scanner registration of the specified project. If no scanner registration is configured for the specified project, the system default scanner registration will be returned. tags: - - project + - project operationId: getScannerOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': description: The details of the scanner registration. @@ -1467,17 +1578,17 @@ paths: summary: Configure scanner for the specified project description: Set one of the system configured scanner registration as the indepndent scanner of the specified project. tags: - - project + - project operationId: setScannerOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: payload - in: body - required: true - schema: - $ref: '#/definitions/ProjectScanner' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: payload + in: body + required: true + schema: + $ref: '#/definitions/ProjectScanner' responses: '200': $ref: '#/responses/200' @@ -1496,16 +1607,16 @@ paths: summary: Get scanner registration candidates for configurating project level scanner description: Retrieve the system configured scanner registrations as candidates of setting project level scanner. tags: - - project + - project operationId: listScannerCandidatesOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: A list of scanner registrations. @@ -1534,14 +1645,14 @@ paths: description: | This endpoint let user see the recent operation logs of the projects which he is member of tags: - - auditlog + - auditlog operationId: listAuditLogs parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -1567,15 +1678,15 @@ paths: summary: Get recent logs of the projects description: Get recent logs of the projects tags: - - project + - project operationId: getLogs parameters: - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -1601,10 +1712,10 @@ paths: summary: List P2P providers description: List P2P providers tags: - - preheat + - preheat operationId: ListProviders parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Success @@ -1629,15 +1740,15 @@ paths: This endpoint checks status of a instance, the instance can be given by ID or Endpoint URL (together with credential) operationId: PingInstances parameters: - - $ref: '#/parameters/requestId' - - name: instance - in: body - description: The JSON object of instance. - required: true - schema: - $ref: '#/definitions/Instance' + - $ref: '#/parameters/requestId' + - name: instance + in: body + description: The JSON object of instance. + required: true + schema: + $ref: '#/definitions/Instance' tags: - - preheat + - preheat responses: '200': $ref: '#/responses/200' @@ -1654,14 +1765,14 @@ paths: summary: List P2P provider instances description: List P2P provider instances tags: - - preheat + - preheat operationId: ListInstances parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': description: Success @@ -1690,16 +1801,16 @@ paths: summary: Create p2p provider instances description: Create p2p provider instances tags: - - preheat + - preheat operationId: CreateInstance parameters: - - $ref: '#/parameters/requestId' - - name: instance - in: body - description: The JSON object of instance. - required: true - schema: - $ref: '#/definitions/Instance' + - $ref: '#/parameters/requestId' + - name: instance + in: body + description: The JSON object of instance. + required: true + schema: + $ref: '#/definitions/Instance' responses: '201': $ref: '#/responses/201' @@ -1720,11 +1831,11 @@ paths: summary: Get a P2P provider instance description: Get a P2P provider instance tags: - - preheat + - preheat operationId: GetInstance parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/instanceName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/instanceName' responses: '200': description: Success @@ -1744,11 +1855,11 @@ paths: summary: Delete the specified P2P provider instance description: Delete the specified P2P provider instance tags: - - preheat + - preheat operationId: DeleteInstance parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/instanceName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/instanceName' responses: '200': $ref: '#/responses/200' @@ -1764,17 +1875,17 @@ paths: summary: Update the specified P2P provider instance description: Update the specified P2P provider instance tags: - - preheat + - preheat operationId: UpdateInstance parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/instanceName' - - name: instance - in: body - description: The instance to update - required: true - schema: - $ref: '#/definitions/Instance' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/instanceName' + - name: instance + in: body + description: The instance to update + required: true + schema: + $ref: '#/definitions/Instance' responses: '200': $ref: '#/responses/200' @@ -1793,17 +1904,17 @@ paths: summary: Create a preheat policy under a project description: Create a preheat policy under a project tags: - - preheat + - preheat operationId: CreatePolicy parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - name: policy - in: body - description: The policy schema info - required: true - schema: - $ref: '#/definitions/PreheatPolicy' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - name: policy + in: body + description: The policy schema info + required: true + schema: + $ref: '#/definitions/PreheatPolicy' responses: '201': $ref: '#/responses/201' @@ -1821,15 +1932,15 @@ paths: summary: List preheat policies description: List preheat policies tags: - - preheat + - preheat operationId: ListPolicies parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': description: List preheat policies success @@ -1857,12 +1968,12 @@ paths: summary: Get a preheat policy description: Get a preheat policy tags: - - preheat + - preheat operationId: GetPolicy parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' responses: '200': description: Get a preheat policy success @@ -1882,18 +1993,18 @@ paths: summary: Update preheat policy description: Update preheat policy tags: - - preheat + - preheat operationId: UpdatePolicy parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - name: policy - in: body - description: The policy schema info - required: true - schema: - $ref: '#/definitions/PreheatPolicy' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - name: policy + in: body + description: The policy schema info + required: true + schema: + $ref: '#/definitions/PreheatPolicy' responses: '200': $ref: '#/responses/200' @@ -1913,18 +2024,18 @@ paths: summary: Manual preheat description: Manual preheat tags: - - preheat + - preheat operationId: ManualPreheat parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - name: policy - in: body - description: The policy schema info - required: true - schema: - $ref: '#/definitions/PreheatPolicy' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - name: policy + in: body + description: The policy schema info + required: true + schema: + $ref: '#/definitions/PreheatPolicy' responses: '201': $ref: '#/responses/201' @@ -1942,12 +2053,12 @@ paths: summary: Delete a preheat policy description: Delete a preheat policy tags: - - preheat + - preheat operationId: DeletePolicy parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' responses: '200': $ref: '#/responses/200' @@ -1966,16 +2077,16 @@ paths: summary: List executions for the given policy description: List executions for the given policy tags: - - preheat + - preheat operationId: ListExecutions parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': description: List executions success @@ -2005,13 +2116,13 @@ paths: summary: Get a execution detail by id description: Get a execution detail by id tags: - - preheat + - preheat operationId: GetExecution parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - $ref: '#/parameters/executionId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/executionId' responses: '200': description: Get execution success @@ -2031,19 +2142,19 @@ paths: summary: Stop a execution description: Stop a execution tags: - - preheat + - preheat operationId: StopExecution parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - $ref: '#/parameters/executionId' - - name: execution - description: The data of execution - in: body - required: true - schema: - $ref: '#/definitions/Execution' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/executionId' + - name: execution + description: The data of execution + in: body + required: true + schema: + $ref: '#/definitions/Execution' responses: '200': $ref: '#/responses/200' @@ -2062,17 +2173,17 @@ paths: summary: List all the related tasks for the given execution description: List all the related tasks for the given execution tags: - - preheat + - preheat operationId: ListTasks parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - $ref: '#/parameters/executionId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/executionId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': description: List tasks success @@ -2102,16 +2213,16 @@ paths: summary: Get the log text stream of the specified task for the given execution description: Get the log text stream of the specified task for the given execution tags: - - preheat + - preheat operationId: GetPreheatLog produces: - - text/plain + - text/plain parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' - - $ref: '#/parameters/preheatPolicyName' - - $ref: '#/parameters/executionId' - - $ref: '#/parameters/taskId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' + - $ref: '#/parameters/preheatPolicyName' + - $ref: '#/parameters/executionId' + - $ref: '#/parameters/taskId' responses: '200': description: Get log success @@ -2136,11 +2247,11 @@ paths: summary: Get all providers at project level description: Get all providers at project level tags: - - preheat + - preheat operationId: ListProvidersUnderProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/projectName' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/projectName' responses: '200': description: Success @@ -2163,15 +2274,15 @@ paths: summary: Get all robot accounts of specified project description: Get all robot accounts of specified project parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' tags: - - robotv1 + - robotv1 operationId: ListRobotV1 responses: '200': @@ -2197,18 +2308,18 @@ paths: summary: Create a robot account description: Create a robot account tags: - - robotv1 + - robotv1 operationId: CreateRobotV1 parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: robot - in: body - description: The JSON object of a robot account. - required: true - schema: - $ref: '#/definitions/RobotCreateV1' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: robot + in: body + description: The JSON object of a robot account. + required: true + schema: + $ref: '#/definitions/RobotCreateV1' responses: '201': description: Created @@ -2236,13 +2347,13 @@ paths: summary: Get a robot account description: This endpoint returns specific robot account information by robot ID. tags: - - robotv1 + - robotv1 operationId: GetRobotByIDV1 parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/robotId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/robotId' responses: '200': description: Return matched robot information. @@ -2260,19 +2371,19 @@ paths: summary: Update status of robot account. description: Used to disable/enable a specified robot account. tags: - - robotv1 + - robotv1 operationId: UpdateRobotV1 parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/robotId' - - name: robot - in: body - description: The JSON object of a robot account. - required: true - schema: - $ref: '#/definitions/Robot' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/robotId' + - name: robot + in: body + description: The JSON object of a robot account. + required: true + schema: + $ref: '#/definitions/Robot' responses: '200': $ref: '#/responses/200' @@ -2292,13 +2403,13 @@ paths: summary: Delete a robot account description: This endpoint deletes specific robot account information by robot ID. tags: - - robotv1 + - robotv1 operationId: DeleteRobotV1 parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/robotId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/robotId' responses: '200': $ref: '#/responses/200' @@ -2318,16 +2429,16 @@ paths: description: | This endpoint returns the immutable tag rules of a project tags: - - immutable + - immutable operationId: ListImmuRules parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': description: Success @@ -2355,17 +2466,17 @@ paths: description: | This endpoint add an immutable tag rule to the project tags: - - immutable + - immutable operationId: CreateImmuRule parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: ImmutableRule - in: body - required: true - schema: - $ref: '#/definitions/ImmutableRule' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: ImmutableRule + in: body + required: true + schema: + $ref: '#/definitions/ImmutableRule' responses: '201': $ref: '#/responses/201' @@ -2383,18 +2494,18 @@ paths: put: summary: Update the immutable tag rule or enable or disable the rule tags: - - immutable + - immutable operationId: UpdateImmuRule parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/immutableRuleId' - - name: ImmutableRule - in: body - required: true - schema: - $ref: '#/definitions/ImmutableRule' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/immutableRuleId' + - name: ImmutableRule + in: body + required: true + schema: + $ref: '#/definitions/ImmutableRule' responses: '200': $ref: '#/responses/200' @@ -2409,13 +2520,13 @@ paths: delete: summary: Delete the immutable tag rule. tags: - - immutable + - immutable operationId: DeleteImmuRule parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/immutableRuleId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/immutableRuleId' responses: '200': $ref: '#/responses/200' @@ -2433,16 +2544,16 @@ paths: description: | This endpoint returns webhook policies of a project. tags: - - webhook + - webhook operationId: ListWebhookPoliciesOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/query' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/query' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -2470,18 +2581,18 @@ paths: description: | This endpoint create a webhook policy if the project does not have one. tags: - - webhook + - webhook operationId: CreateWebhookPolicyOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - name: policy - in: body - description: Properties "targets" and "event_types" needed. - required: true - schema: - $ref: '#/definitions/WebhookPolicy' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - name: policy + in: body + description: Properties "targets" and "event_types" needed. + required: true + schema: + $ref: '#/definitions/WebhookPolicy' responses: '201': description: Project webhook policy create successfully. @@ -2506,13 +2617,13 @@ paths: description: | This endpoint returns specified webhook policy of a project. tags: - - webhook + - webhook operationId: GetWebhookPolicyOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/webhookPolicyId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' responses: '200': description: Get webhook policy successfully. @@ -2533,19 +2644,19 @@ paths: description: | This endpoint is aimed to update the webhook policy of a project. tags: - - webhook + - webhook operationId: UpdateWebhookPolicyOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/webhookPolicyId' - - name: policy - in: body - description: All properties needed except "id", "project_id", "creation_time", "update_time". - required: true - schema: - $ref: '#/definitions/WebhookPolicy' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' + - name: policy + in: body + description: All properties needed except "id", "project_id", "creation_time", "update_time". + required: true + schema: + $ref: '#/definitions/WebhookPolicy' responses: '200': $ref: '#/responses/200' @@ -2564,13 +2675,13 @@ paths: description: | This endpoint is aimed to delete webhookpolicy of a project. tags: - - webhook + - webhook operationId: DeleteWebhookPolicyOfProject parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/webhookPolicyId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' responses: '200': $ref: '#/responses/200' @@ -2584,143 +2695,283 @@ paths: $ref: '#/responses/404' '500': $ref: '#/responses/500' - '/projects/{project_name_or_id}/webhook/lasttrigger': + '/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions': get: - summary: Get project webhook policy last trigger info + summary: List executions for a specific webhook policy description: | - This endpoint returns last trigger information of project webhook policy. + This endpoint returns the executions of a specific webhook policy. tags: - - webhook - operationId: LastTrigger + - webhook + operationId: ListExecutionsOfWebhookPolicy parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': - description: Test webhook connection successfully. + description: List webhook executions success + headers: + X-Total-Count: + description: The total count of executions + type: integer + Link: + description: Link refers to the previous page and next page + type: string schema: type: array items: - $ref: '#/definitions/WebhookLastTrigger' + $ref: '#/definitions/Execution' '400': $ref: '#/responses/400' '401': $ref: '#/responses/401' + '404': + $ref: '#/responses/404' '403': $ref: '#/responses/403' '500': $ref: '#/responses/500' - '/projects/{project_name_or_id}/webhook/jobs': + '/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks': get: - summary: List project webhook jobs + summary: List tasks for a specific webhook execution description: | - This endpoint returns webhook jobs of a project. + This endpoint returns the tasks of a specific webhook execution. tags: - - webhookjob - operationId: ListWebhookJobs + - webhook + operationId: ListTasksOfWebhookExecution parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: policy_id - in: query - type: integer - format: int64 - required: true - description: The policy ID. - - name: status - in: query - description: The status of webhook job. - required: false - type: array - items: - type: string + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' + - $ref: '#/parameters/executionId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' responses: '200': - description: List project webhook jobs successfully. + description: List tasks of webhook executions success headers: X-Total-Count: - description: The total count of available items + description: The total count of tasks type: integer Link: - description: Link to previous page and next page + description: Link refers to the previous page and next page type: string schema: type: array items: - $ref: '#/definitions/WebhookJob' + $ref: '#/definitions/Task' '400': $ref: '#/responses/400' '401': $ref: '#/responses/401' + '404': + $ref: '#/responses/404' '403': $ref: '#/responses/403' '500': $ref: '#/responses/500' - '/projects/{project_name_or_id}/webhook/events': + '/projects/{project_name_or_id}/webhook/policies/{webhook_policy_id}/executions/{execution_id}/tasks/{task_id}/log': get: - summary: Get supported event types and notify types. - description: Get supportted event types and notify types. + summary: Get logs for a specific webhook task + description: | + This endpoint returns the logs of a specific webhook task. tags: - - webhook - operationId: GetSupportedEventTypes + - webhook + operationId: GetLogsOfWebhookTask + produces: + - text/plain parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/isResourceName' - - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/webhookPolicyId' + - $ref: '#/parameters/executionId' + - $ref: '#/parameters/taskId' responses: '200': - description: Success + description: Get log success + headers: + Content-Type: + description: Content type of response + type: string schema: - $ref: '#/definitions/SupportedWebhookEventTypes' + type: string + '400': + $ref: '#/responses/400' '401': $ref: '#/responses/401' + '404': + $ref: '#/responses/404' '403': $ref: '#/responses/403' '500': $ref: '#/responses/500' - /usergroups: + '/projects/{project_name_or_id}/webhook/lasttrigger': get: - summary: Get all user groups information - description: Get all user groups information - operationId: listUserGroups + deprecated: true + summary: Get project webhook policy last trigger info + description: | + This endpoint returns last trigger information of project webhook policy. tags: - - usergroup + - webhook + operationId: LastTrigger parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' responses: '200': - description: Get user group successfully. + description: Test webhook connection successfully. schema: type: array items: - $ref: '#/definitions/UserGroup' + $ref: '#/definitions/WebhookLastTrigger' + '400': + $ref: '#/responses/400' '401': $ref: '#/responses/401' '403': $ref: '#/responses/403' '500': $ref: '#/responses/500' - post: - summary: Create user group - description: Create user group information - operationId: createUserGroup + '/projects/{project_name_or_id}/webhook/jobs': + get: + deprecated: true + summary: List project webhook jobs + description: | + This endpoint returns webhook jobs of a project. tags: - - usergroup + - webhookjob + operationId: ListWebhookJobs parameters: - - $ref: '#/parameters/requestId' - - name: usergroup - in: body - schema: - $ref: '#/definitions/UserGroup' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: policy_id + in: query + type: integer + format: int64 + required: true + description: The policy ID. + - name: status + in: query + description: The status of webhook job. + required: false + type: array + items: + type: string responses: - '201': - description: User group created successfully. + '200': + description: List project webhook jobs successfully. + headers: + X-Total-Count: + description: The total count of available items + type: integer + Link: + description: Link to previous page and next page + type: string + schema: + type: array + items: + $ref: '#/definitions/WebhookJob' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + '/projects/{project_name_or_id}/webhook/events': + get: + summary: Get supported event types and notify types. + description: Get supported event types and notify types. + tags: + - webhook + operationId: GetSupportedEventTypes + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/isResourceName' + - $ref: '#/parameters/projectNameOrId' + responses: + '200': + description: Success + schema: + $ref: '#/definitions/SupportedWebhookEventTypes' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + /usergroups: + get: + summary: Get all user groups information + description: Get all user groups information, it is open for system admin + operationId: listUserGroups + tags: + - usergroup + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: ldap_group_dn + in: query + type: string + required: false + description: search with ldap group DN + - name: group_name + in: query + type: string + required: false + description: group name need to search, fuzzy matches + responses: + '200': + description: Get user group successfully. + schema: + type: array + items: + $ref: '#/definitions/UserGroup' + headers: + X-Total-Count: + description: The total count of available items + type: integer + Link: + description: Link to previous page and next page + type: string + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + post: + summary: Create user group + description: Create user group information + operationId: createUserGroup + tags: + - usergroup + parameters: + - $ref: '#/parameters/requestId' + - name: usergroup + in: body + schema: + $ref: '#/definitions/UserGroup' + responses: + '201': + description: User group created successfully. headers: Location: type: string @@ -2735,21 +2986,56 @@ paths: $ref: '#/responses/409' '500': $ref: '#/responses/500' + /usergroups/search: + get: + summary: Search groups by groupname + description: | + This endpoint is to search groups by group name. It's open for all authenticated requests. + tags: + - usergroup + operationId: searchUserGroups + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: groupname + in: query + type: string + required: true + description: Group name for filtering results. + responses: + '200': + description: Search groups successfully. + schema: + type: array + items: + $ref: '#/definitions/UserGroupSearchItem' + headers: + X-Total-Count: + description: The total count of available items + type: integer + Link: + description: Link to previous page and next page + type: string + '401': + $ref: '#/responses/401' + '500': + $ref: '#/responses/500' '/usergroups/{group_id}': get: summary: Get user group information description: Get user group information operationId: getUserGroup tags: - - usergroup + - usergroup parameters: - - $ref: '#/parameters/requestId' - - name: group_id - in: path - type: integer - format: int64 - required: true - description: Group ID + - $ref: '#/parameters/requestId' + - name: group_id + in: path + type: integer + format: int64 + required: true + description: Group ID responses: '200': description: User group get successfully. @@ -2770,20 +3056,20 @@ paths: description: Update user group information operationId: updateUserGroup tags: - - usergroup + - usergroup parameters: - - $ref: '#/parameters/requestId' - - name: group_id - in: path - type: integer - format: int64 - required: true - description: Group ID - - name: usergroup - in: body - required: false - schema: - $ref: '#/definitions/UserGroup' + - $ref: '#/parameters/requestId' + - name: group_id + in: path + type: integer + format: int64 + required: true + description: Group ID + - name: usergroup + in: body + required: false + schema: + $ref: '#/definitions/UserGroup' responses: '200': $ref: '#/responses/200' @@ -2802,13 +3088,13 @@ paths: description: Delete user group operationId: deleteUserGroup tags: - - usergroup + - usergroup parameters: - - $ref: '#/parameters/requestId' - - name: group_id - type: integer - in: path - required: true + - $ref: '#/parameters/requestId' + - name: group_id + type: integer + in: path + required: true responses: '200': $ref: '#/responses/200' @@ -2825,11 +3111,11 @@ paths: summary: Get artifact icon description: Get the artifact icon with the specified digest. As the original icon image is resized and encoded before returning, the parameter "digest" in the path doesn't match the hash of the returned content tags: - - icon + - icon operationId: getIcon parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/digest' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/digest' responses: '200': description: Success @@ -2846,14 +3132,14 @@ paths: summary: Get robot account description: List the robot accounts with the specified level and project. tags: - - robot + - robot operationId: ListRobot parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Success @@ -2878,16 +3164,16 @@ paths: summary: Create a robot account description: Create a robot account tags: - - robot + - robot operationId: CreateRobot parameters: - - $ref: '#/parameters/requestId' - - name: robot - in: body - description: The JSON object of a robot account. - required: true - schema: - $ref: '#/definitions/RobotCreate' + - $ref: '#/parameters/requestId' + - name: robot + in: body + description: The JSON object of a robot account. + required: true + schema: + $ref: '#/definitions/RobotCreate' responses: '201': description: Created @@ -2915,30 +3201,30 @@ paths: summary: List quotas description: List quotas tags: - - quota + - quota operationId: listQuotas parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: reference - in: query - description: The reference type of quota. - required: false - type: string - - name: reference_id - in: query - description: The reference id of quota. - required: false - type: string - - name: sort - in: query - type: string - required: false - description: | - Sort method, valid values include: - 'hard.resource_name', '-hard.resource_name', 'used.resource_name', '-used.resource_name'. - Here '-' stands for descending order, resource_name should be the real resource name of the quota. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: reference + in: query + description: The reference type of quota. + required: false + type: string + - name: reference_id + in: query + description: The reference id of quota. + required: false + type: string + - name: sort + in: query + type: string + required: false + description: | + Sort method, valid values include: + 'hard.resource_name', '-hard.resource_name', 'used.resource_name', '-used.resource_name'. + Here '-' stands for descending order, resource_name should be the real resource name of the quota. responses: '200': description: Successfully retrieved the quotas. @@ -2964,15 +3250,15 @@ paths: summary: Get the specified quota description: Get the specified quota tags: - - quota + - quota operationId: getQuota parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - required: true - description: Quota ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + required: true + description: Quota ID responses: '200': description: Successfully retrieved the quota. @@ -2990,21 +3276,21 @@ paths: summary: Update the specified quota description: Update hard limits of the specified quota tags: - - quota + - quota operationId: updateQuota parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - required: true - description: Quota ID - - name: hard - in: body - required: true - description: The new hard limits for the quota - schema: - $ref: '#/definitions/QuotaUpdateReq' + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + required: true + description: Quota ID + - name: hard + in: body + required: true + description: The new hard limits for the quota + schema: + $ref: '#/definitions/QuotaUpdateReq' responses: '200': $ref: '#/responses/200' @@ -3023,11 +3309,11 @@ paths: summary: Get a robot account description: This endpoint returns specific robot account information by robot ID. tags: - - robot + - robot operationId: GetRobotByID parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/robotId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/robotId' responses: '200': description: Return matched robot information. @@ -3045,17 +3331,17 @@ paths: summary: Update a robot account description: This endpoint updates specific robot account information by robot ID. tags: - - robot + - robot operationId: UpdateRobot parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/robotId' - - name: robot - in: body - description: The JSON object of a robot account. - required: true - schema: - $ref: '#/definitions/Robot' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/robotId' + - name: robot + in: body + description: The JSON object of a robot account. + required: true + schema: + $ref: '#/definitions/Robot' responses: '200': $ref: '#/responses/200' @@ -3075,17 +3361,17 @@ paths: summary: Refresh the robot secret description: Refresh the robot secret tags: - - robot + - robot operationId: RefreshSec parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/robotId' - - name: robotSec - description: The JSON object of a robot account. - in: body - required: true - schema: - $ref: '#/definitions/RobotSec' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/robotId' + - name: robotSec + description: The JSON object of a robot account. + in: body + required: true + schema: + $ref: '#/definitions/RobotSec' responses: '200': description: Return refreshed robot sec. @@ -3105,11 +3391,11 @@ paths: summary: Delete a robot account description: This endpoint deletes specific robot account information by robot ID. tags: - - robot + - robot operationId: DeleteRobot parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/robotId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/robotId' responses: '200': $ref: '#/responses/200' @@ -3128,19 +3414,19 @@ paths: summary: List replication policies description: List replication policies tags: - - replication + - replication operationId: listReplicationPolicies parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: name - in: query - type: string - required: false - description: Deprecated, use "query" instead. The policy name. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: name + in: query + type: string + required: false + description: Deprecated, use "query" instead. The policy name. responses: '200': description: Success @@ -3165,15 +3451,16 @@ paths: summary: Create a replication policy description: Create a replication policy tags: - - replication + - replication operationId: createReplicationPolicy parameters: - - name: policy - in: body - description: The replication policy - required: true - schema: - $ref: '#/definitions/ReplicationPolicy' + - $ref: '#/parameters/requestId' + - name: policy + in: body + description: The replication policy + required: true + schema: + $ref: '#/definitions/ReplicationPolicy' responses: '201': $ref: '#/responses/201' @@ -3192,15 +3479,16 @@ paths: summary: Get the specific replication policy description: Get the specific replication policy tags: - - replication + - replication operationId: getReplicationPolicy parameters: - - name: id - in: path - type: integer - format: int64 - required: true - description: Policy ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Policy ID responses: '200': description: Success @@ -3216,15 +3504,16 @@ paths: summary: Delete the specific replication policy description: Delete the specific replication policy tags: - - replication + - replication operationId: deleteReplicationPolicy parameters: - - name: id - in: path - type: integer - format: int64 - required: true - description: Replication policy ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Replication policy ID responses: '200': $ref: '#/responses/200' @@ -3242,21 +3531,22 @@ paths: summary: Update the replication policy description: Update the replication policy tags: - - replication + - replication operationId: updateReplicationPolicy parameters: - - name: id - in: path - type: integer - format: int64 - required: true - description: The policy ID - - name: policy - in: body - description: The replication policy - required: true - schema: - $ref: '#/definitions/ReplicationPolicy' + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: The policy ID + - name: policy + in: body + description: The replication policy + required: true + schema: + $ref: '#/definitions/ReplicationPolicy' responses: '200': $ref: '#/responses/200' @@ -3275,28 +3565,28 @@ paths: summary: List replication executions description: List replication executions tags: - - replication + - replication operationId: listReplicationExecutions parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: policy_id - in: query - type: integer - required: false - description: The ID of the policy that the executions belong to. - - name: status - in: query - type: string - required: false - description: The execution status. - - name: trigger - in: query - type: string - required: false - description: The trigger mode. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: policy_id + in: query + type: integer + required: false + description: The ID of the policy that the executions belong to. + - name: status + in: query + type: string + required: false + description: The execution status. + - name: trigger + in: query + type: string + required: false + description: The trigger mode. responses: '200': description: Success @@ -3321,15 +3611,16 @@ paths: summary: Start one replication execution description: Start one replication execution according to the policy tags: - - replication + - replication operationId: startReplication parameters: - - name: execution - in: body - description: The ID of policy that the execution belongs to - required: true - schema: - $ref: '#/definitions/StartReplicationExecution' + - $ref: '#/parameters/requestId' + - name: execution + in: body + description: The ID of policy that the execution belongs to + required: true + schema: + $ref: '#/definitions/StartReplicationExecution' responses: '201': $ref: '#/responses/201' @@ -3346,15 +3637,16 @@ paths: summary: Get the specific replication execution description: Get the replication execution specified by ID tags: - - replication + - replication operationId: getReplicationExecution parameters: - - name: id - in: path - type: integer - format: int64 - description: The ID of the execution. - required: true + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + description: The ID of the execution. + required: true responses: '200': description: Success @@ -3372,15 +3664,16 @@ paths: summary: Stop the specific replication execution description: Stop the replication execution specified by ID tags: - - replication + - replication operationId: stopReplication parameters: - - name: id - in: path - type: integer - format: int64 - description: The ID of the execution. - required: true + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + description: The ID of the execution. + required: true responses: '200': $ref: '#/responses/200' @@ -3397,29 +3690,29 @@ paths: summary: List replication tasks for a specific execution description: List replication tasks for a specific execution tags: - - replication + - replication operationId: listReplicationTasks parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: id - in: path - type: integer - format: int64 - description: The ID of the execution that the tasks belongs to. - required: true - - name: status - in: query - type: string - required: false - description: The task status. - - name: resource_type - in: query - type: string - required: false - description: The resource type. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: id + in: path + type: integer + format: int64 + description: The ID of the execution that the tasks belongs to. + required: true + - name: status + in: query + type: string + required: false + description: The task status. + - name: resource_type + in: query + type: string + required: false + description: The resource type. responses: '200': description: Success @@ -3445,23 +3738,24 @@ paths: summary: Get the log of the specific replication task description: Get the log of the specific replication task tags: - - replication + - replication operationId: getReplicationLog produces: - - text/plain + - text/plain parameters: - - name: id - in: path - type: integer - format: int64 - description: The ID of the execution that the tasks belongs to. - required: true - - name: task_id - in: path - type: integer - format: int64 - description: The ID of the task. - required: true + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + description: The ID of the execution that the tasks belongs to. + required: true + - name: task_id + in: path + type: integer + format: int64 + description: The ID of the task. + required: true responses: '200': description: Success @@ -3484,10 +3778,10 @@ paths: summary: List registry adapters description: List registry adapters tags: - - registry + - registry operationId: listRegistryProviderTypes parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Success. @@ -3506,10 +3800,10 @@ paths: summary: List all registered registry provider information description: List all registered registry provider information tags: - - registry + - registry operationId: listRegistryProviderInfos parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Success. @@ -3528,16 +3822,16 @@ paths: summary: Create a registry description: Create a registry tags: - - registry + - registry operationId: createRegistry parameters: - - $ref: '#/parameters/requestId' - - name: registry - in: body - description: The registry - required: true - schema: - $ref: '#/definitions/Registry' + - $ref: '#/parameters/requestId' + - name: registry + in: body + description: The registry + required: true + schema: + $ref: '#/definitions/Registry' responses: '201': $ref: '#/responses/201' @@ -3555,19 +3849,19 @@ paths: summary: List the registries description: List the registries tags: - - registry + - registry operationId: listRegistries parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: name - in: query - type: string - required: false - description: Deprecated, use `q` instead. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: name + in: query + type: string + required: false + description: Deprecated, use `q` instead. responses: '200': description: Success @@ -3593,16 +3887,16 @@ paths: summary: Check status of a registry description: Check status of a registry tags: - - registry + - registry operationId: pingRegistry parameters: - - $ref: '#/parameters/requestId' - - name: registry - in: body - description: The registry - required: true - schema: - $ref: '#/definitions/RegistryPing' + - $ref: '#/parameters/requestId' + - name: registry + in: body + description: The registry + required: true + schema: + $ref: '#/definitions/RegistryPing' responses: '200': $ref: '#/responses/200' @@ -3621,16 +3915,16 @@ paths: summary: Get the specific registry description: Get the specific registry tags: - - registry + - registry operationId: getRegistry parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Registry ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Registry ID responses: '200': description: Success @@ -3648,16 +3942,16 @@ paths: summary: Delete the specific registry description: Delete the specific registry tags: - - registry + - registry operationId: deleteRegistry parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Registry ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Registry ID responses: '200': $ref: '#/responses/200' @@ -3675,22 +3969,22 @@ paths: summary: Update the registry description: Update the registry tags: - - registry + - registry operationId: updateRegistry parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: The registry ID - - name: registry - in: body - description: The registry - required: true - schema: - $ref: '#/definitions/RegistryUpdate' + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: The registry ID + - name: registry + in: body + description: The registry + required: true + schema: + $ref: '#/definitions/RegistryUpdate' responses: '200': $ref: '#/responses/200' @@ -3709,16 +4003,16 @@ paths: summary: Get the registry info description: Get the registry info tags: - - registry + - registry operationId: getRegistryInfo parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Registry ID + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Registry ID responses: '200': description: Success @@ -3737,10 +4031,10 @@ paths: summary: Get the metrics of the latest scan all process description: Get the metrics of the latest scan all process tags: - - scanAll + - scanAll operationId: getLatestScanAllMetrics parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: OK @@ -3759,11 +4053,11 @@ paths: summary: Get the metrics of the latest scheduled scan all process description: Get the metrics of the latest scheduled scan all process tags: - - scanAll + - scanAll operationId: getLatestScheduledScanAllMetrics deprecated: true parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: OK @@ -3784,9 +4078,9 @@ paths: description: | This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request. tags: - - systeminfo + - systeminfo parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get general info successfully. @@ -3801,9 +4095,9 @@ paths: description: | This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk. tags: - - systeminfo + - systeminfo parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get system volumes successfully. @@ -3824,11 +4118,11 @@ paths: description: | This endpoint is for downloading a default root certificate. tags: - - systeminfo + - systeminfo produces: - - application/octet-stream + - application/octet-stream parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get default root certificate successfully. @@ -3848,22 +4142,23 @@ paths: description: | Test the OIDC endpoint, the setting of the endpoint is provided in the request. This API can only be called by system admin. tags: - - oidc + - oidc operationId: pingOIDC parameters: - - name: endpoint - in: body - description: Request body for OIDC endpoint to be tested. - required: true - schema: - type: object - properties: - url: - type: string - description: The URL of OIDC endpoint to be tested. - verify_cert: - type: boolean - description: Whether the certificate should be verified + - $ref: '#/parameters/requestId' + - name: endpoint + in: body + description: Request body for OIDC endpoint to be tested. + required: true + schema: + type: object + properties: + url: + type: string + description: The URL of OIDC endpoint to be tested. + verify_cert: + type: boolean + description: Whether the certificate should be verified responses: '200': $ref: '#/responses/200' @@ -3878,14 +4173,14 @@ paths: summary: Get gc results. description: This endpoint let user get gc execution history. tags: - - gc + - gc operationId: getGCHistory parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: Get gc results successfully. @@ -3912,10 +4207,10 @@ paths: description: This endpoint let user get gc status filtered by specific ID. operationId: getGC parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/gcId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/gcId' tags: - - gc + - gc responses: '200': description: Get gc results successfully. @@ -3929,18 +4224,38 @@ paths: $ref: '#/responses/404' '500': $ref: '#/responses/500' + put: + summary: Stop the specific GC execution + description: Stop the GC execution specified by ID + tags: + - gc + operationId: stopGC + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/gcId' + responses: + '200': + $ref: '#/responses/200' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' /system/gc/{gc_id}/log: get: summary: Get gc job log. description: This endpoint let user get gc job logs filtered by specific ID. operationId: getGCLog parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/gcId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/gcId' tags: - - gc + - gc produces: - - text/plain + - text/plain responses: '200': description: Get successfully. @@ -3962,9 +4277,9 @@ paths: description: This endpoint is for get schedule of gc job. operationId: getGCSchedule tags: - - gc + - gc parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get gc's schedule. @@ -3982,14 +4297,15 @@ paths: This endpoint is for update gc schedule. operationId: createGCSchedule parameters: - - name: schedule - in: body - required: true - schema: - $ref: '#/definitions/Schedule' - description: Updates of gc's schedule. + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: Updates of gc's schedule. tags: - - gc + - gc responses: '201': $ref: '#/responses/201' @@ -4009,14 +4325,15 @@ paths: This endpoint is for update gc schedule. operationId: updateGCSchedule parameters: - - name: schedule - in: body - required: true - schema: - $ref: '#/definitions/Schedule' - description: Updates of gc's schedule. + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: Updates of gc's schedule. tags: - - gc + - gc responses: '200': description: Updated gc's schedule successfully. @@ -4028,55 +4345,240 @@ paths: $ref: '#/responses/403' '500': $ref: '#/responses/500' - /system/CVEAllowlist: + /system/purgeaudit: get: - summary: Get the system level allowlist of CVE. - description: Get the system level allowlist of CVE. This API can be called by all authenticated users. - operationId: getSystemCVEAllowlist + summary: Get purge job results. + description: get purge job execution history. tags: - - SystemCVEAllowlist + - purge + operationId: getPurgeHistory parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': - description: Successfully retrieved the CVE allowlist. + description: Get purge job results successfully. + headers: + X-Total-Count: + description: The total count of history + type: integer + Link: + description: Link refers to the previous page and next page + type: string schema: - $ref: "#/definitions/CVEAllowlist" + type: array + items: + $ref: '#/definitions/ExecHistory' '401': $ref: '#/responses/401' + '403': + $ref: '#/responses/403' '500': $ref: '#/responses/500' - put: - summary: Update the system level allowlist of CVE. - description: This API overwrites the system level allowlist of CVE with the list in request body. Only system Admin - has permission to call this API. - operationId: putSystemCVEAllowlist - tags: - - SystemCVEAllowlist + /system/purgeaudit/{purge_id}: + get: + summary: Get purge job status. + description: This endpoint let user get purge job status filtered by specific ID. + operationId: getPurgeJob parameters: - - in: body - name: allowlist - description: The allowlist with new content - schema: - $ref: "#/definitions/CVEAllowlist" + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/purgeId' + tags: + - purge responses: '200': - description: Successfully updated the CVE allowlist. + description: Get purge job results successfully. + schema: + $ref: '#/definitions/ExecHistory' '401': $ref: '#/responses/401' '403': $ref: '#/responses/403' + '404': + $ref: '#/responses/404' '500': $ref: '#/responses/500' - /system/scanAll/schedule: - get: - summary: Get scan all's schedule. - description: This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor. + put: + summary: Stop the specific purge audit log execution + description: Stop the purge audit log execution specified by ID tags: - - scanAll - operationId: getScanAllSchedule + - purge + operationId: stopPurge parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/purgeId' + responses: + '200': + $ref: '#/responses/200' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /system/purgeaudit/{purge_id}/log: + get: + summary: Get purge job log. + description: This endpoint let user get purge job logs filtered by specific ID. + operationId: getPurgeJobLog + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/purgeId' + tags: + - purge + produces: + - text/plain + responses: + '200': + description: Get successfully. + schema: + type: string + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /system/purgeaudit/schedule: + get: + summary: Get purge's schedule. + description: This endpoint is for get schedule of purge job. + operationId: getPurgeSchedule + tags: + - purge + parameters: + - $ref: '#/parameters/requestId' + responses: + '200': + description: Get purge job's schedule. + schema: + $ref: '#/definitions/ExecHistory' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + post: + summary: Create a purge job schedule. + description: | + This endpoint is for update purge job schedule. + operationId: createPurgeSchedule + parameters: + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: | + The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + tags: + - purge + responses: + '201': + $ref: '#/responses/201' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + put: + summary: Update purge job's schedule. + description: | + This endpoint is for update purge job schedule. + operationId: updatePurgeSchedule + parameters: + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: | + The purge job's schedule, it is a json object. | + The sample format is | + {"parameters":{"audit_retention_hour":168,"dry_run":true, "include_operations":"create,delete,pull"},"schedule":{"type":"Hourly","cron":"0 0 * * * *"}} | + the include_operation should be a comma separated string, e.g. create,delete,pull, if it is empty, no operation will be purged. + tags: + - purge + responses: + '200': + description: Updated purge's schedule successfully. + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + + /system/CVEAllowlist: + get: + summary: Get the system level allowlist of CVE. + description: Get the system level allowlist of CVE. This API can be called by all authenticated users. + operationId: getSystemCVEAllowlist + tags: + - SystemCVEAllowlist + parameters: + - $ref: '#/parameters/requestId' + responses: + '200': + description: Successfully retrieved the CVE allowlist. + schema: + $ref: "#/definitions/CVEAllowlist" + '401': + $ref: '#/responses/401' + '500': + $ref: '#/responses/500' + put: + summary: Update the system level allowlist of CVE. + description: This API overwrites the system level allowlist of CVE with the list in request body. Only system Admin + has permission to call this API. + operationId: putSystemCVEAllowlist + tags: + - SystemCVEAllowlist + parameters: + - $ref: '#/parameters/requestId' + - in: body + name: allowlist + description: The allowlist with new content + schema: + $ref: "#/definitions/CVEAllowlist" + responses: + '200': + description: Successfully updated the CVE allowlist. + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + /system/scanAll/schedule: + get: + summary: Get scan all's schedule. + description: This endpoint is for getting a schedule for the scan all job, which scans all of images in Harbor. + tags: + - scanAll + operationId: getScanAllSchedule + parameters: + - $ref: '#/parameters/requestId' responses: '200': description: Get a schedule for the scan all job, which scans all of images in Harbor. @@ -4094,14 +4596,15 @@ paths: summary: Update scan all's schedule. description: This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor. parameters: - - name: schedule - in: body - required: true - schema: - $ref: '#/definitions/Schedule' - description: Updates the schedule of scan all job, which scans all of images in Harbor. + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: Updates the schedule of scan all job, which scans all of images in Harbor. tags: - - scanAll + - scanAll operationId: updateScanAllSchedule responses: '200': @@ -4120,14 +4623,15 @@ paths: summary: Create a schedule or a manual trigger for the scan all job. description: This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor. parameters: - - name: schedule - in: body - required: true - schema: - $ref: '#/definitions/Schedule' - description: Create a schedule or a manual trigger for the scan all job. + - $ref: '#/parameters/requestId' + - name: schedule + in: body + required: true + schema: + $ref: '#/definitions/Schedule' + description: Create a schedule or a manual trigger for the scan all job. tags: - - scanAll + - scanAll operationId: createScanAllSchedule responses: '201': @@ -4144,17 +4648,261 @@ paths: $ref: '#/responses/412' '500': $ref: '#/responses/500' + /system/scanAll/stop: + post: + summary: Stop scanAll job execution + description: Stop scanAll job execution + parameters: + - $ref: '#/parameters/requestId' + tags: + - scanAll + operationId: stopScanAll + responses: + '202': + $ref: '#/responses/202' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + /jobservice/pools: + get: + operationId: getWorkerPools + summary: Get worker pools + description: Get worker pools + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + responses: + '200': + description: Get worker pools successfully. + schema: + type: array + items: + $ref: '#/definitions/WorkerPool' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '500': + $ref: '#/responses/500' + /jobservice/pools/{pool_id}/workers: + get: + operationId: getWorkers + summary: Get workers + description: Get workers in current pool + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + - name: pool_id + in: path + required: true + type: string + description: The name of the pool. 'all' stands for all pools + responses: + '200': + description: Get workers successfully. + schema: + type: array + items: + $ref: '#/definitions/Worker' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /jobservice/jobs/{job_id}: + put: + operationId: stopRunningJob + summary: Stop running job + description: Stop running job + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + - name: job_id + in: path + required: true + type: string + description: The id of the job. + responses: + '200': + description: Stop worker successfully. + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /jobservice/jobs/{job_id}/log: + get: + operationId: actionGetJobLog + summary: Get job log by job id + description: Get job log by job id, it is only used by administrator + produces: + - text/plain + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + - name: job_id + in: path + required: true + type: string + description: The id of the job. + responses: + '200': + description: Get job log successfully. + headers: + Content-Type: + description: The content type of response body + type: string + schema: + type: string + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /jobservice/queues: + get: + operationId: listJobQueues + summary: list job queues + description: list job queue + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + responses: + '200': + description: List job queue successfully. + schema: + type: array + items: + $ref: '#/definitions/JobQueue' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /jobservice/queues/{job_type}: + put: + operationId: actionPendingJobs + summary: stop and clean, pause, resume pending jobs in the queue + description: stop and clean, pause, resume pending jobs in the queue + tags: + - jobservice + parameters: + - $ref: '#/parameters/requestId' + - name: job_type + in: path + required: true + type: string + description: The type of the job. 'all' stands for all job types + - name: action_request + in: body + required: true + schema: + $ref: '#/definitions/ActionRequest' + responses: + '200': + description: take action to the jobs in the queue successfully. + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '422': + $ref: '#/responses/422' + '500': + $ref: '#/responses/500' + /schedules: + get: + operationId: listSchedules + description: List schedules + tags: + - schedule + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + responses: + '200': + description: list schedule successfully. + schema: + type: array + items: + type: object + $ref: '#/definitions/ScheduleTask' + headers: + X-Total-Count: + description: The total count of available items + type: integer + Link: + description: Link to previous page and next page + type: string + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /schedules/{job_type}/paused: + get: + operationId: getSchedulePaused + description: Get scheduler paused status + tags: + - schedule + parameters: + - $ref: '#/parameters/requestId' + - name: job_type + in: path + required: true + type: string + description: The type of the job. 'all' stands for all job types, current only support query with all + responses: + '200': + description: Get scheduler status successfully. + schema: + $ref: '#/definitions/SchedulerStatus' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' /ping: get: operationId: getPing - summary: Ping Harbor to check if it's alive. - description: This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. + summary: Ping Harbor to check if the API server is alive. + description: This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. This path does not require any authentication. tags: - - ping + - ping produces: - - text/plain + - text/plain parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: The API server is alive @@ -4166,9 +4914,9 @@ paths: description: Get Retention Metadatas. operationId: getRentenitionMetadata tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get Retention Metadatas successfully. @@ -4184,15 +4932,15 @@ paths: You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: policy - in: body - description: Create Retention Policy successfully. - required: true - schema: - $ref: '#/definitions/RetentionPolicy' + - $ref: '#/parameters/requestId' + - name: policy + in: body + description: Create Retention Policy successfully. + required: true + schema: + $ref: '#/definitions/RetentionPolicy' responses: '201': $ref: '#/responses/201' @@ -4211,15 +4959,15 @@ paths: operationId: getRetention description: Get Retention Policy. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. responses: '200': description: Get Retention Policy successfully. @@ -4239,20 +4987,20 @@ paths: You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: policy - in: body - required: true - schema: - $ref: '#/definitions/RetentionPolicy' + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: policy + in: body + required: true + schema: + $ref: '#/definitions/RetentionPolicy' responses: '200': description: Update Retention Policy successfully. @@ -4270,15 +5018,15 @@ paths: You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. responses: '200': description: Update Retention Policy successfully. @@ -4295,25 +5043,25 @@ paths: operationId: triggerRetentionExecution description: Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually. tags: - - Retention + - Retention produces: - - text/plain + - text/plain parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: body - in: body - required: true - schema: - type: object - properties: - dry_run: - type: boolean + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: body + in: body + required: true + schema: + type: object + properties: + dry_run: + type: boolean responses: '200': description: Trigger a Retention job successfully. @@ -4330,27 +5078,27 @@ paths: operationId: listRetentionExecutions description: Get Retention executions, execution status may be delayed before job service schedule it up. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: page - in: query - type: integer - format: int64 - required: false - description: The page number. - - name: page_size - in: query - type: integer - format: int64 - required: false - description: The size of per page. + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: page + in: query + type: integer + format: int64 + required: false + description: The page number. + - name: page_size + in: query + type: integer + format: int64 + required: false + description: The size of per page. responses: '200': description: Get a Retention execution successfully. @@ -4379,30 +5127,30 @@ paths: operationId: operateRetentionExecution description: Stop a Retention execution, only support "stop" action now. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: eid - in: path - type: integer - format: int64 - required: true - description: Retention execution ID. - - name: body - in: body - description: The action, only support "stop" now. - required: true - schema: - type: object - properties: - action: - type: string + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: eid + in: path + type: integer + format: int64 + required: true + description: Retention execution ID. + - name: body + in: body + description: The action, only support "stop" now. + required: true + schema: + type: object + properties: + action: + type: string responses: '200': description: Stop a Retention job successfully. @@ -4419,33 +5167,33 @@ paths: operationId: listRetentionTasks description: Get Retention tasks, each repository as a task. tags: - - Retention + - Retention parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: eid - in: path - type: integer - format: int64 - required: true - description: Retention execution ID. - - name: page - in: query - type: integer - format: int64 - required: false - description: The page number. - - name: page_size - in: query - type: integer - format: int64 - required: false - description: The size of per page. + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: eid + in: path + type: integer + format: int64 + required: true + description: Retention execution ID. + - name: page + in: query + type: integer + format: int64 + required: false + description: The page number. + - name: page_size + in: query + type: integer + format: int64 + required: false + description: The size of per page. responses: '200': description: Get Retention job tasks successfully. @@ -4474,29 +5222,29 @@ paths: operationId: getRetentionTaskLog description: Get Retention job task log, tags ratain or deletion detail will be shown in a table. tags: - - Retention + - Retention produces: - - text/plain + - text/plain parameters: - - $ref: '#/parameters/requestId' - - name: id - in: path - type: integer - format: int64 - required: true - description: Retention ID. - - name: eid - in: path - type: integer - format: int64 - required: true - description: Retention execution ID. - - name: tid - in: path - type: integer - format: int64 - required: true - description: Retention execution ID. + - $ref: '#/parameters/requestId' + - name: id + in: path + type: integer + format: int64 + required: true + description: Retention ID. + - name: eid + in: path + type: integer + format: int64 + required: true + description: Retention execution ID. + - name: tid + in: path + type: integer + format: int64 + required: true + description: Retention execution ID. responses: '200': description: Get Retention job task log successfully. @@ -4515,14 +5263,14 @@ paths: description: | Returns a list of currently configured scanner registrations. tags: - - scanner + - scanner operationId: listScanners parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: A list of scanner registrations. @@ -4550,16 +5298,16 @@ paths: description: | Creats a new scanner registration with the given data. tags: - - scanner + - scanner operationId: createScanner parameters: - - $ref: '#/parameters/requestId' - - name: registration - in: body - description: A scanner registration to be created. - required: true - schema: - $ref: '#/definitions/ScannerRegistrationReq' + - $ref: '#/parameters/requestId' + - name: registration + in: body + description: A scanner registration to be created. + required: true + schema: + $ref: '#/definitions/ScannerRegistrationReq' responses: '201': description: Created successfully @@ -4581,16 +5329,16 @@ paths: description: | Pings scanner adapter to test endpoint URL and authorization settings. tags: - - scanner + - scanner operationId: pingScanner parameters: - - $ref: '#/parameters/requestId' - - name: settings - in: body - description: A scanner registration settings to be tested. - required: true - schema: - $ref: '#/definitions/ScannerRegistrationSettings' + - $ref: '#/parameters/requestId' + - name: settings + in: body + description: A scanner registration settings to be tested. + required: true + schema: + $ref: '#/definitions/ScannerRegistrationSettings' responses: '200': $ref: '#/responses/200' @@ -4608,15 +5356,15 @@ paths: description: | Retruns the details of the specified scanner registration. tags: - - scanner + - scanner operationId: getScanner parameters: - - $ref: '#/parameters/requestId' - - name: registration_id - in: path - description: The scanner registration identifer. - required: true - type: string + - $ref: '#/parameters/requestId' + - name: registration_id + in: path + description: The scanner registration identifer. + required: true + type: string responses: '200': description: The details of the scanner registration. @@ -4635,21 +5383,21 @@ paths: description: | Updates the specified scanner registration. tags: - - scanner + - scanner operationId: updateScanner parameters: - - $ref: '#/parameters/requestId' - - name: registration_id - in: path - description: The scanner registration identifier. - required: true - type: string - - name: registration - in: body - required: true - description: A scanner registraiton to be updated. - schema: - $ref: '#/definitions/ScannerRegistrationReq' + - $ref: '#/parameters/requestId' + - name: registration_id + in: path + description: The scanner registration identifier. + required: true + type: string + - name: registration + in: body + required: true + description: A scanner registraiton to be updated. + schema: + $ref: '#/definitions/ScannerRegistrationReq' responses: '200': $ref: '#/responses/200' @@ -4666,15 +5414,15 @@ paths: description: | Deletes the specified scanner registration. tags: - - scanner + - scanner operationId: deleteScanner parameters: - - $ref: '#/parameters/requestId' - - name: registration_id - in: path - description: The scanner registration identifier. - required: true - type: string + - $ref: '#/parameters/requestId' + - name: registration_id + in: path + description: The scanner registration identifier. + required: true + type: string responses: '200': description: Deleted successfully and return the deleted registration @@ -4693,19 +5441,20 @@ paths: description: | Set the specified scanner registration as the system default one. tags: - - scanner + - scanner operationId: setScannerAsDefault parameters: - - name: registration_id - in: path - description: The scanner registration identifier. - required: true - type: string - - name: payload - in: body - required: true - schema: - $ref: '#/definitions/IsDefault' + - $ref: '#/parameters/requestId' + - name: registration_id + in: path + description: The scanner registration identifier. + required: true + type: string + - name: payload + in: body + required: true + schema: + $ref: '#/definitions/IsDefault' responses: '200': description: Successfully set the specified scanner registration as system default @@ -4721,15 +5470,15 @@ paths: description: | Get the metadata of the specified scanner registration, including the capabilities and customized properties. tags: - - scanner + - scanner operationId: getScannerMetadata parameters: - - $ref: '#/parameters/requestId' - - name: registration_id - in: path - required: true - description: The scanner registration identifier. - type: string + - $ref: '#/parameters/requestId' + - name: registration_id + in: path + required: true + description: The scanner registration identifier. + type: string responses: '200': description: The metadata of the specified scanner adapter @@ -4745,14 +5494,14 @@ paths: get: summary: List users tags: - - user + - user operationId: listUsers parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' responses: '200': description: return the list of users. @@ -4777,16 +5526,16 @@ paths: summary: Create a local user. description: This API can be used only when the authentication mode is for local DB. When self registration is disabled. tags: - - user + - user operationId: createUser parameters: - - $ref: '#/parameters/requestId' - - name: userReq - in: body - description: The new user - required: true - schema: - $ref: '#/definitions/UserCreationReq' + - $ref: '#/parameters/requestId' + - name: userReq + in: body + description: The new user + required: true + schema: + $ref: '#/definitions/UserCreationReq' responses: '201': $ref: '#/responses/201' @@ -4804,10 +5553,10 @@ paths: get: summary: Get current user info. tags: - - user + - user operationId: getCurrentUserInfo parameters: - - $ref: '#/parameters/requestId' + - $ref: '#/parameters/requestId' responses: '200': description: Get current user information successfully. @@ -4823,17 +5572,17 @@ paths: description: | This endpoint is to search the users by username. It's open for all authenticated requests. tags: - - user + - user operationId: searchUsers parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: username - in: query - type: string - required: true - description: Username for filtering results. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: username + in: query + type: string + required: true + description: Username for filtering results. responses: '200': description: Search users by username successfully. @@ -4856,14 +5605,14 @@ paths: get: summary: Get a user's profile. parameters: - - $ref: '#/parameters/requestId' - - name: user_id - in: path - type: integer - format: int - required: true + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true tags: - - user + - user operationId: getUser responses: '200': @@ -4881,21 +5630,21 @@ paths: put: summary: Update user's profile. parameters: - - $ref: '#/parameters/requestId' - - name: user_id - in: path - type: integer - format: int - required: true - description: Registered user ID - - name: profile - in: body - description: 'Only email, realname and comment can be modified.' - required: true - schema: - $ref: '#/definitions/UserProfile' - tags: - - user + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true + description: Registered user ID + - name: profile + in: body + description: 'Only email, realname and comment can be modified.' + required: true + schema: + $ref: '#/definitions/UserProfile' + tags: + - user operationId: updateUserProfile responses: '200': @@ -4913,14 +5662,15 @@ paths: description: | This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. parameters: - - name: user_id - in: path - type: integer - format: int - required: true - description: User ID for marking as to be removed. + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true + description: User ID for marking as to be removed. tags: - - user + - user operationId: deleteUser responses: '200': @@ -4937,20 +5687,21 @@ paths: put: summary: Update a registered user to change to be an administrator of Harbor. tags: - - user + - user operationId: setUserSysAdmin parameters: - - name: user_id - in: path - type: integer - format: int - required: true - - name: sysadmin_flag - in: body - description: Toggle a user to admin or not. - required: true - schema: - $ref: '#/definitions/UserSysAdminFlag' + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true + - name: sysadmin_flag + in: body + description: Toggle a user to admin or not. + required: true + schema: + $ref: '#/definitions/UserSysAdminFlag' responses: '200': $ref: '#/responses/200' @@ -4968,20 +5719,21 @@ paths: description: | This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password. tags: - - user + - user operationId: updateUserPassword parameters: - - name: user_id - in: path - type: integer - format: int - required: true - - name: password - in: body - description: Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator. - required: true - schema: - $ref: '#/definitions/PasswordReq' + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true + - name: password + in: body + description: Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator. + required: true + schema: + $ref: '#/definitions/PasswordReq' responses: '200': $ref: '#/responses/200' @@ -4997,21 +5749,22 @@ paths: get: summary: Get current user permissions. tags: - - user + - user operationId: getCurrentUserPermissions parameters: - - name: scope - in: query - type: string - required: false - description: The scope for the permission - - name: relative - in: query - type: boolean - required: false - description: | - If true, the resources in the response are relative to the scope, - eg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'. + - $ref: '#/parameters/requestId' + - name: scope + in: query + type: string + required: false + description: The scope for the permission + - name: relative + in: query + type: boolean + required: false + description: | + If true, the resources in the response are relative to the scope, + eg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'. responses: '200': description: Get current user permission successfully. @@ -5031,21 +5784,21 @@ paths: Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user. tags: - - user + - user operationId: setCliSecret parameters: - - $ref: '#/parameters/requestId' - - name: user_id - in: path - type: integer - format: int - required: true - description: User ID - - name: secret - in: body - required: true - schema: - $ref: '#/definitions/OIDCCliSecretReq' + - $ref: '#/parameters/requestId' + - name: user_id + in: path + type: integer + format: int + required: true + description: User ID + - name: secret + in: body + required: true + schema: + $ref: '#/definitions/OIDCCliSecretReq' responses: '200': description: The secret is successfully updated @@ -5068,30 +5821,30 @@ paths: description: | This endpoint let user list labels by name, scope and project_id tags: - - label + - label operationId: ListLabels parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/query' - - $ref: '#/parameters/sort' - - $ref: '#/parameters/page' - - $ref: '#/parameters/pageSize' - - name: name - in: query - type: string - required: false - description: The label name. - - name: scope - in: query - type: string - required: false - description: The label scope. Valid values are g and p. g for global labels and p for project labels. - - name: project_id - in: query - type: integer - format: int64 - required: false - description: Relevant project ID, required when scope is p. + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/sort' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: name + in: query + type: string + required: false + description: The label name. + - name: scope + in: query + type: string + required: false + description: The label scope. Valid values are g and p. g for global labels and p for project labels. + - name: project_id + in: query + type: integer + format: int64 + required: false + description: Relevant project ID, required when scope is p. responses: '200': description: Get successfully. @@ -5117,100 +5870,329 @@ paths: description: | This endpoint let user creates a label. tags: - - label + - label operationId: CreateLabel parameters: - - name: label - in: body - description: The json object of label. - required: true - schema: - $ref: '#/definitions/Label' + - $ref: '#/parameters/requestId' + - name: label + in: body + description: The json object of label. + required: true + schema: + $ref: '#/definitions/Label' responses: '201': description: Create successfully. headers: Location: type: string - description: The URL of the created resource - '400': - $ref: '#/responses/400' + description: The URL of the created resource + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '409': + $ref: '#/responses/409' + '415': + $ref: '#/responses/415' + '500': + $ref: '#/responses/500' + '/labels/{label_id}': + get: + summary: Get the label specified by ID. + description: | + This endpoint let user get the label by specific ID. + tags: + - label + operationId: GetLabelByID + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/labelId' + responses: + '200': + description: Get successfully. + schema: + $ref: '#/definitions/Label' + '401': + $ref: '#/responses/401' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + put: + summary: Update the label properties. + description: | + This endpoint let user update label properties. + tags: + - label + operationId: UpdateLabel + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/labelId' + - name: label + in: body + description: The updated label json object. + required: true + schema: + $ref: '#/definitions/Label' + responses: + '200': + $ref: '#/responses/200' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '404': + $ref: '#/responses/404' + '409': + $ref: '#/responses/409' + '500': + $ref: '#/responses/500' + delete: + summary: Delete the label specified by ID. + description: | + Delete the label specified by ID. + tags: + - label + operationId: DeleteLabel + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/labelId' + responses: + '200': + $ref: '#/responses/200' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + + /export/cve: + post: + summary: Export scan data for selected projects + description: Export scan data for selected projects + tags: + - scan data export + operationId: exportScanData + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/scanDataType' + - name: criteria + in: body + description: The criteria for the export + required: true + schema: + $ref: '#/definitions/ScanDataExportRequest' + responses: + '200': + description: Success. + schema: + $ref: '#/definitions/ScanDataExportJob' + '400': + $ref: '#/responses/400' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '405': + $ref: '#/responses/405' + '409': + $ref: '#/responses/409' + '500': + $ref: '#/responses/500' + /export/cve/execution/{execution_id}: + get: + summary: Get the specific scan data export execution + description: Get the scan data export execution specified by ID + tags: + - scan data export + operationId: getScanDataExportExecution + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/executionId' + responses: + '200': + description: Success + schema: + $ref: '#/definitions/ScanDataExportExecution' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /export/cve/executions: + get: + summary: Get a list of specific scan data export execution jobs for a specified user + description: Get a list of specific scan data export execution jobs for a specified user + tags: + - scan data export + operationId: getScanDataExportExecutionList + parameters: + - $ref: '#/parameters/requestId' + responses: + '200': + description: Success + schema: + $ref: '#/definitions/ScanDataExportExecutionList' + '401': + $ref: '#/responses/401' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' + '500': + $ref: '#/responses/500' + /export/cve/download/{execution_id}: + get: + summary: Download the scan data export file + description: Download the scan data report. Default format is CSV + tags: + - scan data export + operationId: downloadScanData + produces: + - text/csv + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/executionId' + - name: format + in: query + type: string + required: false + description: The format of the data to be exported. e.g. CSV or PDF + responses: + '200': + description: Data file containing the export data + schema: + type: file + headers: + Content-Disposition: + type: string + description: Value is a CSV formatted file; filename=export.csv '401': $ref: '#/responses/401' - '409': - $ref: '#/responses/409' - '415': - $ref: '#/responses/415' + '403': + $ref: '#/responses/403' + '404': + $ref: '#/responses/404' '500': $ref: '#/responses/500' - '/labels/{label_id}': + /security/summary: get: - summary: Get the label specified by ID. - description: | - This endpoint let user get the label by specific ID. + summary: Get vulnerability system summary + description: Retrieve the vulnerability summary of the system tags: - - label - operationId: GetLabelByID + - securityhub + operationId: getSecuritySummary parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/labelId' + - $ref: '#/parameters/requestId' + - name: with_dangerous_cve + in: query + description: Specify whether the dangerous CVEs are included inside summary information + type: boolean + required: false + default: false + - name: with_dangerous_artifact + in: query + description: Specify whether the dangerous Artifact are included inside summary information + type: boolean + required: false + default: false responses: '200': - description: Get successfully. + description: Success schema: - $ref: '#/definitions/Label' + $ref: '#/definitions/SecuritySummary' '401': $ref: '#/responses/401' + '403': + $ref: '#/responses/403' '404': $ref: '#/responses/404' '500': $ref: '#/responses/500' - put: - summary: Update the label properties. + + /security/vul: + get: + summary: Get the vulnerability list. description: | - This endpoint let user update label properties. - tags: - - label - operationId: UpdateLabel - parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/labelId' - - name: label - in: body - description: The updated label json object. - required: true - schema: - $ref: '#/definitions/Label' + Get the vulnerability list. use q to pass the query condition, + supported conditions: + cve_id(exact match) + cvss_score_v3(range condition) + severity(exact match) + repository_name(exact match) + project_id(exact match) + package(exact match) + tag(exact match) + digest(exact match) + tags: + - securityhub + operationId: ListVulnerabilities + parameters: + - $ref: '#/parameters/requestId' + - $ref: '#/parameters/query' + - $ref: '#/parameters/page' + - $ref: '#/parameters/pageSize' + - name: tune_count + in: query + description: Enable to ignore X-Total-Count when the total count > 1000, if the total count is less than 1000, the real total count is returned, else -1. + type: boolean + required: false + default: false + - name: with_tag + in: query + description: Specify whether the tag information is included inside vulnerability information + type: boolean + required: false + default: false responses: '200': - $ref: '#/responses/200' + description: The vulnerability list. + schema: + type: array + items: + $ref: '#/definitions/VulnerabilityItem' + headers: + X-Total-Count: + description: The total count of vulnerabilities + type: integer + Link: + description: Link refers to the previous page and next page + type: string '400': $ref: '#/responses/400' '401': $ref: '#/responses/401' - '404': - $ref: '#/responses/404' - '409': - $ref: '#/responses/409' '500': $ref: '#/responses/500' - delete: - summary: Delete the label specified by ID. + + /permissions: + get: + summary: Get system or project level permissions info. + operationId: getPermissions description: | - Delete the label specified by ID. + This endpoint is for retrieving resource and action info that only provides for admin user(system admin and project admin). tags: - - label - operationId: DeleteLabel + - permissions parameters: - - $ref: '#/parameters/requestId' - - $ref: '#/parameters/labelId' + - $ref: '#/parameters/requestId' responses: '200': - $ref: '#/responses/200' - '400': - $ref: '#/responses/400' + description: Get permissions successfully. + schema: + $ref: '#/definitions/Permissions' '401': $ref: '#/responses/401' + '403': + $ref: '#/responses/403' '404': $ref: '#/responses/404' '500': @@ -5225,7 +6207,7 @@ parameters: required: false sort: name: sort - description: Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2" + description: Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with "sort=field1,-field2" in: query type: string required: false @@ -5271,7 +6253,7 @@ parameters: name: X-Accept-Vulnerabilities in: header type: string - default: 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' + default: 'application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' description: |- A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports 'application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' and 'application/vnd.security.vulnerability.report; version=1.1' @@ -5290,7 +6272,7 @@ parameters: repositoryName: name: repository_name in: path - description: The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb + description: The name of the repository. If it contains slash, encode it twice over with URL encoding. e.g. a/b -> a%2Fb -> a%252Fb required: true type: string reference: @@ -5348,6 +6330,13 @@ parameters: required: true type: integer format: int64 + purgeId: + name: purge_id + in: path + description: The ID of the purge log + required: true + type: integer + format: int64 labelId: name: label_id in: path @@ -5369,6 +6358,25 @@ parameters: required: true type: integer format: int64 + accessoryId: + name: accessory_id + in: path + description: The ID of the accessory + required: true + type: integer + format: int64 + scanDataType: + name: X-Scan-Data-Type + description: The type of scan data to export + in: header + type: string + required: true + userName: + name: user_name + description: The name of the user + in: query + type: string + required: true responses: '200': @@ -5456,6 +6464,14 @@ responses: type: string schema: $ref: '#/definitions/Errors' + '422': + description: Unsupported Type + headers: + X-Request-Id: + description: The ID of the corresponding request for the response + type: string + schema: + $ref: '#/definitions/Errors' '500': description: Internal server error headers: @@ -5496,13 +6512,6 @@ definitions: type: array items: $ref: '#/definitions/SearchRepository' - chart: - description: Search results of the charts that macthed the filter keywords. - type: array - items: - $ref: '#/definitions/SearchResult' - x-omitempty: true - x-isnullable: true SearchRepository: type: object properties: @@ -5524,93 +6533,6 @@ definitions: artifact_count: type: integer description: The count of artifacts in the repository - SearchResult: - type: object - description: The chart search result item - properties: - Name: - type: string - description: The chart name with repo name - Score: - type: integer - description: The matched level - Chart: - $ref: '#/definitions/ChartVersion' - ChartVersion: - type: object - description: A specified chart entry - allOf: - - $ref: '#/definitions/ChartMetadata' - - type: object - properties: - created: - type: string - description: The created time of the chart entry - removed: - type: boolean - description: A flag to indicate if the chart entry is removed - digest: - type: string - description: The digest value of the chart entry - urls: - type: array - description: The urls of the chart entry - items: - type: string - properties: - labels: - type: array - description: A list of label - items: - $ref: '#/definitions/Label' - ChartMetadata: - type: object - description: The metadata of chart version - required: - - name - - version - - engine - - icon - - apiVersion - - appVersion - properties: - name: - type: string - description: The name of the chart - home: - type: string - description: The URL to the relevant project page - sources: - type: array - description: The URL to the source code of chart - items: - type: string - version: - type: string - description: A SemVer 2 version of chart - description: - type: string - description: A one-sentence description of chart - keywords: - type: array - description: A list of string keywords - items: - type: string - engine: - type: string - description: The name of template engine - icon: - type: string - description: The URL to an icon file - apiVersion: - type: string - description: The API version of this chart - appVersion: - type: string - description: The version of the application enclosed in the chart - deprecated: - type: boolean - description: Whether or not this chart is deprecated Repository: type: object properties: @@ -5632,14 +6554,18 @@ definitions: type: integer format: int64 description: The count of the artifacts inside the repository + x-omitempty: false pull_count: type: integer format: int64 description: The count that the artifact inside the repository pulled + x-omitempty: false creation_time: type: string format: date-time description: The creation time of the repository + x-nullable: true + x-omitempty: true update_time: type: string format: date-time @@ -5707,6 +6633,14 @@ definitions: scan_overview: $ref: '#/definitions/ScanOverview' description: The overview of the scan result. + sbom_overview: + $ref: '#/definitions/SBOMOverview' + description: The overview of the generating SBOM progress + accessories: + type: array + items: + $ref: '#/definitions/Accessory' + description: The accessory of the artifact. Tag: type: object properties: @@ -5737,10 +6671,6 @@ definitions: type: boolean x-omitempty: false description: The immutable status of the tag - signed: - type: boolean - x-omitempty: false - description: The attribute indicates whether the tag is signed or not ExtraAttrs: type: object additionalProperties: @@ -5857,6 +6787,37 @@ definitions: description: 'The scan overview attached in the metadata of tag' additionalProperties: $ref: '#/definitions/NativeReportSummary' + SBOMOverview: + type: object + description: 'The generate SBOM overview information' + properties: + start_time: + type: string + format: date-time + description: 'The start time of the generating sbom report task' + example: '2006-01-02T14:04:05Z' + end_time: + type: string + format: date-time + description: 'The end time of the generating sbom report task' + example: '2006-01-02T15:04:05Z' + scan_status: + type: string + description: 'The status of the generating SBOM task' + sbom_digest: + type: string + description: 'The digest of the generated SBOM accessory' + report_id: + type: string + description: 'id of the native scan report' + example: '5f62c830-f996-11e9-957f-0242c0a89008' + duration: + type: integer + format: int64 + description: 'Time in seconds required to create the report' + example: 300 + scanner: + $ref: '#/definitions/Scanner' NativeReportSummary: type: object description: 'The summary for the native report' @@ -5884,12 +6845,12 @@ definitions: type: string format: date-time description: 'The start time of the scan process that generating report' - example: '2006-01-02T14:04:05' + example: '2006-01-02T14:04:05Z' end_time: type: string format: date-time description: 'The end time of the scan process that generating report' - example: '2006-01-02T15:04:05' + example: '2006-01-02T15:04:05Z' complete_percent: type: integer description: 'The complete percent of the scanning which value is between 0 and 100' @@ -5945,7 +6906,7 @@ definitions: op_time: type: string format: date-time - example: '2006-01-02T15:04:05' + example: '2006-01-02T15:04:05Z' description: The time when this operation is triggered. Metadata: type: object @@ -6168,6 +7129,7 @@ definitions: project_name: type: string description: The name of the project. + maxLength: 255 public: type: boolean description: deprecated, reserved for project creation in replication @@ -6235,9 +7197,7 @@ definitions: repo_count: type: integer description: The number of the repositories under this project. - chart_count: - type: integer - description: The total number of charts under this project. + x-omitempty: false metadata: description: The metadata of the project. $ref: '#/definitions/ProjectMetadata' @@ -6263,6 +7223,10 @@ definitions: type: string description: 'Whether content trust is enabled or not. If it is enabled, user can''t pull unsigned images from this project. The valid values are "true", "false".' x-nullable: true + enable_content_trust_cosign: + type: string + description: 'Whether cosign content trust is enabled or not. If it is enabled, user can''t pull images without cosign signature from this project. The valid values are "true", "false".' + x-nullable: true prevent_vul: type: string description: 'Whether prevent the vulnerable images from running. The valid values are "true", "false".' @@ -6275,6 +7239,10 @@ definitions: type: string description: 'Whether scan images automatically when pushing. The valid values are "true", "false".' x-nullable: true + auto_sbom_generation: + type: string + description: 'Whether generating SBOM automatically when pushing a subject artifact. The valid values are "true", "false".' + x-nullable: true reuse_sys_cve_allowlist: type: string description: 'Whether this project reuse the system level CVE allowlist as the allowlist of its own. The valid values are "true", "false". @@ -6290,9 +7258,7 @@ definitions: repo_count: type: integer description: The number of the repositories under this project. - chart_count: - type: integer - description: The total number of charts under this project. + x-omitempty: false project_admin_count: type: integer description: The total number of project admin members. @@ -6324,7 +7290,7 @@ definitions: ProjectScanner: type: object required: - - uuid + - uuid properties: uuid: type: string @@ -6418,6 +7384,15 @@ definitions: type: string format: date-time description: The update time of the policy. + speed: + type: integer + format: int32 + description: speed limit for each task + x-isnullable: true # make this field optional to keep backward compatibility + copy_by_chunk: + type: boolean + description: Whether to enable copy by chunk. + x-isnullable: true ReplicationTrigger: type: object properties: @@ -6441,6 +7416,9 @@ definitions: value: type: object description: 'The value of replication policy filter.' + decoration: + type: string + description: 'matches or excludes the result' RegistryCredential: type: object properties: @@ -6572,6 +7550,11 @@ definitions: description: The triggers that the registry supports items: type: string + supported_copy_by_chunk: + type: boolean + description: The registry whether support copy by chunk. + x-omitempty: true + x-isnullable: true RegistryProviderInfo: type: object description: The registry provider info contains the base info and capability declarations of the registry provider @@ -6740,7 +7723,7 @@ definitions: description: The ID of the robot name: type: string - description: The name of the tag + description: The name of the robot description: type: string description: The description of the robot @@ -6752,8 +7735,9 @@ definitions: description: The level of the robot, project or system duration: type: integer + x-nullable: true format: int64 - description: The duration of the robot in days + description: The duration of the robot in days, duration must be either -1(Never) or a positive integer editable: type: boolean x-omitempty: false @@ -6765,7 +7749,7 @@ definitions: expires_at: type: integer format: int64 - description: The expiration data of the robot + description: The expiration date of the robot permissions: type: array items: @@ -6784,7 +7768,7 @@ definitions: properties: name: type: string - description: The name of the tag + description: The name of the robot description: type: string description: The description of the robot @@ -6800,7 +7784,7 @@ definitions: duration: type: integer format: int64 - description: The duration of the robot in days + description: The duration of the robot in days, duration must be either -1(Never) or a positive integer permissions: type: array items: @@ -6815,7 +7799,7 @@ definitions: description: The ID of the robot name: type: string - description: The name of the tag + description: The name of the robot secret: type: string description: The secret of the robot @@ -6826,7 +7810,7 @@ definitions: expires_at: type: integer format: int64 - description: The expiration data of the robot + description: The expiration date of the robot RobotSec: type: object description: The response for refresh/update robot account secret. @@ -6852,10 +7836,10 @@ definitions: properties: resource: type: string - description: The resource of the access + description: The resource of the access. Possible resources are listed here for system and project level https://github.com/goharbor/harbor/blob/main/src/common/rbac/const.go action: type: string - description: The action of the access + description: The action of the access. Possible actions are *, pull, push, create, read, update, delete, list, operate, scanner-pull and stop. effect: type: string description: The effect of the access @@ -6890,16 +7874,18 @@ definitions: GeneralInfo: type: object properties: - with_notary: - type: boolean + banner_message: + type: string x-nullable: true x-omitempty: true - description: If the Harbor instance is deployed with nested notary. - with_chartmuseum: - type: boolean + description: The banner message for the UI. It is the stringified result of the banner message object. + example: "{\"closable\":true,\"message\":\"your banner message content\",\"type\":\"warning\",\"fromDate\":\"06/19/2023\",\"toDate\":\"06/21/2023\"}" + current_time: + type: string + format: date-time x-nullable: true x-omitempty: true - description: If the Harbor instance is deployed with nested chartmuseum. + description: The current time of the server. registry_url: type: string x-nullable: true @@ -6915,6 +7901,11 @@ definitions: x-nullable: true x-omitempty: true description: The auth mode of current Harbor instance. + primary_auth_mode: + type: boolean + x-nullable: true + x-omitempty: true + description: The flag to indicate whether the current auth mode should consider as a primary one. project_creation_restriction: type: string x-nullable: true @@ -6955,6 +7946,11 @@ definitions: x-nullable: true x-omitempty: true $ref: '#/definitions/AuthproxySetting' + oidc_provider_name: + type: string + x-nullable: true + x-omitempty: true + description: The OIDC provider name, empty if current auth is not OIDC_auth or OIDC provider is not configured. AuthproxySetting: type: object properties: @@ -7012,6 +8008,37 @@ definitions: type: string format: date-time description: the update time of gc job. + ExecHistory: + type: object + properties: + id: + type: integer + description: the id of purge job. + job_name: + type: string + description: the job name of purge job. + job_kind: + type: string + description: the job kind of purge job. + job_parameters: + type: string + description: the job parameters of purge job. + schedule: + $ref: '#/definitions/ScheduleObj' + job_status: + type: string + description: the status of purge job. + deleted: + type: boolean + description: if purge job was deleted. + creation_time: + type: string + format: date-time + description: the creation time of purge job. + update_time: + type: string + format: date-time + description: the update time of purge job. Schedule: type: object properties: @@ -7046,19 +8073,24 @@ definitions: type: type: string description: | - The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual' and 'None'. - 'Manual' means to trigger it right away and 'None' means to cancel the schedule. + The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual', 'None' and 'Schedule'. + 'Manual' means to trigger it right away, 'Schedule' means to trigger it by a specified cron schedule and + 'None' means to cancel the schedule. enum: - - Hourly - - Daily - - Weekly - - Custom - - Manual - - None + - Hourly + - Daily + - Weekly + - Custom + - Manual + - None + - Schedule cron: type: string description: A cron expression, a time-based job scheduler. - + next_scheduled_time: + type: string + format: date-time + description: The next time to schedule to run the job. Stats: type: object description: Stats provides the overall progress of the scan all process. @@ -7094,9 +8126,9 @@ definitions: type: string description: The trigger of the scan all job. enum: - - Manual - - Schedule - - Event + - Manual + - Schedule + - Event RetentionMetadata: type: object description: the tag retention metadata @@ -7349,7 +8381,7 @@ definitions: x-omitempty: false url: type: string - format: url + format: uri description: A base URL of the scanner adapter example: http://harbor-scanner-trivy:8080 disabled: @@ -7397,7 +8429,7 @@ definitions: adapter: type: string description: Optional property to describe the name of the scanner registration - example: "Clair" + example: "Trivy" vendor: type: string description: Optional property to describe the vendor of the scanner registration @@ -7411,12 +8443,17 @@ definitions: default: "" description: Indicate the healthy of the registration example: "healthy" + capabilities: + type: object + description: Indicates the capabilities of the scanner, e.g. support_vulnerability or support_sbom. + additionalProperties: True + example: {"support_vulnerability": true, "support_sbom": true} ScannerRegistrationReq: type: object required: - - name - - url + - name + - url properties: name: type: string @@ -7459,8 +8496,8 @@ definitions: ScannerRegistrationSettings: type: object required: - - name - - url + - name + - url properties: name: type: string @@ -7493,6 +8530,12 @@ definitions: ScannerCapability: type: object properties: + type: + type: string + description: | + Specify the type of scanner capability, like vulnerability or sbom + x-omitempty: false + example: "sbom" consumes_mime_types: type: array items: @@ -7642,13 +8685,25 @@ definitions: description: The name of the user group group_type: type: integer - description: 'The group type, 1 for LDAP group, 2 for HTTP group.' + description: 'The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.' ldap_group_dn: type: string description: The DN of the LDAP group if group type is 1 (LDAP group). + UserGroupSearchItem: + type: object + properties: + id: + type: integer + description: The ID of the user group + group_name: + type: string + description: The name of the user group + group_type: + type: integer + description: 'The group type, 1 for LDAP group, 2 for HTTP group, 3 for OIDC group.' SupportedWebhookEventTypes: type: object - description: Supportted webhook event types and notify types. + description: Supported webhook event types and notify types. properties: event_type: type: array @@ -7658,14 +8713,33 @@ definitions: type: array items: $ref: '#/definitions/NotifyType' + payload_formats: + type: array + items: + $ref: '#/definitions/PayloadFormat' EventType: type: string - description: Webhook supportted event type. - example: 'pullImage' + description: Webhook supported event type. + example: 'PULL_ARTIFACT' NotifyType: type: string - description: Webhook supportted notify type. + description: Webhook supported notify type. example: 'http' + PayloadFormatType: + type: string + description: The type of webhook paylod format. + example: 'CloudEvents' + PayloadFormat: + type: object + description: Webhook supported payload format type collections. + properties: + notify_type: + $ref: '#/definitions/NotifyType' + formats: + type: array + description: The supported payload formats for this notify type. + items: + $ref: '#/definitions/PayloadFormatType' WebhookTargetObject: type: object @@ -7683,6 +8757,9 @@ definitions: skip_cert_verify: type: boolean description: Whether or not to skip cert verify. + payload_format: + $ref: '#/definitions/PayloadFormatType' + description: The payload format of webhook, by default is Default for http type. WebhookPolicy: type: object description: The webhook policy object @@ -7778,33 +8855,27 @@ definitions: format: date-time InternalConfigurationsResponse: type: object + additionalProperties: + $ref: '#/definitions/InternalConfigurationValue' + InternalConfigurationValue: + type: object + properties: + value: + type: object + description: The value of current config item + editable: + type: boolean + x-omitempty: false + description: The configure item can be updated or not ConfigurationsResponse: type: object properties: auth_mode: $ref: '#/definitions/StringConfigItem' description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" - email_from: - $ref: '#/definitions/StringConfigItem' - description: The sender name for Email notification. - email_host: - $ref: '#/definitions/StringConfigItem' - description: The hostname of SMTP server that sends Email notification. - email_identity: - $ref: '#/definitions/StringConfigItem' - description: By default it's empty so the email_username is picked - email_insecure: - $ref: '#/definitions/BoolConfigItem' - description: Whether or not the certificate will be verified when Harbor tries to access the email server. - email_port: - $ref: '#/definitions/IntegerConfigItem' - description: The port of SMTP server - email_ssl: + primary_auth_mode: $ref: '#/definitions/BoolConfigItem' - description: When it''s set to true the system will access Email server via TLS by default. If it''s set to false, it still will handle "STARTTLS" from server side. - email_username: - $ref: '#/definitions/StringConfigItem' - description: The username for authenticate against SMTP server + description: The flag to indicate whether the current auth mode should consider as a primary one. ldap_base_dn: $ref: '#/definitions/StringConfigItem' description: The Base DN for LDAP binding. @@ -7907,6 +8978,9 @@ definitions: oidc_admin_group: $ref: '#/definitions/StringConfigItem' description: The OIDC group which has the harbor admin privileges + oidc_group_filter: + $ref: '#/definitions/StringConfigItem' + description: The OIDC group filter which filters out the group doesn't match the regular expression oidc_scope: $ref: '#/definitions/StringConfigItem' description: The scope of the OIDC provider @@ -7937,6 +9011,15 @@ definitions: storage_per_project: $ref: '#/definitions/IntegerConfigItem' description: The storage quota per project + audit_log_forward_endpoint: + $ref: '#/definitions/StringConfigItem' + description: The endpoint of the audit log forwarder + skip_audit_log_database: + $ref: '#/definitions/BoolConfigItem' + description: Whether skip the audit log in database + scanner_skip_update_pulltime: + $ref: '#/definitions/BoolConfigItem' + description: Whether or not to skip update the pull time for scanner scan_all_policy: type: object properties: @@ -7949,37 +9032,318 @@ definitions: daily_time: type: integer description: 'The offset in seconds of UTC 0 o''clock, only valid when the policy type is "daily"' - description: 'The parameters of the policy, the values are dependant on the type of the policy.' + description: 'The parameters of the policy, the values are dependent on the type of the policy.' + session_timeout: + $ref: '#/definitions/IntegerConfigItem' + description: The session timeout in minutes + banner_message: + $ref: '#/definitions/StringConfigItem' + description: The banner message for the UI.It is the stringified result of the banner message object Configurations: type: object - additionalProperties: - type: object + properties: + auth_mode: + type: string + description: The auth mode of current system, such as "db_auth", "ldap_auth", "oidc_auth" + x-omitempty: true + x-isnullable: true + primary_auth_mode: + type: boolean + x-nullable: true + x-omitempty: true + description: The flag to indicate whether the current auth mode should consider as a primary one. + ldap_base_dn: + type: string + description: The Base DN for LDAP binding. + x-omitempty: true + x-isnullable: true + ldap_filter: + type: string + description: The filter for LDAP search + x-omitempty: true + x-isnullable: true + ldap_group_base_dn: + type: string + description: The base DN to search LDAP group. + x-omitempty: true + x-isnullable: true + ldap_group_admin_dn: + type: string + description: Specify the ldap group which have the same privilege with Harbor admin + x-omitempty: true + x-isnullable: true + ldap_group_attribute_name: + type: string + description: The attribute which is used as identity of the LDAP group, default is cn.' + x-omitempty: true + x-isnullable: true + ldap_group_search_filter: + type: string + description: The filter to search the ldap group + x-omitempty: true + x-isnullable: true + ldap_group_search_scope: + type: integer + description: The scope to search ldap group. ''0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE'' + x-omitempty: true + x-isnullable: true + ldap_scope: + type: integer + description: The scope to search ldap users,'0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE' + x-omitempty: true + x-isnullable: true + ldap_search_dn: + type: string + description: The DN of the user to do the search. + x-omitempty: true + x-isnullable: true + ldap_search_password: + type: string + description: The password of the ldap search dn + x-omitempty: true + x-isnullable: true + ldap_timeout: + type: integer + description: Timeout in seconds for connection to LDAP server + x-omitempty: true + x-isnullable: true + ldap_uid: + type: string + description: The attribute which is used as identity for the LDAP binding, such as "CN" or "SAMAccountname" + x-omitempty: true + x-isnullable: true + ldap_url: + type: string + description: The URL of LDAP server + x-omitempty: true + x-isnullable: true + ldap_verify_cert: + type: boolean + description: Whether verify your OIDC server certificate, disable it if your OIDC server is hosted via self-hosted certificate. + x-omitempty: true + x-isnullable: true + ldap_group_membership_attribute: + type: string + description: The user attribute to identify the group membership + x-omitempty: true + x-isnullable: true + project_creation_restriction: + type: string + description: Indicate who can create projects, it could be ''adminonly'' or ''everyone''. + x-omitempty: true + x-isnullable: true + read_only: + type: boolean + description: The flag to indicate whether Harbor is in readonly mode. + x-omitempty: true + x-isnullable: true + self_registration: + type: boolean + description: Whether the Harbor instance supports self-registration. If it''s set to false, admin need to add user to the instance. + x-omitempty: true + x-isnullable: true + token_expiration: + type: integer + description: The expiration time of the token for internal Registry, in minutes. + x-omitempty: true + x-isnullable: true + uaa_client_id: + type: string + description: The client id of UAA + x-omitempty: true + x-isnullable: true + uaa_client_secret: + type: string + description: The client secret of the UAA + x-omitempty: true + x-isnullable: true + uaa_endpoint: + type: string + description: The endpoint of the UAA + x-omitempty: true + x-isnullable: true + uaa_verify_cert: + type: boolean + description: Verify the certificate in UAA server + x-omitempty: true + x-isnullable: true + http_authproxy_endpoint: + type: string + description: The endpoint of the HTTP auth + x-omitempty: true + x-isnullable: true + http_authproxy_tokenreview_endpoint: + type: string + description: The token review endpoint + x-omitempty: true + x-isnullable: true + http_authproxy_admin_groups: + type: string + description: The group which has the harbor admin privileges + x-omitempty: true + x-isnullable: true + http_authproxy_admin_usernames: + type: string + description: The username which has the harbor admin privileges + x-omitempty: true + x-isnullable: true + http_authproxy_verify_cert: + type: boolean + description: Verify the HTTP auth provider's certificate + x-omitempty: true + x-isnullable: true + http_authproxy_skip_search: + type: boolean + description: Search user before onboard + x-omitempty: true + x-isnullable: true + http_authproxy_server_certificate: + type: string + description: The certificate of the HTTP auth provider + x-omitempty: true + x-isnullable: true + oidc_name: + type: string + description: The OIDC provider name + x-omitempty: true + x-isnullable: true + oidc_endpoint: + type: string + description: The endpoint of the OIDC provider + x-omitempty: true + x-isnullable: true + oidc_client_id: + type: string + description: The client ID of the OIDC provider + x-omitempty: true + x-isnullable: true + oidc_client_secret: + type: string + description: The OIDC provider secret + x-omitempty: true + x-isnullable: true + oidc_groups_claim: + type: string + description: The attribute claims the group name + x-omitempty: true + x-isnullable: true + oidc_admin_group: + type: string + description: The OIDC group which has the harbor admin privileges + x-omitempty: true + x-isnullable: true + oidc_group_filter: + type: string + description: The OIDC group filter which filters out the group name doesn't match the regular expression + x-omitempty: true + x-isnullable: true + oidc_scope: + type: string + description: The scope of the OIDC provider + x-omitempty: true + x-isnullable: true + oidc_user_claim: + type: string + description: The attribute claims the username + x-omitempty: true + x-isnullable: true + oidc_verify_cert: + type: boolean + description: Verify the OIDC provider's certificate' + x-omitempty: true + x-isnullable: true + oidc_auto_onboard: + type: boolean + description: Auto onboard the OIDC user + x-omitempty: true + x-isnullable: true + oidc_extra_redirect_parms: + type: string + description: Extra parameters to add when redirect request to OIDC provider + x-omitempty: true + x-isnullable: true + robot_token_duration: + type: integer + description: The robot account token duration in days + x-omitempty: true + x-isnullable: true + robot_name_prefix: + type: string + description: The rebot account name prefix + x-omitempty: true + x-isnullable: true + notification_enable: + type: boolean + description: Enable notification + x-omitempty: true + x-isnullable: true + quota_per_project_enable: + type: boolean + description: Enable quota per project + x-omitempty: true + x-isnullable: true + storage_per_project: + type: integer + description: The storage quota per project + x-omitempty: true + x-isnullable: true + audit_log_forward_endpoint: + type: string + description: The audit log forward endpoint + x-omitempty: true + x-isnullable: true + skip_audit_log_database: + type: boolean + description: Skip audit log database + x-omitempty: true + x-isnullable: true + session_timeout: + type: integer + description: The session timeout for harbor, in minutes. + x-omitempty: true + x-isnullable: true + scanner_skip_update_pulltime: + type: boolean + description: Whether or not to skip update pull time for scanner + x-omitempty: true + x-isnullable: true + banner_message: + type: string + description: The banner message for the UI.It is the stringified result of the banner message object + x-omitempty: true + x-isnullable: true StringConfigItem: type: object properties: value: type: string + x-omitempty: false description: The string value of current config item editable: type: boolean + x-omitempty: false description: The configure item can be updated or not BoolConfigItem: type: object properties: value: type: boolean + x-omitempty: false description: The boolean value of current config item editable: type: boolean + x-omitempty: false description: The configure item can be updated or not IntegerConfigItem: type: object properties: value: type: integer + x-omitempty: false description: The integer value of current config item editable: type: boolean + x-omitempty: false description: The configure item can be updated or not ProjectMemberEntity: type: object @@ -8044,6 +9408,7 @@ definitions: properties: email: type: string + maxLength: 255 realname: type: string comment: @@ -8052,6 +9417,7 @@ definitions: type: string username: type: string + maxLength: 255 OIDCUserInfo: type: object properties: @@ -8150,6 +9516,19 @@ definitions: action: type: string description: The permission action + Permissions: + type: object + properties: + system: + type: array + description: The system level permissions + items: + $ref: '#/definitions/Permission' + project: + type: array + description: The project level permissions + items: + $ref: '#/definitions/Permission' OIDCCliSecretReq: type: object properties: @@ -8176,7 +9555,7 @@ definitions: description: The component name status: type: string - description: The health status of component + description: The health status of component. Is either "healthy" or "unhealthy". error: type: string description: (optional) The error message when the status is "unhealthy" @@ -8218,3 +9597,410 @@ definitions: format: int64 description: The total storage consumption of blobs, only be seen by the system admin x-omitempty: false + Accessory: + type: object + description: 'The accessory of the artifact' + properties: + id: + type: integer + format: int64 + description: The ID of the accessory + artifact_id: + type: integer + format: int64 + description: The artifact id of the accessory + x-omitempty: false + subject_artifact_id: + type: integer + format: int64 + description: Going to be deprecated, use repo and digest for insteand. The subject artifact id of the accessory. + subject_artifact_digest: + type: string + description: The subject artifact digest of the accessory + x-omitempty: false + subject_artifact_repo: + type: string + description: The subject artifact repository name of the accessory + x-omitempty: false + size: + type: integer + format: int64 + description: The artifact size of the accessory + x-omitempty: false + digest: + type: string + description: The artifact digest of the accessory + x-omitempty: false + type: + type: string + description: The artifact size of the accessory + x-omitempty: false + icon: + type: string + description: The icon of the accessory + x-omitempty: false + creation_time: + type: string + format: date-time + description: The creation time of the accessory + + ScanDataExportRequest: + type: object + description: The criteria to select the scan data to export. + properties: + job_name: + type: string + description: Name of the scan data export job + projects: + type: array + items: + type: integer + format: int64 + description: A list of one or more projects for which to export the scan data, currently only one project is supported due to performance concerns, but define as array for extension in the future. + labels: + type: array + items: + type: integer + format: int64 + description: A list of one or more labels for which to export the scan data, defaults to all if empty + repositories: + type: string + description: A list of repositories for which to export the scan data, defaults to all if empty + cveIds: + type: string + description: CVE-IDs for which to export data. Multiple CVE-IDs can be specified by separating using ',' and enclosed between '{}'. Defaults to all if empty + tags: + type: string + description: A list of tags enclosed within '{}'. Defaults to all if empty + ScanDataExportJob: + type: object + description: The metadata associated with the scan data export job + properties: + id: + type: integer + format: int64 + description: The id of the scan data export job + ScanDataExportExecution: + type: object + description: The replication execution + properties: + id: + type: integer + description: The ID of the execution + user_id: + type: integer + description: The ID if the user triggering the export job + status: + type: string + description: The status of the execution + trigger: + type: string + description: The trigger mode + start_time: + type: string + format: date-time + description: The start time + end_time: + type: string + format: date-time + description: The end time + status_text: + type: string + x-omitempty: false + description: The status text + user_name: + type: string + x-omitempty: false + description: The name of the user triggering the job + file_present: + type: boolean + x-omitempty: false + description: Indicates whether the export artifact is present in registry + ScanDataExportExecutionList: + type: object + description: The list of scan data export executions + properties: + items: + type: array + items: + $ref: '#/definitions/ScanDataExportExecution' + description: The list of scan data export executions + + WorkerPool: + type: object + description: the worker pool of job service + properties: + pid: + type: integer + description: the process id of jobservice + worker_pool_id: + type: string + description: the id of the worker pool + start_at: + type: string + format: date-time + description: The start time of the work pool + heartbeat_at: + type: string + format: date-time + description: The heartbeat time of the work pool + concurrency: + type: integer + description: The concurrency of the work pool + host: + type: string + description: The host of the work pool + Worker: + type: object + description: worker in the pool + properties: + id: + type: string + description: the id of the worker + pool_id: + type: string + description: the id of the worker pool + job_name: + type: string + description: the name of the running job in the worker + job_id: + type: string + description: the id of the running job in the worker + start_at: + type: string + format: date-time + description: The start time of the worker + x-nullable: true + x-omitempty: true + check_in: + type: string + description: the checkin of the running job in the worker + checkin_at: + type: string + format: date-time + description: The checkin time of the worker + x-nullable: true + x-omitempty: true + ActionRequest: + type: object + description: The request to stop, pause or resume + properties: + action: + type: string + description: The action of the request, should be stop, pause or resume + enum: + - stop + - pause + - resume + JobQueue: + type: object + description: the job queue info + properties: + job_type: + type: string + description: The type of the job queue + count: + type: integer + description: The count of jobs in the job queue + latency: + type: integer + description: The latency the job queue (seconds) + paused: + type: boolean + description: The paused status of the job queue + x-omitempty: false + ScheduleTask: + type: object + description: the schedule task info + properties: + id: + type: integer + description: the id of the Schedule task + vendor_type: + type: string + description: the vendor type of the current schedule task + vendor_id: + type: integer + description: the vendor id of the current task + cron: + type: string + description: the cron of the current schedule task + update_time: + type: string + format: date-time + description: the update time of the schedule task + SchedulerStatus: + type: object + description: the scheduler status + properties: + paused: + type: boolean + description: if the scheduler is paused + x-omitempty: false + SecuritySummary: + type: object + description: the security summary + properties: + critical_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of critical vulnerabilities + high_cnt: + type: integer + format: int64 + description: the count of high vulnerabilities + medium_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of medium vulnerabilities + low_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of low vulnerabilities + none_cnt: + type: integer + format: int64 + description: the count of none vulnerabilities + unknown_cnt: + type: integer + format: int64 + description: the count of unknown vulnerabilities + total_vuls: + type: integer + format: int64 + x-omitempty: false + description: the count of total vulnerabilities + scanned_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of scanned artifacts + total_artifact: + type: integer + format: int64 + x-omitempty: false + description: the total count of artifacts + fixable_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of fixable vulnerabilities + dangerous_cves: + type: array + x-omitempty: true + description: the list of dangerous CVEs + items: + $ref: '#/definitions/DangerousCVE' + dangerous_artifacts: + type: array + x-omitempty: true + description: the list of dangerous artifacts + items: + $ref: '#/definitions/DangerousArtifact' + DangerousCVE: + type: object + description: the dangerous CVE information + properties: + cve_id: + type: string + description: the cve id + severity: + type: string + description: the severity of the CVE + cvss_score_v3: + type: number + format: float64 + description: the cvss score v3 + desc: + type: string + description: the description of the CVE + package: + type: string + description: the package of the CVE + version: + type: string + description: the version of the package + DangerousArtifact: + type: object + description: the dangerous artifact information + properties: + project_id: + type: integer + format: int64 + description: the project id of the artifact + repository_name: + type: string + description: the repository name of the artifact + digest: + type: string + description: the digest of the artifact + critical_cnt: + type: integer + x-omitempty: false + description: the count of critical vulnerabilities + high_cnt: + type: integer + format: int64 + x-omitempty: false + description: the count of high vulnerabilities + medium_cnt: + type: integer + x-omitempty: false + description: the count of medium vulnerabilities + + VulnerabilityItem: + type: object + description: the vulnerability item info + properties: + project_id: + type: integer + format: int64 + description: the project ID of the artifact + repository_name: + type: string + description: the repository name of the artifact + digest: + type: string + description: the digest of the artifact + tags: + type: array + items: + type: string + description: the tags of the artifact + cve_id: + type: string + description: the CVE id of the vulnerability. + severity: + type: string + description: the severity of the vulnerability + cvss_v3_score: + type: number + format: float + description: the nvd cvss v3 score of the vulnerability + package: + type: string + description: the package of the vulnerability + version: + type: string + description: the version of the package + fixed_version: + type: string + description: the fixed version of the package + desc: + type: string + description: The description of the vulnerability + links: + type: array + items: + type: string + description: Links of the vulnerability + ScanType: + type: object + properties: + scan_type: + type: string + description: 'The scan type for the scan request. Two options are currently supported, vulnerability and sbom' + enum: [ vulnerability, sbom ] diff --git a/pkg/module/project.go b/pkg/module/project.go index d760f40..09b28b4 100644 --- a/pkg/module/project.go +++ b/pkg/module/project.go @@ -110,7 +110,7 @@ func (h *Harbor) DeleteAllProjects(excludeProjects []string) { } }() - h.DeleteProject(project.Name, rt.ToValue(project.RepoCount+project.ChartCount > 0)) + h.DeleteProject(project.Name, rt.ToValue(project.RepoCount > 0)) deleted++ }() }