From 0def9b01ded248457eda508d55d881e637bf69ea Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Mon, 11 Nov 2019 22:18:05 +0000 Subject: [PATCH] virtcontainers/firecracker: update API update firecracker API to 0.19.0 Signed-off-by: Julio Montes --- virtcontainers/pkg/firecracker/README | 4 +- .../client/models/instance_info.go | 10 +- .../create_sync_action_responses.go | 11 +- .../operations/describe_instance_responses.go | 10 +- .../get_machine_configuration_responses.go | 10 +- .../client/operations/get_mmds_responses.go | 15 +- .../client/operations/operations_client.go | 149 ++++------------ .../patch_guest_drive_by_id_responses.go | 11 +- ...guest_network_interface_by_id_responses.go | 11 +- .../patch_machine_configuration_responses.go | 11 +- .../client/operations/patch_mmds_responses.go | 11 +- .../put_guest_boot_source_responses.go | 11 +- .../put_guest_drive_by_id_responses.go | 11 +- ...guest_network_interface_by_id_responses.go | 11 +- .../put_guest_vsock_by_id_parameters.go | 160 ------------------ .../put_guest_vsock_by_id_responses.go | 145 ---------------- .../operations/put_guest_vsock_parameters.go | 139 +++++++++++++++ .../operations/put_guest_vsock_responses.go | 140 +++++++++++++++ .../client/operations/put_logger_responses.go | 11 +- .../put_machine_configuration_responses.go | 11 +- .../client/operations/put_mmds_responses.go | 11 +- ...ker-experimental.yaml => firecracker.yaml} | 20 +-- 22 files changed, 367 insertions(+), 556 deletions(-) delete mode 100644 virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_parameters.go delete mode 100644 virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_responses.go create mode 100644 virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_parameters.go create mode 100644 virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_responses.go rename virtcontainers/pkg/firecracker/{firecracker-experimental.yaml => firecracker.yaml} (97%) diff --git a/virtcontainers/pkg/firecracker/README b/virtcontainers/pkg/firecracker/README index bb042cdd44..d88abc1f0c 100644 --- a/virtcontainers/pkg/firecracker/README +++ b/virtcontainers/pkg/firecracker/README @@ -5,8 +5,8 @@ The code is generated via go-swagger https://github.com/go-swagger/go-swagger#licensing ``` -swagger generate model -f ./firecracker-experimental.yaml --model-package=client/models --client-package=client -swagger generate client -f ./firecracker-experimental.yaml --model-package=client/models --client-package=client +swagger generate model -f ./firecracker.yaml --model-package=client/models --client-package=client +swagger generate client -f ./firecracker.yaml --model-package=client/models --client-package=client ``` ``` diff --git a/virtcontainers/pkg/firecracker/client/models/instance_info.go b/virtcontainers/pkg/firecracker/client/models/instance_info.go index 972eff8d41..f5995cc12e 100644 --- a/virtcontainers/pkg/firecracker/client/models/instance_info.go +++ b/virtcontainers/pkg/firecracker/client/models/instance_info.go @@ -25,7 +25,7 @@ type InstanceInfo struct { // The current detailed state of the Firecracker instance. This value is read-only for the control-plane. // Required: true - // Enum: [Uninitialized Starting Running Halting Halted] + // Enum: [Uninitialized Starting Running] State *string `json:"state"` // MicroVM hypervisor build version. @@ -68,7 +68,7 @@ var instanceInfoTypeStatePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Uninitialized","Starting","Running","Halting","Halted"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Uninitialized","Starting","Running"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -86,12 +86,6 @@ const ( // InstanceInfoStateRunning captures enum value "Running" InstanceInfoStateRunning string = "Running" - - // InstanceInfoStateHalting captures enum value "Halting" - InstanceInfoStateHalting string = "Halting" - - // InstanceInfoStateHalted captures enum value "Halted" - InstanceInfoStateHalted string = "Halted" ) // prop value enum diff --git a/virtcontainers/pkg/firecracker/client/operations/create_sync_action_responses.go b/virtcontainers/pkg/firecracker/client/operations/create_sync_action_responses.go index bb67439557..58cdb44d81 100644 --- a/virtcontainers/pkg/firecracker/client/operations/create_sync_action_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/create_sync_action_responses.go @@ -24,18 +24,21 @@ type CreateSyncActionReader struct { // ReadResponse reads a server response into the received o. func (o *CreateSyncActionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewCreateSyncActionNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewCreateSyncActionBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewCreateSyncActionDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *CreateSyncActionBadRequest) Error() string { return fmt.Sprintf("[PUT /actions][%d] createSyncActionBadRequest %+v", 400, o.Payload) } -func (o *CreateSyncActionBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *CreateSyncActionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *CreateSyncActionDefault) Error() string { return fmt.Sprintf("[PUT /actions][%d] createSyncAction default %+v", o._statusCode, o.Payload) } -func (o *CreateSyncActionDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *CreateSyncActionDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/describe_instance_responses.go b/virtcontainers/pkg/firecracker/client/operations/describe_instance_responses.go index 3b21f1d321..3c63f9dd4a 100644 --- a/virtcontainers/pkg/firecracker/client/operations/describe_instance_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/describe_instance_responses.go @@ -24,12 +24,14 @@ type DescribeInstanceReader struct { // ReadResponse reads a server response into the received o. func (o *DescribeInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 200: result := NewDescribeInstanceOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + default: result := NewDescribeInstanceDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -59,10 +61,6 @@ func (o *DescribeInstanceOK) Error() string { return fmt.Sprintf("[GET /][%d] describeInstanceOK %+v", 200, o.Payload) } -func (o *DescribeInstanceOK) GetPayload() *models.InstanceInfo { - return o.Payload -} - func (o *DescribeInstanceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.InstanceInfo) @@ -101,10 +99,6 @@ func (o *DescribeInstanceDefault) Error() string { return fmt.Sprintf("[GET /][%d] describeInstance default %+v", o._statusCode, o.Payload) } -func (o *DescribeInstanceDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *DescribeInstanceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/get_machine_configuration_responses.go b/virtcontainers/pkg/firecracker/client/operations/get_machine_configuration_responses.go index f73171d9c4..e9bff0f89e 100644 --- a/virtcontainers/pkg/firecracker/client/operations/get_machine_configuration_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/get_machine_configuration_responses.go @@ -24,12 +24,14 @@ type GetMachineConfigurationReader struct { // ReadResponse reads a server response into the received o. func (o *GetMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 200: result := NewGetMachineConfigurationOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + default: result := NewGetMachineConfigurationDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -59,10 +61,6 @@ func (o *GetMachineConfigurationOK) Error() string { return fmt.Sprintf("[GET /machine-config][%d] getMachineConfigurationOK %+v", 200, o.Payload) } -func (o *GetMachineConfigurationOK) GetPayload() *models.MachineConfiguration { - return o.Payload -} - func (o *GetMachineConfigurationOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.MachineConfiguration) @@ -101,10 +99,6 @@ func (o *GetMachineConfigurationDefault) Error() string { return fmt.Sprintf("[GET /machine-config][%d] getMachineConfiguration default %+v", o._statusCode, o.Payload) } -func (o *GetMachineConfigurationDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *GetMachineConfigurationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/get_mmds_responses.go b/virtcontainers/pkg/firecracker/client/operations/get_mmds_responses.go index 4390227d4d..4119bf8ef3 100644 --- a/virtcontainers/pkg/firecracker/client/operations/get_mmds_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/get_mmds_responses.go @@ -24,18 +24,21 @@ type GetMmdsReader struct { // ReadResponse reads a server response into the received o. func (o *GetMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 200: result := NewGetMmdsOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewGetMmdsBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewGetMmdsDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -65,10 +68,6 @@ func (o *GetMmdsOK) Error() string { return fmt.Sprintf("[GET /mmds][%d] getMmdsOK %+v", 200, o.Payload) } -func (o *GetMmdsOK) GetPayload() interface{} { - return o.Payload -} - func (o *GetMmdsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { // response payload @@ -96,10 +95,6 @@ func (o *GetMmdsBadRequest) Error() string { return fmt.Sprintf("[GET /mmds][%d] getMmdsBadRequest %+v", 400, o.Payload) } -func (o *GetMmdsBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *GetMmdsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -138,10 +133,6 @@ func (o *GetMmdsDefault) Error() string { return fmt.Sprintf("[GET /mmds][%d] GetMmds default %+v", o._statusCode, o.Payload) } -func (o *GetMmdsDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *GetMmdsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/operations_client.go b/virtcontainers/pkg/firecracker/client/operations/operations_client.go index 960596baa5..1be8b37cf6 100644 --- a/virtcontainers/pkg/firecracker/client/operations/operations_client.go +++ b/virtcontainers/pkg/firecracker/client/operations/operations_client.go @@ -48,13 +48,8 @@ func (a *Client) GetMmds(params *GetMmdsParams) (*GetMmdsOK, error) { if err != nil { return nil, err } - success, ok := result.(*GetMmdsOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*GetMmdsDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*GetMmdsOK), nil + } /* @@ -81,13 +76,8 @@ func (a *Client) PatchMmds(params *PatchMmdsParams) (*PatchMmdsNoContent, error) if err != nil { return nil, err } - success, ok := result.(*PatchMmdsNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PatchMmdsDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PatchMmdsNoContent), nil + } /* @@ -114,13 +104,8 @@ func (a *Client) PutMmds(params *PutMmdsParams) (*PutMmdsNoContent, error) { if err != nil { return nil, err } - success, ok := result.(*PutMmdsNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutMmdsDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutMmdsNoContent), nil + } /* @@ -147,13 +132,8 @@ func (a *Client) CreateSyncAction(params *CreateSyncActionParams) (*CreateSyncAc if err != nil { return nil, err } - success, ok := result.(*CreateSyncActionNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*CreateSyncActionDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*CreateSyncActionNoContent), nil + } /* @@ -180,13 +160,8 @@ func (a *Client) DescribeInstance(params *DescribeInstanceParams) (*DescribeInst if err != nil { return nil, err } - success, ok := result.(*DescribeInstanceOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*DescribeInstanceDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*DescribeInstanceOK), nil + } /* @@ -215,13 +190,8 @@ func (a *Client) GetMachineConfiguration(params *GetMachineConfigurationParams) if err != nil { return nil, err } - success, ok := result.(*GetMachineConfigurationOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*GetMachineConfigurationDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*GetMachineConfigurationOK), nil + } /* @@ -250,13 +220,8 @@ func (a *Client) PatchGuestDriveByID(params *PatchGuestDriveByIDParams) (*PatchG if err != nil { return nil, err } - success, ok := result.(*PatchGuestDriveByIDNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PatchGuestDriveByIDDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PatchGuestDriveByIDNoContent), nil + } /* @@ -285,13 +250,8 @@ func (a *Client) PatchGuestNetworkInterfaceByID(params *PatchGuestNetworkInterfa if err != nil { return nil, err } - success, ok := result.(*PatchGuestNetworkInterfaceByIDNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PatchGuestNetworkInterfaceByIDDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PatchGuestNetworkInterfaceByIDNoContent), nil + } /* @@ -320,13 +280,8 @@ func (a *Client) PatchMachineConfiguration(params *PatchMachineConfigurationPara if err != nil { return nil, err } - success, ok := result.(*PatchMachineConfigurationNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PatchMachineConfigurationDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PatchMachineConfigurationNoContent), nil + } /* @@ -355,13 +310,8 @@ func (a *Client) PutGuestBootSource(params *PutGuestBootSourceParams) (*PutGuest if err != nil { return nil, err } - success, ok := result.(*PutGuestBootSourceNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutGuestBootSourceDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutGuestBootSourceNoContent), nil + } /* @@ -390,13 +340,8 @@ func (a *Client) PutGuestDriveByID(params *PutGuestDriveByIDParams) (*PutGuestDr if err != nil { return nil, err } - success, ok := result.(*PutGuestDriveByIDNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutGuestDriveByIDDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutGuestDriveByIDNoContent), nil + } /* @@ -425,48 +370,38 @@ func (a *Client) PutGuestNetworkInterfaceByID(params *PutGuestNetworkInterfaceBy if err != nil { return nil, err } - success, ok := result.(*PutGuestNetworkInterfaceByIDNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutGuestNetworkInterfaceByIDDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutGuestNetworkInterfaceByIDNoContent), nil + } /* -PutGuestVsockByID creates new vsock with ID specified by the id parameter +PutGuestVsock creates updates a vsock device -If the vsock device with the specified ID already exists, its body will be updated based on the new input. May fail if update is not possible. +The first call creates the device with the configuration specified in body. Subsequent calls will update the device configuration. May fail if update is not possible. */ -func (a *Client) PutGuestVsockByID(params *PutGuestVsockByIDParams) (*PutGuestVsockByIDNoContent, error) { +func (a *Client) PutGuestVsock(params *PutGuestVsockParams) (*PutGuestVsockNoContent, error) { // TODO: Validate the params before sending if params == nil { - params = NewPutGuestVsockByIDParams() + params = NewPutGuestVsockParams() } result, err := a.transport.Submit(&runtime.ClientOperation{ - ID: "putGuestVsockByID", + ID: "putGuestVsock", Method: "PUT", - PathPattern: "/vsocks/{id}", + PathPattern: "/vsock", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, - Reader: &PutGuestVsockByIDReader{formats: a.formats}, + Reader: &PutGuestVsockReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, }) if err != nil { return nil, err } - success, ok := result.(*PutGuestVsockByIDNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutGuestVsockByIDDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutGuestVsockNoContent), nil + } /* @@ -493,13 +428,8 @@ func (a *Client) PutLogger(params *PutLoggerParams) (*PutLoggerNoContent, error) if err != nil { return nil, err } - success, ok := result.(*PutLoggerNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutLoggerDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutLoggerNoContent), nil + } /* @@ -528,13 +458,8 @@ func (a *Client) PutMachineConfiguration(params *PutMachineConfigurationParams) if err != nil { return nil, err } - success, ok := result.(*PutMachineConfigurationNoContent) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*PutMachineConfigurationDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) + return result.(*PutMachineConfigurationNoContent), nil + } // SetTransport changes the transport on the client diff --git a/virtcontainers/pkg/firecracker/client/operations/patch_guest_drive_by_id_responses.go b/virtcontainers/pkg/firecracker/client/operations/patch_guest_drive_by_id_responses.go index ba80a3e21d..672473f838 100644 --- a/virtcontainers/pkg/firecracker/client/operations/patch_guest_drive_by_id_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/patch_guest_drive_by_id_responses.go @@ -24,18 +24,21 @@ type PatchGuestDriveByIDReader struct { // ReadResponse reads a server response into the received o. func (o *PatchGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPatchGuestDriveByIDNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPatchGuestDriveByIDBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPatchGuestDriveByIDDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PatchGuestDriveByIDBadRequest) Error() string { return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdBadRequest %+v", 400, o.Payload) } -func (o *PatchGuestDriveByIDBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchGuestDriveByIDBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PatchGuestDriveByIDDefault) Error() string { return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByID default %+v", o._statusCode, o.Payload) } -func (o *PatchGuestDriveByIDDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchGuestDriveByIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/patch_guest_network_interface_by_id_responses.go b/virtcontainers/pkg/firecracker/client/operations/patch_guest_network_interface_by_id_responses.go index 652130d75a..cb9ed11b72 100644 --- a/virtcontainers/pkg/firecracker/client/operations/patch_guest_network_interface_by_id_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/patch_guest_network_interface_by_id_responses.go @@ -24,18 +24,21 @@ type PatchGuestNetworkInterfaceByIDReader struct { // ReadResponse reads a server response into the received o. func (o *PatchGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPatchGuestNetworkInterfaceByIDNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPatchGuestNetworkInterfaceByIDBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPatchGuestNetworkInterfaceByIDDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PatchGuestNetworkInterfaceByIDBadRequest) Error() string { return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdBadRequest %+v", 400, o.Payload) } -func (o *PatchGuestNetworkInterfaceByIDBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchGuestNetworkInterfaceByIDBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PatchGuestNetworkInterfaceByIDDefault) Error() string { return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByID default %+v", o._statusCode, o.Payload) } -func (o *PatchGuestNetworkInterfaceByIDDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchGuestNetworkInterfaceByIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/patch_machine_configuration_responses.go b/virtcontainers/pkg/firecracker/client/operations/patch_machine_configuration_responses.go index f828e63c17..b796d056a7 100644 --- a/virtcontainers/pkg/firecracker/client/operations/patch_machine_configuration_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/patch_machine_configuration_responses.go @@ -24,18 +24,21 @@ type PatchMachineConfigurationReader struct { // ReadResponse reads a server response into the received o. func (o *PatchMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPatchMachineConfigurationNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPatchMachineConfigurationBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPatchMachineConfigurationDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PatchMachineConfigurationBadRequest) Error() string { return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationBadRequest %+v", 400, o.Payload) } -func (o *PatchMachineConfigurationBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchMachineConfigurationBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PatchMachineConfigurationDefault) Error() string { return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfiguration default %+v", o._statusCode, o.Payload) } -func (o *PatchMachineConfigurationDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchMachineConfigurationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/patch_mmds_responses.go b/virtcontainers/pkg/firecracker/client/operations/patch_mmds_responses.go index fe0a8e9936..113c5abaa6 100644 --- a/virtcontainers/pkg/firecracker/client/operations/patch_mmds_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/patch_mmds_responses.go @@ -24,18 +24,21 @@ type PatchMmdsReader struct { // ReadResponse reads a server response into the received o. func (o *PatchMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPatchMmdsNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPatchMmdsBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPatchMmdsDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PatchMmdsBadRequest) Error() string { return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsBadRequest %+v", 400, o.Payload) } -func (o *PatchMmdsBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchMmdsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PatchMmdsDefault) Error() string { return fmt.Sprintf("[PATCH /mmds][%d] PatchMmds default %+v", o._statusCode, o.Payload) } -func (o *PatchMmdsDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PatchMmdsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_boot_source_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_boot_source_responses.go index 5c7f604783..3d39bebe87 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_guest_boot_source_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_guest_boot_source_responses.go @@ -24,18 +24,21 @@ type PutGuestBootSourceReader struct { // ReadResponse reads a server response into the received o. func (o *PutGuestBootSourceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutGuestBootSourceNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutGuestBootSourceBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutGuestBootSourceDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutGuestBootSourceBadRequest) Error() string { return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceBadRequest %+v", 400, o.Payload) } -func (o *PutGuestBootSourceBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestBootSourceBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutGuestBootSourceDefault) Error() string { return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSource default %+v", o._statusCode, o.Payload) } -func (o *PutGuestBootSourceDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestBootSourceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_drive_by_id_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_drive_by_id_responses.go index a6909f865e..6dc8d6419f 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_guest_drive_by_id_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_guest_drive_by_id_responses.go @@ -24,18 +24,21 @@ type PutGuestDriveByIDReader struct { // ReadResponse reads a server response into the received o. func (o *PutGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutGuestDriveByIDNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutGuestDriveByIDBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutGuestDriveByIDDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutGuestDriveByIDBadRequest) Error() string { return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdBadRequest %+v", 400, o.Payload) } -func (o *PutGuestDriveByIDBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestDriveByIDBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutGuestDriveByIDDefault) Error() string { return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByID default %+v", o._statusCode, o.Payload) } -func (o *PutGuestDriveByIDDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestDriveByIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_network_interface_by_id_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_network_interface_by_id_responses.go index ed4fbf7819..ebfbe2d604 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_guest_network_interface_by_id_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_guest_network_interface_by_id_responses.go @@ -24,18 +24,21 @@ type PutGuestNetworkInterfaceByIDReader struct { // ReadResponse reads a server response into the received o. func (o *PutGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutGuestNetworkInterfaceByIDNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutGuestNetworkInterfaceByIDBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutGuestNetworkInterfaceByIDDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutGuestNetworkInterfaceByIDBadRequest) Error() string { return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdBadRequest %+v", 400, o.Payload) } -func (o *PutGuestNetworkInterfaceByIDBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestNetworkInterfaceByIDBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutGuestNetworkInterfaceByIDDefault) Error() string { return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByID default %+v", o._statusCode, o.Payload) } -func (o *PutGuestNetworkInterfaceByIDDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutGuestNetworkInterfaceByIDDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_parameters.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_parameters.go deleted file mode 100644 index 29a85e2702..0000000000 --- a/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_parameters.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package operations - -// 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" - - models "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models" -) - -// NewPutGuestVsockByIDParams creates a new PutGuestVsockByIDParams object -// with the default values initialized. -func NewPutGuestVsockByIDParams() *PutGuestVsockByIDParams { - var () - return &PutGuestVsockByIDParams{ - - timeout: cr.DefaultTimeout, - } -} - -// NewPutGuestVsockByIDParamsWithTimeout creates a new PutGuestVsockByIDParams object -// with the default values initialized, and the ability to set a timeout on a request -func NewPutGuestVsockByIDParamsWithTimeout(timeout time.Duration) *PutGuestVsockByIDParams { - var () - return &PutGuestVsockByIDParams{ - - timeout: timeout, - } -} - -// NewPutGuestVsockByIDParamsWithContext creates a new PutGuestVsockByIDParams object -// with the default values initialized, and the ability to set a context for a request -func NewPutGuestVsockByIDParamsWithContext(ctx context.Context) *PutGuestVsockByIDParams { - var () - return &PutGuestVsockByIDParams{ - - Context: ctx, - } -} - -// NewPutGuestVsockByIDParamsWithHTTPClient creates a new PutGuestVsockByIDParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request -func NewPutGuestVsockByIDParamsWithHTTPClient(client *http.Client) *PutGuestVsockByIDParams { - var () - return &PutGuestVsockByIDParams{ - HTTPClient: client, - } -} - -/*PutGuestVsockByIDParams contains all the parameters to send to the API endpoint -for the put guest vsock by ID operation typically these are written to a http.Request -*/ -type PutGuestVsockByIDParams struct { - - /*Body - Guest vsock properties - - */ - Body *models.Vsock - /*ID - The id of the vsock device - - */ - ID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithTimeout adds the timeout to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) WithTimeout(timeout time.Duration) *PutGuestVsockByIDParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) WithContext(ctx context.Context) *PutGuestVsockByIDParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) WithHTTPClient(client *http.Client) *PutGuestVsockByIDParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) WithBody(body *models.Vsock) *PutGuestVsockByIDParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) SetBody(body *models.Vsock) { - o.Body = body -} - -// WithID adds the id to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) WithID(id string) *PutGuestVsockByIDParams { - o.SetID(id) - return o -} - -// SetID adds the id to the put guest vsock by ID params -func (o *PutGuestVsockByIDParams) SetID(id string) { - o.ID = id -} - -// WriteToRequest writes these params to a swagger request -func (o *PutGuestVsockByIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if o.Body != nil { - if err := r.SetBodyParam(o.Body); err != nil { - return err - } - } - - // path param id - if err := r.SetPathParam("id", o.ID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_responses.go deleted file mode 100644 index 74e56f91b3..0000000000 --- a/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_by_id_responses.go +++ /dev/null @@ -1,145 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package operations - -// 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/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models" -) - -// PutGuestVsockByIDReader is a Reader for the PutGuestVsockByID structure. -type PutGuestVsockByIDReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PutGuestVsockByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 204: - result := NewPutGuestVsockByIDNoContent() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPutGuestVsockByIDBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - result := NewPutGuestVsockByIDDefault(response.Code()) - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - if response.Code()/100 == 2 { - return result, nil - } - return nil, result - } -} - -// NewPutGuestVsockByIDNoContent creates a PutGuestVsockByIDNoContent with default headers values -func NewPutGuestVsockByIDNoContent() *PutGuestVsockByIDNoContent { - return &PutGuestVsockByIDNoContent{} -} - -/*PutGuestVsockByIDNoContent handles this case with default header values. - -Vsock created/updated -*/ -type PutGuestVsockByIDNoContent struct { -} - -func (o *PutGuestVsockByIDNoContent) Error() string { - return fmt.Sprintf("[PUT /vsocks/{id}][%d] putGuestVsockByIdNoContent ", 204) -} - -func (o *PutGuestVsockByIDNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} - -// NewPutGuestVsockByIDBadRequest creates a PutGuestVsockByIDBadRequest with default headers values -func NewPutGuestVsockByIDBadRequest() *PutGuestVsockByIDBadRequest { - return &PutGuestVsockByIDBadRequest{} -} - -/*PutGuestVsockByIDBadRequest handles this case with default header values. - -Vsock cannot be created due to bad input -*/ -type PutGuestVsockByIDBadRequest struct { - Payload *models.Error -} - -func (o *PutGuestVsockByIDBadRequest) Error() string { - return fmt.Sprintf("[PUT /vsocks/{id}][%d] putGuestVsockByIdBadRequest %+v", 400, o.Payload) -} - -func (o *PutGuestVsockByIDBadRequest) GetPayload() *models.Error { - return o.Payload -} - -func (o *PutGuestVsockByIDBadRequest) 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 -} - -// NewPutGuestVsockByIDDefault creates a PutGuestVsockByIDDefault with default headers values -func NewPutGuestVsockByIDDefault(code int) *PutGuestVsockByIDDefault { - return &PutGuestVsockByIDDefault{ - _statusCode: code, - } -} - -/*PutGuestVsockByIDDefault handles this case with default header values. - -Internal server error -*/ -type PutGuestVsockByIDDefault struct { - _statusCode int - - Payload *models.Error -} - -// Code gets the status code for the put guest vsock by ID default response -func (o *PutGuestVsockByIDDefault) Code() int { - return o._statusCode -} - -func (o *PutGuestVsockByIDDefault) Error() string { - return fmt.Sprintf("[PUT /vsocks/{id}][%d] putGuestVsockByID default %+v", o._statusCode, o.Payload) -} - -func (o *PutGuestVsockByIDDefault) GetPayload() *models.Error { - return o.Payload -} - -func (o *PutGuestVsockByIDDefault) 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/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_parameters.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_parameters.go new file mode 100644 index 0000000000..f57ddeaf4a --- /dev/null +++ b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" + + models "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models" +) + +// NewPutGuestVsockParams creates a new PutGuestVsockParams object +// with the default values initialized. +func NewPutGuestVsockParams() *PutGuestVsockParams { + var () + return &PutGuestVsockParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewPutGuestVsockParamsWithTimeout creates a new PutGuestVsockParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewPutGuestVsockParamsWithTimeout(timeout time.Duration) *PutGuestVsockParams { + var () + return &PutGuestVsockParams{ + + timeout: timeout, + } +} + +// NewPutGuestVsockParamsWithContext creates a new PutGuestVsockParams object +// with the default values initialized, and the ability to set a context for a request +func NewPutGuestVsockParamsWithContext(ctx context.Context) *PutGuestVsockParams { + var () + return &PutGuestVsockParams{ + + Context: ctx, + } +} + +// NewPutGuestVsockParamsWithHTTPClient creates a new PutGuestVsockParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewPutGuestVsockParamsWithHTTPClient(client *http.Client) *PutGuestVsockParams { + var () + return &PutGuestVsockParams{ + HTTPClient: client, + } +} + +/*PutGuestVsockParams contains all the parameters to send to the API endpoint +for the put guest vsock operation typically these are written to a http.Request +*/ +type PutGuestVsockParams struct { + + /*Body + Guest vsock properties + + */ + Body *models.Vsock + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the put guest vsock params +func (o *PutGuestVsockParams) WithTimeout(timeout time.Duration) *PutGuestVsockParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the put guest vsock params +func (o *PutGuestVsockParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the put guest vsock params +func (o *PutGuestVsockParams) WithContext(ctx context.Context) *PutGuestVsockParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the put guest vsock params +func (o *PutGuestVsockParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the put guest vsock params +func (o *PutGuestVsockParams) WithHTTPClient(client *http.Client) *PutGuestVsockParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the put guest vsock params +func (o *PutGuestVsockParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the put guest vsock params +func (o *PutGuestVsockParams) WithBody(body *models.Vsock) *PutGuestVsockParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the put guest vsock params +func (o *PutGuestVsockParams) SetBody(body *models.Vsock) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *PutGuestVsockParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_responses.go new file mode 100644 index 0000000000..d6b78ac8b8 --- /dev/null +++ b/virtcontainers/pkg/firecracker/client/operations/put_guest_vsock_responses.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models" +) + +// PutGuestVsockReader is a Reader for the PutGuestVsock structure. +type PutGuestVsockReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PutGuestVsockReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 204: + result := NewPutGuestVsockNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewPutGuestVsockBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + result := NewPutGuestVsockDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewPutGuestVsockNoContent creates a PutGuestVsockNoContent with default headers values +func NewPutGuestVsockNoContent() *PutGuestVsockNoContent { + return &PutGuestVsockNoContent{} +} + +/*PutGuestVsockNoContent handles this case with default header values. + +Vsock created/updated +*/ +type PutGuestVsockNoContent struct { +} + +func (o *PutGuestVsockNoContent) Error() string { + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockNoContent ", 204) +} + +func (o *PutGuestVsockNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewPutGuestVsockBadRequest creates a PutGuestVsockBadRequest with default headers values +func NewPutGuestVsockBadRequest() *PutGuestVsockBadRequest { + return &PutGuestVsockBadRequest{} +} + +/*PutGuestVsockBadRequest handles this case with default header values. + +Vsock cannot be created due to bad input +*/ +type PutGuestVsockBadRequest struct { + Payload *models.Error +} + +func (o *PutGuestVsockBadRequest) Error() string { + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockBadRequest %+v", 400, o.Payload) +} + +func (o *PutGuestVsockBadRequest) 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 +} + +// NewPutGuestVsockDefault creates a PutGuestVsockDefault with default headers values +func NewPutGuestVsockDefault(code int) *PutGuestVsockDefault { + return &PutGuestVsockDefault{ + _statusCode: code, + } +} + +/*PutGuestVsockDefault handles this case with default header values. + +Internal server error +*/ +type PutGuestVsockDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the put guest vsock default response +func (o *PutGuestVsockDefault) Code() int { + return o._statusCode +} + +func (o *PutGuestVsockDefault) Error() string { + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsock default %+v", o._statusCode, o.Payload) +} + +func (o *PutGuestVsockDefault) 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/virtcontainers/pkg/firecracker/client/operations/put_logger_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_logger_responses.go index b9bfebe9fb..c986768786 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_logger_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_logger_responses.go @@ -24,18 +24,21 @@ type PutLoggerReader struct { // ReadResponse reads a server response into the received o. func (o *PutLoggerReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutLoggerNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutLoggerBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutLoggerDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutLoggerBadRequest) Error() string { return fmt.Sprintf("[PUT /logger][%d] putLoggerBadRequest %+v", 400, o.Payload) } -func (o *PutLoggerBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutLoggerBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutLoggerDefault) Error() string { return fmt.Sprintf("[PUT /logger][%d] putLogger default %+v", o._statusCode, o.Payload) } -func (o *PutLoggerDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutLoggerDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_machine_configuration_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_machine_configuration_responses.go index f36aa154f3..6127fea6e3 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_machine_configuration_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_machine_configuration_responses.go @@ -24,18 +24,21 @@ type PutMachineConfigurationReader struct { // ReadResponse reads a server response into the received o. func (o *PutMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutMachineConfigurationNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutMachineConfigurationBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutMachineConfigurationDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutMachineConfigurationBadRequest) Error() string { return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationBadRequest %+v", 400, o.Payload) } -func (o *PutMachineConfigurationBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutMachineConfigurationBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutMachineConfigurationDefault) Error() string { return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfiguration default %+v", o._statusCode, o.Payload) } -func (o *PutMachineConfigurationDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutMachineConfigurationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/client/operations/put_mmds_responses.go b/virtcontainers/pkg/firecracker/client/operations/put_mmds_responses.go index 1f8116d71f..7b1e47b35e 100644 --- a/virtcontainers/pkg/firecracker/client/operations/put_mmds_responses.go +++ b/virtcontainers/pkg/firecracker/client/operations/put_mmds_responses.go @@ -24,18 +24,21 @@ type PutMmdsReader struct { // ReadResponse reads a server response into the received o. func (o *PutMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { + case 204: result := NewPutMmdsNoContent() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil + case 400: result := NewPutMmdsBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return nil, result + default: result := NewPutMmdsDefault(response.Code()) if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -86,10 +89,6 @@ func (o *PutMmdsBadRequest) Error() string { return fmt.Sprintf("[PUT /mmds][%d] putMmdsBadRequest %+v", 400, o.Payload) } -func (o *PutMmdsBadRequest) GetPayload() *models.Error { - return o.Payload -} - func (o *PutMmdsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) @@ -128,10 +127,6 @@ func (o *PutMmdsDefault) Error() string { return fmt.Sprintf("[PUT /mmds][%d] PutMmds default %+v", o._statusCode, o.Payload) } -func (o *PutMmdsDefault) GetPayload() *models.Error { - return o.Payload -} - func (o *PutMmdsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { o.Payload = new(models.Error) diff --git a/virtcontainers/pkg/firecracker/firecracker-experimental.yaml b/virtcontainers/pkg/firecracker/firecracker.yaml similarity index 97% rename from virtcontainers/pkg/firecracker/firecracker-experimental.yaml rename to virtcontainers/pkg/firecracker/firecracker.yaml index e54415e007..5f7fcbdc8f 100644 --- a/virtcontainers/pkg/firecracker/firecracker-experimental.yaml +++ b/virtcontainers/pkg/firecracker/firecracker.yaml @@ -5,7 +5,7 @@ info: The API is accessible through HTTP calls on specific URLs carrying JSON modeled data. The transport medium is a Unix Domain Socket. - version: 0.18.0 + version: 0.19.0 termsOfService: "" contact: email: "compute-capsule@amazon.com" @@ -353,19 +353,15 @@ paths: schema: $ref: "#/definitions/Error" - /vsocks/{id}: + /vsock: put: - summary: Creates new vsock with ID specified by the id parameter. + summary: Creates/updates a vsock device. description: - If the vsock device with the specified ID already exists, its body will - be updated based on the new input. May fail if update is not possible. - operationId: putGuestVsockByID + The first call creates the device with the configuration specified + in body. Subsequent calls will update the device configuration. + May fail if update is not possible. + operationId: putGuestVsock parameters: - - name: id - in: path - description: The id of the vsock device - required: true - type: string - name: body in: body description: Guest vsock properties @@ -481,8 +477,6 @@ definitions: - Uninitialized - Starting - Running - - Halting - - Halted vmm_version: description: MicroVM hypervisor build version. type: string