From 748a956ca1bde207e48961fcecb41777be27be1a Mon Sep 17 00:00:00 2001 From: surajsub Date: Wed, 11 Mar 2020 14:13:39 -0500 Subject: [PATCH 1/2] Updated the power-go-client --- .../p_cloud_snapshots_client.go | 33 +++- ...oudinstances_snapshots_delete_responses.go | 22 +-- ...cloudinstances_snapshots_get_parameters.go | 157 ++++++++++++++++++ ..._cloudinstances_snapshots_get_responses.go | 139 ++++++++++++++++ power/models/p_vm_instance_sys_type.go | 66 -------- power/models/snapshot.go | 9 +- power/models/snapshot_create_response.go | 17 -- version.go | 6 + 8 files changed, 350 insertions(+), 99 deletions(-) create mode 100644 power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go create mode 100644 power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go delete mode 100644 power/models/p_vm_instance_sys_type.go create mode 100644 version.go diff --git a/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go b/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go index e49914c3..654163d3 100644 --- a/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go +++ b/power/client/p_cloud_snapshots/p_cloud_snapshots_client.go @@ -27,7 +27,7 @@ type Client struct { /* PcloudCloudinstancesSnapshotsDelete deletes a p VM instance snapshot of a cloud instance */ -func (a *Client) PcloudCloudinstancesSnapshotsDelete(params *PcloudCloudinstancesSnapshotsDeleteParams, authInfo runtime.ClientAuthInfoWriter) (*PcloudCloudinstancesSnapshotsDeleteOK, error) { +func (a *Client) PcloudCloudinstancesSnapshotsDelete(params *PcloudCloudinstancesSnapshotsDeleteParams, authInfo runtime.ClientAuthInfoWriter) (*PcloudCloudinstancesSnapshotsDeleteAccepted, error) { // TODO: Validate the params before sending if params == nil { params = NewPcloudCloudinstancesSnapshotsDeleteParams() @@ -49,7 +49,36 @@ func (a *Client) PcloudCloudinstancesSnapshotsDelete(params *PcloudCloudinstance if err != nil { return nil, err } - return result.(*PcloudCloudinstancesSnapshotsDeleteOK), nil + return result.(*PcloudCloudinstancesSnapshotsDeleteAccepted), nil + +} + +/* +PcloudCloudinstancesSnapshotsGet gets the detail of a snapshot +*/ +func (a *Client) PcloudCloudinstancesSnapshotsGet(params *PcloudCloudinstancesSnapshotsGetParams, authInfo runtime.ClientAuthInfoWriter) (*PcloudCloudinstancesSnapshotsGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPcloudCloudinstancesSnapshotsGetParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "pcloud.cloudinstances.snapshots.get", + Method: "GET", + PathPattern: "/pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PcloudCloudinstancesSnapshotsGetReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*PcloudCloudinstancesSnapshotsGetOK), nil } diff --git a/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go index fee0f34d..d87794e5 100644 --- a/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go +++ b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_delete_responses.go @@ -25,8 +25,8 @@ type PcloudCloudinstancesSnapshotsDeleteReader struct { func (o *PcloudCloudinstancesSnapshotsDeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { - case 200: - result := NewPcloudCloudinstancesSnapshotsDeleteOK() + case 202: + result := NewPcloudCloudinstancesSnapshotsDeleteAccepted() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } @@ -58,24 +58,24 @@ func (o *PcloudCloudinstancesSnapshotsDeleteReader) ReadResponse(response runtim } } -// NewPcloudCloudinstancesSnapshotsDeleteOK creates a PcloudCloudinstancesSnapshotsDeleteOK with default headers values -func NewPcloudCloudinstancesSnapshotsDeleteOK() *PcloudCloudinstancesSnapshotsDeleteOK { - return &PcloudCloudinstancesSnapshotsDeleteOK{} +// NewPcloudCloudinstancesSnapshotsDeleteAccepted creates a PcloudCloudinstancesSnapshotsDeleteAccepted with default headers values +func NewPcloudCloudinstancesSnapshotsDeleteAccepted() *PcloudCloudinstancesSnapshotsDeleteAccepted { + return &PcloudCloudinstancesSnapshotsDeleteAccepted{} } -/*PcloudCloudinstancesSnapshotsDeleteOK handles this case with default header values. +/*PcloudCloudinstancesSnapshotsDeleteAccepted handles this case with default header values. -OK +Accepted */ -type PcloudCloudinstancesSnapshotsDeleteOK struct { +type PcloudCloudinstancesSnapshotsDeleteAccepted struct { Payload models.Object } -func (o *PcloudCloudinstancesSnapshotsDeleteOK) Error() string { - return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteOK %+v", 200, o.Payload) +func (o *PcloudCloudinstancesSnapshotsDeleteAccepted) Error() string { + return fmt.Sprintf("[DELETE /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsDeleteAccepted %+v", 202, o.Payload) } -func (o *PcloudCloudinstancesSnapshotsDeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { +func (o *PcloudCloudinstancesSnapshotsDeleteAccepted) 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 { diff --git a/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go new file mode 100644 index 00000000..d4805a80 --- /dev/null +++ b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_parameters.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewPcloudCloudinstancesSnapshotsGetParams creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the default values initialized. +func NewPcloudCloudinstancesSnapshotsGetParams() *PcloudCloudinstancesSnapshotsGetParams { + var () + return &PcloudCloudinstancesSnapshotsGetParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithTimeout creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewPcloudCloudinstancesSnapshotsGetParamsWithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetParams { + var () + return &PcloudCloudinstancesSnapshotsGetParams{ + + timeout: timeout, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithContext creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the default values initialized, and the ability to set a context for a request +func NewPcloudCloudinstancesSnapshotsGetParamsWithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetParams { + var () + return &PcloudCloudinstancesSnapshotsGetParams{ + + Context: ctx, + } +} + +// NewPcloudCloudinstancesSnapshotsGetParamsWithHTTPClient creates a new PcloudCloudinstancesSnapshotsGetParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewPcloudCloudinstancesSnapshotsGetParamsWithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetParams { + var () + return &PcloudCloudinstancesSnapshotsGetParams{ + HTTPClient: client, + } +} + +/*PcloudCloudinstancesSnapshotsGetParams contains all the parameters to send to the API endpoint +for the pcloud cloudinstances snapshots get operation typically these are written to a http.Request +*/ +type PcloudCloudinstancesSnapshotsGetParams struct { + + /*CloudInstanceID + Cloud Instance ID of a PCloud Instance + + */ + CloudInstanceID string + /*SnapshotID + PVM Instance snapshot id + + */ + SnapshotID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithTimeout(timeout time.Duration) *PcloudCloudinstancesSnapshotsGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithContext(ctx context.Context) *PcloudCloudinstancesSnapshotsGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithHTTPClient(client *http.Client) *PcloudCloudinstancesSnapshotsGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithCloudInstanceID adds the cloudInstanceID to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithCloudInstanceID(cloudInstanceID string) *PcloudCloudinstancesSnapshotsGetParams { + o.SetCloudInstanceID(cloudInstanceID) + return o +} + +// SetCloudInstanceID adds the cloudInstanceId to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetCloudInstanceID(cloudInstanceID string) { + o.CloudInstanceID = cloudInstanceID +} + +// WithSnapshotID adds the snapshotID to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) WithSnapshotID(snapshotID string) *PcloudCloudinstancesSnapshotsGetParams { + o.SetSnapshotID(snapshotID) + return o +} + +// SetSnapshotID adds the snapshotId to the pcloud cloudinstances snapshots get params +func (o *PcloudCloudinstancesSnapshotsGetParams) SetSnapshotID(snapshotID string) { + o.SnapshotID = snapshotID +} + +// WriteToRequest writes these params to a swagger request +func (o *PcloudCloudinstancesSnapshotsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param cloud_instance_id + if err := r.SetPathParam("cloud_instance_id", o.CloudInstanceID); err != nil { + return err + } + + // 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/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go new file mode 100644 index 00000000..a071672c --- /dev/null +++ b/power/client/p_cloud_snapshots/pcloud_cloudinstances_snapshots_get_responses.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package p_cloud_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" + "io" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/IBM-Cloud/power-go-client/power/models" +) + +// PcloudCloudinstancesSnapshotsGetReader is a Reader for the PcloudCloudinstancesSnapshotsGet structure. +type PcloudCloudinstancesSnapshotsGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PcloudCloudinstancesSnapshotsGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewPcloudCloudinstancesSnapshotsGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewPcloudCloudinstancesSnapshotsGetBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewPcloudCloudinstancesSnapshotsGetInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewPcloudCloudinstancesSnapshotsGetOK creates a PcloudCloudinstancesSnapshotsGetOK with default headers values +func NewPcloudCloudinstancesSnapshotsGetOK() *PcloudCloudinstancesSnapshotsGetOK { + return &PcloudCloudinstancesSnapshotsGetOK{} +} + +/*PcloudCloudinstancesSnapshotsGetOK handles this case with default header values. + +OK +*/ +type PcloudCloudinstancesSnapshotsGetOK struct { + Payload *models.Snapshot +} + +func (o *PcloudCloudinstancesSnapshotsGetOK) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetOK %+v", 200, o.Payload) +} + +func (o *PcloudCloudinstancesSnapshotsGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Snapshot) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPcloudCloudinstancesSnapshotsGetBadRequest creates a PcloudCloudinstancesSnapshotsGetBadRequest with default headers values +func NewPcloudCloudinstancesSnapshotsGetBadRequest() *PcloudCloudinstancesSnapshotsGetBadRequest { + return &PcloudCloudinstancesSnapshotsGetBadRequest{} +} + +/*PcloudCloudinstancesSnapshotsGetBadRequest handles this case with default header values. + +Bad Request +*/ +type PcloudCloudinstancesSnapshotsGetBadRequest struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetBadRequest) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetBadRequest %+v", 400, o.Payload) +} + +func (o *PcloudCloudinstancesSnapshotsGetBadRequest) 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 +} + +// NewPcloudCloudinstancesSnapshotsGetInternalServerError creates a PcloudCloudinstancesSnapshotsGetInternalServerError with default headers values +func NewPcloudCloudinstancesSnapshotsGetInternalServerError() *PcloudCloudinstancesSnapshotsGetInternalServerError { + return &PcloudCloudinstancesSnapshotsGetInternalServerError{} +} + +/*PcloudCloudinstancesSnapshotsGetInternalServerError handles this case with default header values. + +Internal Server Error +*/ +type PcloudCloudinstancesSnapshotsGetInternalServerError struct { + Payload *models.Error +} + +func (o *PcloudCloudinstancesSnapshotsGetInternalServerError) Error() string { + return fmt.Sprintf("[GET /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}][%d] pcloudCloudinstancesSnapshotsGetInternalServerError %+v", 500, o.Payload) +} + +func (o *PcloudCloudinstancesSnapshotsGetInternalServerError) 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/p_vm_instance_sys_type.go b/power/models/p_vm_instance_sys_type.go deleted file mode 100644 index b718486f..00000000 --- a/power/models/p_vm_instance_sys_type.go +++ /dev/null @@ -1,66 +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 ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/validate" -) - -// PVMInstanceSysType System type used to host the instance -// swagger:model PVMInstanceSysType -type PVMInstanceSysType string - -const ( - - // PVMInstanceSysTypeS922 captures enum value "s922" - PVMInstanceSysTypeS922 PVMInstanceSysType = "s922" - - // PVMInstanceSysTypeE880 captures enum value "e880" - PVMInstanceSysTypeE880 PVMInstanceSysType = "e880" - - // PVMInstanceSysTypeUnknown captures enum value "unknown" - PVMInstanceSysTypeUnknown PVMInstanceSysType = "unknown" -) - -// for schema -var pVmInstanceSysTypeEnum []interface{} - -func init() { - var res []PVMInstanceSysType - if err := json.Unmarshal([]byte(`["s922","e880","unknown"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - pVmInstanceSysTypeEnum = append(pVmInstanceSysTypeEnum, v) - } -} - -func (m PVMInstanceSysType) validatePVMInstanceSysTypeEnum(path, location string, value PVMInstanceSysType) error { - if err := validate.Enum(path, location, value, pVmInstanceSysTypeEnum); err != nil { - return err - } - return nil -} - -// Validate validates this p VM instance sys type -func (m PVMInstanceSysType) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validatePVMInstanceSysTypeEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/power/models/snapshot.go b/power/models/snapshot.go index ed4355d6..ab301f42 100644 --- a/power/models/snapshot.go +++ b/power/models/snapshot.go @@ -17,6 +17,9 @@ import ( // swagger:model Snapshot type Snapshot struct { + // Action performed on the instance snapshot + Action string `json:"action,omitempty"` + // Creation Date // Format: date-time CreationDate strfmt.DateTime `json:"creationDate,omitempty"` @@ -32,6 +35,9 @@ type Snapshot struct { // Required: true Name *string `json:"name"` + // Snapshot completion percentage + PercentComplete int64 `json:"percentComplete,omitempty"` + // PCloud PVM Instance ID // Required: true PvmInstanceID *string `json:"pvmInstanceID"` @@ -43,9 +49,6 @@ type Snapshot struct { // Status of the PVM instancesnapshot Status string `json:"status,omitempty"` - // URL to call to get latest status of a PVM instance snapshot - StatusURL string `json:"statusUrl,omitempty"` - // A map of volume snapshots included in the PVM instance snapshot // Required: true VolumeSnapshots map[string]string `json:"volumeSnapshots"` diff --git a/power/models/snapshot_create_response.go b/power/models/snapshot_create_response.go index ff7980d0..c372430b 100644 --- a/power/models/snapshot_create_response.go +++ b/power/models/snapshot_create_response.go @@ -20,10 +20,6 @@ type SnapshotCreateResponse struct { // ID of the PVM instance snapshot // Required: true SnapshotID *string `json:"snapshotID"` - - // URL to call to get latest status of a PVM instance snapshot - // Required: true - StatusURL *string `json:"statusUrl"` } // Validate validates this snapshot create response @@ -34,10 +30,6 @@ func (m *SnapshotCreateResponse) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateStatusURL(formats); err != nil { - res = append(res, err) - } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -53,15 +45,6 @@ func (m *SnapshotCreateResponse) validateSnapshotID(formats strfmt.Registry) err return nil } -func (m *SnapshotCreateResponse) validateStatusURL(formats strfmt.Registry) error { - - if err := validate.Required("statusUrl", "body", m.StatusURL); err != nil { - return err - } - - return nil -} - // MarshalBinary interface implementation func (m *SnapshotCreateResponse) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/version.go b/version.go new file mode 100644 index 00000000..274a5a4d --- /dev/null +++ b/version.go @@ -0,0 +1,6 @@ +package power_go_client + +//Version is the Power-go-client sdk version +const Version = "0.1" + +// Power client version - Pull 870 From 359bc9763aba194e246fd268fee870a563f459c2 Mon Sep 17 00:00:00 2001 From: surajsub Date: Mon, 16 Mar 2020 12:52:12 -0500 Subject: [PATCH 2/2] Added version --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 274a5a4d..d2b3cb8e 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ package power_go_client //Version is the Power-go-client sdk version -const Version = "0.1" +const Version = "v1.0.0" // Power client version - Pull 870