diff --git a/power/client/power_iaas_api_client.go b/power/client/power_iaas_api_client.go index cbd707d0..43c7c298 100644 --- a/power/client/power_iaas_api_client.go +++ b/power/client/power_iaas_api_client.go @@ -51,6 +51,7 @@ import ( "github.com/IBM-Cloud/power-go-client/power/client/power_edge_router" "github.com/IBM-Cloud/power-go-client/power/client/service_bindings" "github.com/IBM-Cloud/power-go-client/power/client/service_instances" + "github.com/IBM-Cloud/power-go-client/power/client/snapshots" "github.com/IBM-Cloud/power-go-client/power/client/storage_types" "github.com/IBM-Cloud/power-go-client/power/client/swagger_spec" "github.com/IBM-Cloud/power-go-client/power/client/workspaces" @@ -139,6 +140,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *PowerIaasA cli.PowerEdgeRouter = power_edge_router.New(transport, formats) cli.ServiceBindings = service_bindings.New(transport, formats) cli.ServiceInstances = service_instances.New(transport, formats) + cli.Snapshots = snapshots.New(transport, formats) cli.StorageTypes = storage_types.New(transport, formats) cli.SwaggerSpec = swagger_spec.New(transport, formats) cli.Workspaces = workspaces.New(transport, formats) @@ -268,6 +270,8 @@ type PowerIaasAPI struct { ServiceInstances service_instances.ClientService + Snapshots snapshots.ClientService + StorageTypes storage_types.ClientService SwaggerSpec swagger_spec.ClientService @@ -321,6 +325,7 @@ func (c *PowerIaasAPI) SetTransport(transport runtime.ClientTransport) { c.PowerEdgeRouter.SetTransport(transport) c.ServiceBindings.SetTransport(transport) c.ServiceInstances.SetTransport(transport) + c.Snapshots.SetTransport(transport) c.StorageTypes.SetTransport(transport) c.SwaggerSpec.SetTransport(transport) c.Workspaces.SetTransport(transport) diff --git a/power/client/snapshots/snapshots_client.go b/power/client/snapshots/snapshots_client.go new file mode 100644 index 00000000..3ad1d9fc --- /dev/null +++ b/power/client/snapshots/snapshots_client.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// New creates a new snapshots API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +// New creates a new snapshots API client with basic auth credentials. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - user: user for basic authentication header. +// - password: password for basic authentication header. +func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BasicAuth(user, password) + return &Client{transport: transport, formats: strfmt.Default} +} + +// New creates a new snapshots API client with a bearer token for authentication. +// It takes the following parameters: +// - host: http host (github.com). +// - basePath: any base path for the API client ("/v1", "/v3"). +// - scheme: http scheme ("http", "https"). +// - bearerToken: bearer token for Bearer authentication header. +func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { + transport := httptransport.New(host, basePath, []string{scheme}) + transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) + return &Client{transport: transport, formats: strfmt.Default} +} + +/* +Client for snapshots API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption may be used to customize the behavior of Client methods. +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + V1SnapshotsGet(params *V1SnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetOK, error) + + V1SnapshotsGetall(params *V1SnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetallOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +V1SnapshotsGet gets the detail of a snapshot +*/ +func (a *Client) V1SnapshotsGet(params *V1SnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewV1SnapshotsGetParams() + } + op := &runtime.ClientOperation{ + ID: "v1.snapshots.get", + Method: "GET", + PathPattern: "/v1/snapshots/{snapshot_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &V1SnapshotsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*V1SnapshotsGetOK) + if ok { + return success, nil + } + // unexpected success response + // 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 v1.snapshots.get: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +V1SnapshotsGetall gets a list of all the snapshots on a workspace +*/ +func (a *Client) V1SnapshotsGetall(params *V1SnapshotsGetallParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*V1SnapshotsGetallOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewV1SnapshotsGetallParams() + } + op := &runtime.ClientOperation{ + ID: "v1.snapshots.getall", + Method: "GET", + PathPattern: "/v1/snapshots", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &V1SnapshotsGetallReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*V1SnapshotsGetallOK) + if ok { + return success, nil + } + // unexpected success response + // 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 v1.snapshots.getall: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/power/client/snapshots/v1_snapshots_get_parameters.go b/power/client/snapshots/v1_snapshots_get_parameters.go new file mode 100644 index 00000000..9777373d --- /dev/null +++ b/power/client/snapshots/v1_snapshots_get_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package snapshots + +// 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" +) + +// NewV1SnapshotsGetParams creates a new V1SnapshotsGetParams 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 NewV1SnapshotsGetParams() *V1SnapshotsGetParams { + return &V1SnapshotsGetParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewV1SnapshotsGetParamsWithTimeout creates a new V1SnapshotsGetParams object +// with the ability to set a timeout on a request. +func NewV1SnapshotsGetParamsWithTimeout(timeout time.Duration) *V1SnapshotsGetParams { + return &V1SnapshotsGetParams{ + timeout: timeout, + } +} + +// NewV1SnapshotsGetParamsWithContext creates a new V1SnapshotsGetParams object +// with the ability to set a context for a request. +func NewV1SnapshotsGetParamsWithContext(ctx context.Context) *V1SnapshotsGetParams { + return &V1SnapshotsGetParams{ + Context: ctx, + } +} + +// NewV1SnapshotsGetParamsWithHTTPClient creates a new V1SnapshotsGetParams object +// with the ability to set a custom HTTPClient for a request. +func NewV1SnapshotsGetParamsWithHTTPClient(client *http.Client) *V1SnapshotsGetParams { + return &V1SnapshotsGetParams{ + HTTPClient: client, + } +} + +/* +V1SnapshotsGetParams contains all the parameters to send to the API endpoint + + for the v1 snapshots get operation. + + Typically these are written to a http.Request. +*/ +type V1SnapshotsGetParams struct { + + /* SnapshotID. + + PVM Instance snapshot id + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the v1 snapshots get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *V1SnapshotsGetParams) WithDefaults() *V1SnapshotsGetParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the v1 snapshots get params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *V1SnapshotsGetParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the v1 snapshots get params +func (o *V1SnapshotsGetParams) WithTimeout(timeout time.Duration) *V1SnapshotsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the v1 snapshots get params +func (o *V1SnapshotsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the v1 snapshots get params +func (o *V1SnapshotsGetParams) WithContext(ctx context.Context) *V1SnapshotsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the v1 snapshots get params +func (o *V1SnapshotsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the v1 snapshots get params +func (o *V1SnapshotsGetParams) WithHTTPClient(client *http.Client) *V1SnapshotsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the v1 snapshots get params +func (o *V1SnapshotsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSnapshotID adds the snapshotID to the v1 snapshots get params +func (o *V1SnapshotsGetParams) WithSnapshotID(snapshotID string) *V1SnapshotsGetParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the v1 snapshots get params +func (o *V1SnapshotsGetParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *V1SnapshotsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param snapshot_id + if err := r.SetPathParam("snapshot_id", o.SnapshotID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/power/client/snapshots/v1_snapshots_get_responses.go b/power/client/snapshots/v1_snapshots_get_responses.go new file mode 100644 index 00000000..576e0c59 --- /dev/null +++ b/power/client/snapshots/v1_snapshots_get_responses.go @@ -0,0 +1,486 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// V1SnapshotsGetReader is a Reader for the V1SnapshotsGet structure. +type V1SnapshotsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *V1SnapshotsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewV1SnapshotsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewV1SnapshotsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewV1SnapshotsGetUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewV1SnapshotsGetForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewV1SnapshotsGetNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewV1SnapshotsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /v1/snapshots/{snapshot_id}] v1.snapshots.get", response, response.Code()) + } +} + +// NewV1SnapshotsGetOK creates a V1SnapshotsGetOK with default headers values +func NewV1SnapshotsGetOK() *V1SnapshotsGetOK { + return &V1SnapshotsGetOK{} +} + +/* +V1SnapshotsGetOK describes a response with status code 200, with default header values. + +OK +*/ +type V1SnapshotsGetOK struct { + Payload *models.SnapshotV1 +} + +// IsSuccess returns true when this v1 snapshots get o k response has a 2xx status code +func (o *V1SnapshotsGetOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this v1 snapshots get o k response has a 3xx status code +func (o *V1SnapshotsGetOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get o k response has a 4xx status code +func (o *V1SnapshotsGetOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this v1 snapshots get o k response has a 5xx status code +func (o *V1SnapshotsGetOK) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots get o k response a status code equal to that given +func (o *V1SnapshotsGetOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the v1 snapshots get o k response +func (o *V1SnapshotsGetOK) Code() int { + return 200 +} + +func (o *V1SnapshotsGetOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetOK %s", 200, payload) +} + +func (o *V1SnapshotsGetOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetOK %s", 200, payload) +} + +func (o *V1SnapshotsGetOK) GetPayload() *models.SnapshotV1 { + return o.Payload +} + +func (o *V1SnapshotsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SnapshotV1) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetBadRequest creates a V1SnapshotsGetBadRequest with default headers values +func NewV1SnapshotsGetBadRequest() *V1SnapshotsGetBadRequest { + return &V1SnapshotsGetBadRequest{} +} + +/* +V1SnapshotsGetBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type V1SnapshotsGetBadRequest struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots get bad request response has a 2xx status code +func (o *V1SnapshotsGetBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots get bad request response has a 3xx status code +func (o *V1SnapshotsGetBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get bad request response has a 4xx status code +func (o *V1SnapshotsGetBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots get bad request response has a 5xx status code +func (o *V1SnapshotsGetBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots get bad request response a status code equal to that given +func (o *V1SnapshotsGetBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the v1 snapshots get bad request response +func (o *V1SnapshotsGetBadRequest) Code() int { + return 400 +} + +func (o *V1SnapshotsGetBadRequest) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetBadRequest %s", 400, payload) +} + +func (o *V1SnapshotsGetBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetBadRequest %s", 400, payload) +} + +func (o *V1SnapshotsGetBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetUnauthorized creates a V1SnapshotsGetUnauthorized with default headers values +func NewV1SnapshotsGetUnauthorized() *V1SnapshotsGetUnauthorized { + return &V1SnapshotsGetUnauthorized{} +} + +/* +V1SnapshotsGetUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type V1SnapshotsGetUnauthorized struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots get unauthorized response has a 2xx status code +func (o *V1SnapshotsGetUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots get unauthorized response has a 3xx status code +func (o *V1SnapshotsGetUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get unauthorized response has a 4xx status code +func (o *V1SnapshotsGetUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots get unauthorized response has a 5xx status code +func (o *V1SnapshotsGetUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots get unauthorized response a status code equal to that given +func (o *V1SnapshotsGetUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the v1 snapshots get unauthorized response +func (o *V1SnapshotsGetUnauthorized) Code() int { + return 401 +} + +func (o *V1SnapshotsGetUnauthorized) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetUnauthorized %s", 401, payload) +} + +func (o *V1SnapshotsGetUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetUnauthorized %s", 401, payload) +} + +func (o *V1SnapshotsGetUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetForbidden creates a V1SnapshotsGetForbidden with default headers values +func NewV1SnapshotsGetForbidden() *V1SnapshotsGetForbidden { + return &V1SnapshotsGetForbidden{} +} + +/* +V1SnapshotsGetForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type V1SnapshotsGetForbidden struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots get forbidden response has a 2xx status code +func (o *V1SnapshotsGetForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots get forbidden response has a 3xx status code +func (o *V1SnapshotsGetForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get forbidden response has a 4xx status code +func (o *V1SnapshotsGetForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots get forbidden response has a 5xx status code +func (o *V1SnapshotsGetForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots get forbidden response a status code equal to that given +func (o *V1SnapshotsGetForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the v1 snapshots get forbidden response +func (o *V1SnapshotsGetForbidden) Code() int { + return 403 +} + +func (o *V1SnapshotsGetForbidden) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetForbidden %s", 403, payload) +} + +func (o *V1SnapshotsGetForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetForbidden %s", 403, payload) +} + +func (o *V1SnapshotsGetForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetNotFound creates a V1SnapshotsGetNotFound with default headers values +func NewV1SnapshotsGetNotFound() *V1SnapshotsGetNotFound { + return &V1SnapshotsGetNotFound{} +} + +/* +V1SnapshotsGetNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type V1SnapshotsGetNotFound struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots get not found response has a 2xx status code +func (o *V1SnapshotsGetNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots get not found response has a 3xx status code +func (o *V1SnapshotsGetNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get not found response has a 4xx status code +func (o *V1SnapshotsGetNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots get not found response has a 5xx status code +func (o *V1SnapshotsGetNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots get not found response a status code equal to that given +func (o *V1SnapshotsGetNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the v1 snapshots get not found response +func (o *V1SnapshotsGetNotFound) Code() int { + return 404 +} + +func (o *V1SnapshotsGetNotFound) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetNotFound %s", 404, payload) +} + +func (o *V1SnapshotsGetNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetNotFound %s", 404, payload) +} + +func (o *V1SnapshotsGetNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetInternalServerError creates a V1SnapshotsGetInternalServerError with default headers values +func NewV1SnapshotsGetInternalServerError() *V1SnapshotsGetInternalServerError { + return &V1SnapshotsGetInternalServerError{} +} + +/* +V1SnapshotsGetInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type V1SnapshotsGetInternalServerError struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots get internal server error response has a 2xx status code +func (o *V1SnapshotsGetInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots get internal server error response has a 3xx status code +func (o *V1SnapshotsGetInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots get internal server error response has a 4xx status code +func (o *V1SnapshotsGetInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this v1 snapshots get internal server error response has a 5xx status code +func (o *V1SnapshotsGetInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this v1 snapshots get internal server error response a status code equal to that given +func (o *V1SnapshotsGetInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the v1 snapshots get internal server error response +func (o *V1SnapshotsGetInternalServerError) Code() int { + return 500 +} + +func (o *V1SnapshotsGetInternalServerError) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetInternalServerError %s", 500, payload) +} + +func (o *V1SnapshotsGetInternalServerError) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots/{snapshot_id}][%d] v1SnapshotsGetInternalServerError %s", 500, payload) +} + +func (o *V1SnapshotsGetInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/power/client/snapshots/v1_snapshots_getall_parameters.go b/power/client/snapshots/v1_snapshots_getall_parameters.go new file mode 100644 index 00000000..99063ef1 --- /dev/null +++ b/power/client/snapshots/v1_snapshots_getall_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package snapshots + +// 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" +) + +// NewV1SnapshotsGetallParams creates a new V1SnapshotsGetallParams 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 NewV1SnapshotsGetallParams() *V1SnapshotsGetallParams { + return &V1SnapshotsGetallParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewV1SnapshotsGetallParamsWithTimeout creates a new V1SnapshotsGetallParams object +// with the ability to set a timeout on a request. +func NewV1SnapshotsGetallParamsWithTimeout(timeout time.Duration) *V1SnapshotsGetallParams { + return &V1SnapshotsGetallParams{ + timeout: timeout, + } +} + +// NewV1SnapshotsGetallParamsWithContext creates a new V1SnapshotsGetallParams object +// with the ability to set a context for a request. +func NewV1SnapshotsGetallParamsWithContext(ctx context.Context) *V1SnapshotsGetallParams { + return &V1SnapshotsGetallParams{ + Context: ctx, + } +} + +// NewV1SnapshotsGetallParamsWithHTTPClient creates a new V1SnapshotsGetallParams object +// with the ability to set a custom HTTPClient for a request. +func NewV1SnapshotsGetallParamsWithHTTPClient(client *http.Client) *V1SnapshotsGetallParams { + return &V1SnapshotsGetallParams{ + HTTPClient: client, + } +} + +/* +V1SnapshotsGetallParams contains all the parameters to send to the API endpoint + + for the v1 snapshots getall operation. + + Typically these are written to a http.Request. +*/ +type V1SnapshotsGetallParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the v1 snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *V1SnapshotsGetallParams) WithDefaults() *V1SnapshotsGetallParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the v1 snapshots getall params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *V1SnapshotsGetallParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) WithTimeout(timeout time.Duration) *V1SnapshotsGetallParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) WithContext(ctx context.Context) *V1SnapshotsGetallParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) WithHTTPClient(client *http.Client) *V1SnapshotsGetallParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the v1 snapshots getall params +func (o *V1SnapshotsGetallParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *V1SnapshotsGetallParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/power/client/snapshots/v1_snapshots_getall_responses.go b/power/client/snapshots/v1_snapshots_getall_responses.go new file mode 100644 index 00000000..36b8f3ee --- /dev/null +++ b/power/client/snapshots/v1_snapshots_getall_responses.go @@ -0,0 +1,410 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package snapshots + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/IBM-Cloud/power-go-client/power/models" +) + +// V1SnapshotsGetallReader is a Reader for the V1SnapshotsGetall structure. +type V1SnapshotsGetallReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *V1SnapshotsGetallReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewV1SnapshotsGetallOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewV1SnapshotsGetallUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewV1SnapshotsGetallForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewV1SnapshotsGetallNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewV1SnapshotsGetallInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /v1/snapshots] v1.snapshots.getall", response, response.Code()) + } +} + +// NewV1SnapshotsGetallOK creates a V1SnapshotsGetallOK with default headers values +func NewV1SnapshotsGetallOK() *V1SnapshotsGetallOK { + return &V1SnapshotsGetallOK{} +} + +/* +V1SnapshotsGetallOK describes a response with status code 200, with default header values. + +OK +*/ +type V1SnapshotsGetallOK struct { + Payload *models.SnapshotList +} + +// IsSuccess returns true when this v1 snapshots getall o k response has a 2xx status code +func (o *V1SnapshotsGetallOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this v1 snapshots getall o k response has a 3xx status code +func (o *V1SnapshotsGetallOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots getall o k response has a 4xx status code +func (o *V1SnapshotsGetallOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this v1 snapshots getall o k response has a 5xx status code +func (o *V1SnapshotsGetallOK) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots getall o k response a status code equal to that given +func (o *V1SnapshotsGetallOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the v1 snapshots getall o k response +func (o *V1SnapshotsGetallOK) Code() int { + return 200 +} + +func (o *V1SnapshotsGetallOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallOK %s", 200, payload) +} + +func (o *V1SnapshotsGetallOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallOK %s", 200, payload) +} + +func (o *V1SnapshotsGetallOK) GetPayload() *models.SnapshotList { + return o.Payload +} + +func (o *V1SnapshotsGetallOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.SnapshotList) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetallUnauthorized creates a V1SnapshotsGetallUnauthorized with default headers values +func NewV1SnapshotsGetallUnauthorized() *V1SnapshotsGetallUnauthorized { + return &V1SnapshotsGetallUnauthorized{} +} + +/* +V1SnapshotsGetallUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type V1SnapshotsGetallUnauthorized struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots getall unauthorized response has a 2xx status code +func (o *V1SnapshotsGetallUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots getall unauthorized response has a 3xx status code +func (o *V1SnapshotsGetallUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots getall unauthorized response has a 4xx status code +func (o *V1SnapshotsGetallUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots getall unauthorized response has a 5xx status code +func (o *V1SnapshotsGetallUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots getall unauthorized response a status code equal to that given +func (o *V1SnapshotsGetallUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the v1 snapshots getall unauthorized response +func (o *V1SnapshotsGetallUnauthorized) Code() int { + return 401 +} + +func (o *V1SnapshotsGetallUnauthorized) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallUnauthorized %s", 401, payload) +} + +func (o *V1SnapshotsGetallUnauthorized) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallUnauthorized %s", 401, payload) +} + +func (o *V1SnapshotsGetallUnauthorized) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetallUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetallForbidden creates a V1SnapshotsGetallForbidden with default headers values +func NewV1SnapshotsGetallForbidden() *V1SnapshotsGetallForbidden { + return &V1SnapshotsGetallForbidden{} +} + +/* +V1SnapshotsGetallForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type V1SnapshotsGetallForbidden struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots getall forbidden response has a 2xx status code +func (o *V1SnapshotsGetallForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots getall forbidden response has a 3xx status code +func (o *V1SnapshotsGetallForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots getall forbidden response has a 4xx status code +func (o *V1SnapshotsGetallForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots getall forbidden response has a 5xx status code +func (o *V1SnapshotsGetallForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots getall forbidden response a status code equal to that given +func (o *V1SnapshotsGetallForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the v1 snapshots getall forbidden response +func (o *V1SnapshotsGetallForbidden) Code() int { + return 403 +} + +func (o *V1SnapshotsGetallForbidden) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallForbidden %s", 403, payload) +} + +func (o *V1SnapshotsGetallForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallForbidden %s", 403, payload) +} + +func (o *V1SnapshotsGetallForbidden) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetallForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetallNotFound creates a V1SnapshotsGetallNotFound with default headers values +func NewV1SnapshotsGetallNotFound() *V1SnapshotsGetallNotFound { + return &V1SnapshotsGetallNotFound{} +} + +/* +V1SnapshotsGetallNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type V1SnapshotsGetallNotFound struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots getall not found response has a 2xx status code +func (o *V1SnapshotsGetallNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots getall not found response has a 3xx status code +func (o *V1SnapshotsGetallNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots getall not found response has a 4xx status code +func (o *V1SnapshotsGetallNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this v1 snapshots getall not found response has a 5xx status code +func (o *V1SnapshotsGetallNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this v1 snapshots getall not found response a status code equal to that given +func (o *V1SnapshotsGetallNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the v1 snapshots getall not found response +func (o *V1SnapshotsGetallNotFound) Code() int { + return 404 +} + +func (o *V1SnapshotsGetallNotFound) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallNotFound %s", 404, payload) +} + +func (o *V1SnapshotsGetallNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallNotFound %s", 404, payload) +} + +func (o *V1SnapshotsGetallNotFound) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetallNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewV1SnapshotsGetallInternalServerError creates a V1SnapshotsGetallInternalServerError with default headers values +func NewV1SnapshotsGetallInternalServerError() *V1SnapshotsGetallInternalServerError { + return &V1SnapshotsGetallInternalServerError{} +} + +/* +V1SnapshotsGetallInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type V1SnapshotsGetallInternalServerError struct { + Payload *models.Error +} + +// IsSuccess returns true when this v1 snapshots getall internal server error response has a 2xx status code +func (o *V1SnapshotsGetallInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this v1 snapshots getall internal server error response has a 3xx status code +func (o *V1SnapshotsGetallInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this v1 snapshots getall internal server error response has a 4xx status code +func (o *V1SnapshotsGetallInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this v1 snapshots getall internal server error response has a 5xx status code +func (o *V1SnapshotsGetallInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this v1 snapshots getall internal server error response a status code equal to that given +func (o *V1SnapshotsGetallInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the v1 snapshots getall internal server error response +func (o *V1SnapshotsGetallInternalServerError) Code() int { + return 500 +} + +func (o *V1SnapshotsGetallInternalServerError) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallInternalServerError %s", 500, payload) +} + +func (o *V1SnapshotsGetallInternalServerError) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /v1/snapshots][%d] v1SnapshotsGetallInternalServerError %s", 500, payload) +} + +func (o *V1SnapshotsGetallInternalServerError) GetPayload() *models.Error { + return o.Payload +} + +func (o *V1SnapshotsGetallInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/power/models/snapshot_list.go b/power/models/snapshot_list.go new file mode 100644 index 00000000..a1e6fd10 --- /dev/null +++ b/power/models/snapshot_list.go @@ -0,0 +1,124 @@ +// 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" + "github.com/go-openapi/validate" +) + +// SnapshotList snapshot list +// +// swagger:model SnapshotList +type SnapshotList struct { + + // The list of snapshots. + // Required: true + Snapshots []*SnapshotV1 `json:"snapshots"` +} + +// Validate validates this snapshot list +func (m *SnapshotList) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSnapshots(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotList) validateSnapshots(formats strfmt.Registry) error { + + if err := validate.Required("snapshots", "body", m.Snapshots); err != nil { + return err + } + + for i := 0; i < len(m.Snapshots); i++ { + if swag.IsZero(m.Snapshots[i]) { // not required + continue + } + + if m.Snapshots[i] != nil { + if err := m.Snapshots[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this snapshot list based on the context it is used +func (m *SnapshotList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSnapshots(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotList) contextValidateSnapshots(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Snapshots); i++ { + + if m.Snapshots[i] != nil { + + if swag.IsZero(m.Snapshots[i]) { // not required + return nil + } + + if err := m.Snapshots[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("snapshots" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotList) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotList) UnmarshalBinary(b []byte) error { + var res SnapshotList + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/power/models/snapshot_v1.go b/power/models/snapshot_v1.go new file mode 100644 index 00000000..2974fef6 --- /dev/null +++ b/power/models/snapshot_v1.go @@ -0,0 +1,179 @@ +// 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" +) + +// SnapshotV1 snapshot v1 +// +// swagger:model SnapshotV1 +type SnapshotV1 struct { + + // The date and time when the snapshot was created. + // Format: date-time + CreationDate strfmt.DateTime `json:"creationDate,omitempty"` + + // The snapshot UUID. + // Required: true + ID *string `json:"id"` + + // The snapshot name. + // Required: true + Name *string `json:"name"` + + // The size of the snapshot, in gibibytes (GiB). + // Required: true + Size *float64 `json:"size"` + + // The status for the snapshot. + // Required: true + Status *string `json:"status"` + + // The date and time when the snapshot was last updated. + // Format: date-time + UpdatedDate strfmt.DateTime `json:"updatedDate,omitempty"` + + // The volume UUID associated with the snapshot. + // Required: true + VolumeID *string `json:"volumeID"` +} + +// Validate validates this snapshot v1 +func (m *SnapshotV1) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreationDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdatedDate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumeID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotV1) validateCreationDate(formats strfmt.Registry) error { + if swag.IsZero(m.CreationDate) { // not required + return nil + } + + if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", m.Size); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateUpdatedDate(formats strfmt.Registry) error { + if swag.IsZero(m.UpdatedDate) { // not required + return nil + } + + if err := validate.FormatOf("updatedDate", "body", "date-time", m.UpdatedDate.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *SnapshotV1) validateVolumeID(formats strfmt.Registry) error { + + if err := validate.Required("volumeID", "body", m.VolumeID); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this snapshot v1 based on context it is used +func (m *SnapshotV1) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SnapshotV1) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SnapshotV1) UnmarshalBinary(b []byte) error { + var res SnapshotV1 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}