From f1babe9e980f32d8901b2f9943ed1e1ffb01d610 Mon Sep 17 00:00:00 2001 From: JooYoung Park Date: Sat, 22 Nov 2025 04:59:11 -0700 Subject: [PATCH] Bump up go-swagger version Signed-off-by: JooYoung Park --- client/firecracker_client.go | 3 +- client/models/balloon.go | 9 +- client/models/balloon_stats.go | 9 +- client/models/balloon_stats_update.go | 9 +- client/models/balloon_update.go | 9 +- client/models/boot_source.go | 9 +- client/models/cpu_config.go | 9 +- client/models/cpu_template.go | 23 +- client/models/drive.go | 68 +++- client/models/entropy_device.go | 53 ++- client/models/error.go | 29 +- client/models/firecracker_version.go | 9 +- client/models/full_vm_configuration.go | 366 +++++++++++++++++- client/models/instance_action_info.go | 16 +- client/models/instance_info.go | 16 +- client/models/logger.go | 17 +- client/models/machine_configuration.go | 67 +++- client/models/memory_backend.go | 16 +- client/models/metrics.go | 9 +- client/models/mmds_config.go | 17 +- client/models/mmds_contents_object.go | 3 +- client/models/network_interface.go | 91 ++++- client/models/partial_drive.go | 53 ++- client/models/partial_network_interface.go | 91 ++++- client/models/rate_limiter.go | 91 ++++- client/models/snapshot_create_params.go | 17 +- client/models/snapshot_load_params.go | 53 ++- client/models/token_bucket.go | 16 +- client/models/vm.go | 16 +- client/models/vsock.go | 11 +- .../operations/create_snapshot_parameters.go | 54 ++- .../operations/create_snapshot_responses.go | 129 +++++- .../create_sync_action_parameters.go | 52 ++- .../create_sync_action_responses.go | 129 +++++- .../describe_balloon_config_parameters.go | 47 ++- .../describe_balloon_config_responses.go | 133 ++++++- .../describe_balloon_stats_parameters.go | 47 ++- .../describe_balloon_stats_responses.go | 133 ++++++- .../describe_instance_parameters.go | 47 ++- .../operations/describe_instance_responses.go | 90 ++++- .../get_export_vm_config_parameters.go | 47 ++- .../get_export_vm_config_responses.go | 90 ++++- .../get_firecracker_version_parameters.go | 47 ++- .../get_firecracker_version_responses.go | 90 ++++- .../get_machine_configuration_parameters.go | 47 ++- .../get_machine_configuration_responses.go | 90 ++++- client/operations/get_mmds_parameters.go | 47 ++- client/operations/get_mmds_responses.go | 137 ++++++- client/operations/load_snapshot_parameters.go | 54 ++- client/operations/load_snapshot_responses.go | 129 +++++- client/operations/patch_balloon_parameters.go | 54 ++- client/operations/patch_balloon_responses.go | 129 +++++- ...patch_balloon_stats_interval_parameters.go | 54 ++- .../patch_balloon_stats_interval_responses.go | 129 +++++- .../patch_guest_drive_by_id_parameters.go | 59 +-- .../patch_guest_drive_by_id_responses.go | 129 +++++- ...uest_network_interface_by_id_parameters.go | 59 +-- ...guest_network_interface_by_id_responses.go | 129 +++++- .../patch_machine_configuration_parameters.go | 54 ++- .../patch_machine_configuration_responses.go | 129 +++++- client/operations/patch_mmds_parameters.go | 54 ++- client/operations/patch_mmds_responses.go | 129 +++++- client/operations/patch_vm_parameters.go | 54 ++- client/operations/patch_vm_responses.go | 129 +++++- client/operations/put_balloon_parameters.go | 54 ++- client/operations/put_balloon_responses.go | 129 +++++- .../put_cpu_configuration_parameters.go | 54 ++- .../put_cpu_configuration_responses.go | 129 +++++- .../put_entropy_device_parameters.go | 54 ++- .../put_entropy_device_responses.go | 86 +++- .../put_guest_boot_source_parameters.go | 54 ++- .../put_guest_boot_source_responses.go | 129 +++++- .../put_guest_drive_by_id_parameters.go | 59 +-- .../put_guest_drive_by_id_responses.go | 129 +++++- ...uest_network_interface_by_id_parameters.go | 59 +-- ...guest_network_interface_by_id_responses.go | 129 +++++- .../operations/put_guest_vsock_parameters.go | 54 ++- .../operations/put_guest_vsock_responses.go | 129 +++++- client/operations/put_logger_parameters.go | 54 ++- client/operations/put_logger_responses.go | 129 +++++- .../put_machine_configuration_parameters.go | 54 ++- .../put_machine_configuration_responses.go | 129 +++++- client/operations/put_metrics_parameters.go | 54 ++- client/operations/put_metrics_responses.go | 129 +++++- .../operations/put_mmds_config_parameters.go | 54 ++- .../operations/put_mmds_config_responses.go | 129 +++++- client/operations/put_mmds_parameters.go | 54 ++- client/operations/put_mmds_responses.go | 129 +++++- machine_test.go | 2 +- swagger.go | 6 +- 90 files changed, 5275 insertions(+), 1031 deletions(-) diff --git a/client/firecracker_client.go b/client/firecracker_client.go index c021c062..66d9e7f0 100644 --- a/client/firecracker_client.go +++ b/client/firecracker_client.go @@ -19,12 +19,11 @@ package client // Editing this file might prove futile when you re-run the swagger generate command import ( + "github.com/firecracker-microvm/firecracker-go-sdk/client/operations" "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" strfmt "github.com/go-openapi/strfmt" - - "github.com/firecracker-microvm/firecracker-go-sdk/client/operations" ) // Default firecracker HTTP client. diff --git a/client/models/balloon.go b/client/models/balloon.go index ef07d0dd..e09313da 100644 --- a/client/models/balloon.go +++ b/client/models/balloon.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Balloon Balloon device descriptor. +// // swagger:model Balloon type Balloon struct { @@ -78,6 +80,11 @@ func (m *Balloon) validateDeflateOnOom(formats strfmt.Registry) error { return nil } +// ContextValidate validates this balloon based on context it is used +func (m *Balloon) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Balloon) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/balloon_stats.go b/client/models/balloon_stats.go index 63956879..98b1431b 100644 --- a/client/models/balloon_stats.go +++ b/client/models/balloon_stats.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // BalloonStats Describes the balloon device statistics. +// // swagger:model BalloonStats type BalloonStats struct { @@ -139,6 +141,11 @@ func (m *BalloonStats) validateTargetPages(formats strfmt.Registry) error { return nil } +// ContextValidate validates this balloon stats based on context it is used +func (m *BalloonStats) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *BalloonStats) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/balloon_stats_update.go b/client/models/balloon_stats_update.go index 571687ff..e605b5a9 100644 --- a/client/models/balloon_stats_update.go +++ b/client/models/balloon_stats_update.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // BalloonStatsUpdate Update the statistics polling interval, with the first statistics update scheduled immediately. Statistics cannot be turned on/off after boot. +// // swagger:model BalloonStatsUpdate type BalloonStatsUpdate struct { @@ -58,6 +60,11 @@ func (m *BalloonStatsUpdate) validateStatsPollingIntervals(formats strfmt.Regist return nil } +// ContextValidate validates this balloon stats update based on context it is used +func (m *BalloonStatsUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *BalloonStatsUpdate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/balloon_update.go b/client/models/balloon_update.go index e2b379fa..6957dcf9 100644 --- a/client/models/balloon_update.go +++ b/client/models/balloon_update.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // BalloonUpdate Balloon device descriptor. +// // swagger:model BalloonUpdate type BalloonUpdate struct { @@ -58,6 +60,11 @@ func (m *BalloonUpdate) validateAmountMib(formats strfmt.Registry) error { return nil } +// ContextValidate validates this balloon update based on context it is used +func (m *BalloonUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *BalloonUpdate) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/boot_source.go b/client/models/boot_source.go index 759e339c..c3213ae5 100644 --- a/client/models/boot_source.go +++ b/client/models/boot_source.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // BootSource Boot source descriptor. +// // swagger:model BootSource type BootSource struct { @@ -64,6 +66,11 @@ func (m *BootSource) validateKernelImagePath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this boot source based on context it is used +func (m *BootSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *BootSource) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/cpu_config.go b/client/models/cpu_config.go index 73a3c60d..579a67f2 100644 --- a/client/models/cpu_config.go +++ b/client/models/cpu_config.go @@ -19,12 +19,14 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" ) // CPUConfig The CPU configuration template defines a set of bit maps as modifiers of flags accessed by register to be disabled/enabled for the microvm. +// // swagger:model CpuConfig type CPUConfig string @@ -37,3 +39,8 @@ func (m CPUConfig) Validate(formats strfmt.Registry) error { } return nil } + +// ContextValidate validates this Cpu config based on context it is used +func (m CPUConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/cpu_template.go b/client/models/cpu_template.go index 42d4c796..d4e6e7c8 100644 --- a/client/models/cpu_template.go +++ b/client/models/cpu_template.go @@ -19,18 +19,28 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" ) // CPUTemplate The CPU Template defines a set of flags to be disabled from the microvm so that the features exposed to the guest are the same as in the selected instance type. +// // swagger:model CpuTemplate type CPUTemplate string +func NewCPUTemplate(value CPUTemplate) *CPUTemplate { + return &value +} + +// Pointer returns a pointer to a freshly-allocated CPUTemplate. +func (m CPUTemplate) Pointer() *CPUTemplate { + return &m +} + const ( // CPUTemplateC3 captures enum value "C3" @@ -56,7 +66,7 @@ const ( ) // for schema -var cpuTemplateEnum []interface{} +var cpuTemplateEnum []any func init() { var res []CPUTemplate @@ -69,7 +79,7 @@ func init() { } func (m CPUTemplate) validateCPUTemplateEnum(path, location string, value CPUTemplate) error { - if err := validate.Enum(path, location, value, cpuTemplateEnum); err != nil { + if err := validate.EnumCase(path, location, value, cpuTemplateEnum, true); err != nil { return err } return nil @@ -89,3 +99,8 @@ func (m CPUTemplate) Validate(formats strfmt.Registry) error { } return nil } + +// ContextValidate validates this Cpu template based on context it is used +func (m CPUTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/client/models/drive.go b/client/models/drive.go index 310891b2..fa9e1c24 100644 --- a/client/models/drive.go +++ b/client/models/drive.go @@ -19,21 +19,23 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - - strfmt "github.com/go-openapi/strfmt" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Drive drive +// // swagger:model Drive type Drive struct { // Represents the caching strategy for the block device. - // Enum: [Unsafe Writeback] + // Enum: ["Unsafe","Writeback"] CacheType *string `json:"cache_type,omitempty"` // drive id @@ -41,7 +43,7 @@ type Drive struct { DriveID *string `json:"drive_id"` // Type of the IO engine used by the device. "Async" is supported on host kernels newer than 5.10.51. - // Enum: [Sync Async] + // Enum: ["Sync","Async"] IoEngine *string `json:"io_engine,omitempty"` // is read only @@ -101,7 +103,7 @@ func (m *Drive) Validate(formats strfmt.Registry) error { return nil } -var driveTypeCacheTypePropEnum []interface{} +var driveTypeCacheTypePropEnum []any func init() { var res []string @@ -124,14 +126,13 @@ const ( // prop value enum func (m *Drive) validateCacheTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, driveTypeCacheTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, driveTypeCacheTypePropEnum, true); err != nil { return err } return nil } func (m *Drive) validateCacheType(formats strfmt.Registry) error { - if swag.IsZero(m.CacheType) { // not required return nil } @@ -153,7 +154,7 @@ func (m *Drive) validateDriveID(formats strfmt.Registry) error { return nil } -var driveTypeIoEnginePropEnum []interface{} +var driveTypeIoEnginePropEnum []any func init() { var res []string @@ -176,14 +177,13 @@ const ( // prop value enum func (m *Drive) validateIoEngineEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, driveTypeIoEnginePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, driveTypeIoEnginePropEnum, true); err != nil { return err } return nil } func (m *Drive) validateIoEngine(formats strfmt.Registry) error { - if swag.IsZero(m.IoEngine) { // not required return nil } @@ -224,16 +224,60 @@ func (m *Drive) validatePathOnHost(formats strfmt.Registry) error { } func (m *Drive) validateRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.RateLimiter) { // not required return nil } if m.RateLimiter != nil { if err := m.RateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this drive based on the context it is used +func (m *Drive) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Drive) contextValidateRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.RateLimiter != nil { + + if swag.IsZero(m.RateLimiter) { // not required + return nil + } + + if err := m.RateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + return err } } diff --git a/client/models/entropy_device.go b/client/models/entropy_device.go index 28d2fd70..2865cb75 100644 --- a/client/models/entropy_device.go +++ b/client/models/entropy_device.go @@ -19,13 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // EntropyDevice Defines an entropy device. +// // swagger:model EntropyDevice type EntropyDevice struct { @@ -48,16 +51,60 @@ func (m *EntropyDevice) Validate(formats strfmt.Registry) error { } func (m *EntropyDevice) validateRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.RateLimiter) { // not required return nil } if m.RateLimiter != nil { if err := m.RateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this entropy device based on the context it is used +func (m *EntropyDevice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EntropyDevice) contextValidateRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.RateLimiter != nil { + + if swag.IsZero(m.RateLimiter) { // not required + return nil + } + + if err := m.RateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + return err } } diff --git a/client/models/error.go b/client/models/error.go index c931792e..4c26d741 100644 --- a/client/models/error.go +++ b/client/models/error.go @@ -19,12 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // Error error +// // swagger:model Error type Error struct { @@ -38,6 +42,29 @@ func (m *Error) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate validate this error based on the context it is used +func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateFaultMessage(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Error) contextValidateFaultMessage(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "fault_message", "body", m.FaultMessage); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/firecracker_version.go b/client/models/firecracker_version.go index 52325721..0b6cd1c2 100644 --- a/client/models/firecracker_version.go +++ b/client/models/firecracker_version.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // FirecrackerVersion Describes the Firecracker version. +// // swagger:model FirecrackerVersion type FirecrackerVersion struct { @@ -58,6 +60,11 @@ func (m *FirecrackerVersion) validateFirecrackerVersion(formats strfmt.Registry) return nil } +// ContextValidate validates this firecracker version based on context it is used +func (m *FirecrackerVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *FirecrackerVersion) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/full_vm_configuration.go b/client/models/full_vm_configuration.go index 7d5889f7..c05a91ea 100644 --- a/client/models/full_vm_configuration.go +++ b/client/models/full_vm_configuration.go @@ -19,15 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + stderrors "errors" "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // FullVMConfiguration full Vm configuration +// // swagger:model FullVmConfiguration type FullVMConfiguration struct { @@ -106,16 +108,21 @@ func (m *FullVMConfiguration) Validate(formats strfmt.Registry) error { } func (m *FullVMConfiguration) validateBalloon(formats strfmt.Registry) error { - if swag.IsZero(m.Balloon) { // not required return nil } if m.Balloon != nil { if err := m.Balloon.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("balloon") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("balloon") + } + return err } } @@ -124,16 +131,21 @@ func (m *FullVMConfiguration) validateBalloon(formats strfmt.Registry) error { } func (m *FullVMConfiguration) validateBootSource(formats strfmt.Registry) error { - if swag.IsZero(m.BootSource) { // not required return nil } if m.BootSource != nil { if err := m.BootSource.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("boot-source") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("boot-source") + } + return err } } @@ -142,7 +154,6 @@ func (m *FullVMConfiguration) validateBootSource(formats strfmt.Registry) error } func (m *FullVMConfiguration) validateDrives(formats strfmt.Registry) error { - if swag.IsZero(m.Drives) { // not required return nil } @@ -154,9 +165,15 @@ func (m *FullVMConfiguration) validateDrives(formats strfmt.Registry) error { if m.Drives[i] != nil { if err := m.Drives[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("drives" + "." + strconv.Itoa(i)) } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("drives" + "." + strconv.Itoa(i)) + } + return err } } @@ -167,16 +184,21 @@ func (m *FullVMConfiguration) validateDrives(formats strfmt.Registry) error { } func (m *FullVMConfiguration) validateLogger(formats strfmt.Registry) error { - if swag.IsZero(m.Logger) { // not required return nil } if m.Logger != nil { if err := m.Logger.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("logger") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("logger") + } + return err } } @@ -185,16 +207,21 @@ func (m *FullVMConfiguration) validateLogger(formats strfmt.Registry) error { } func (m *FullVMConfiguration) validateMachineConfig(formats strfmt.Registry) error { - if swag.IsZero(m.MachineConfig) { // not required return nil } if m.MachineConfig != nil { if err := m.MachineConfig.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("machine-config") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("machine-config") + } + return err } } @@ -203,16 +230,21 @@ func (m *FullVMConfiguration) validateMachineConfig(formats strfmt.Registry) err } func (m *FullVMConfiguration) validateMetrics(formats strfmt.Registry) error { - if swag.IsZero(m.Metrics) { // not required return nil } if m.Metrics != nil { if err := m.Metrics.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("metrics") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("metrics") + } + return err } } @@ -221,16 +253,21 @@ func (m *FullVMConfiguration) validateMetrics(formats strfmt.Registry) error { } func (m *FullVMConfiguration) validateMmdsConfig(formats strfmt.Registry) error { - if swag.IsZero(m.MmdsConfig) { // not required return nil } if m.MmdsConfig != nil { if err := m.MmdsConfig.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("mmds-config") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("mmds-config") + } + return err } } @@ -239,7 +276,6 @@ func (m *FullVMConfiguration) validateMmdsConfig(formats strfmt.Registry) error } func (m *FullVMConfiguration) validateNetworkInterfaces(formats strfmt.Registry) error { - if swag.IsZero(m.NetworkInterfaces) { // not required return nil } @@ -251,9 +287,15 @@ func (m *FullVMConfiguration) validateNetworkInterfaces(formats strfmt.Registry) if m.NetworkInterfaces[i] != nil { if err := m.NetworkInterfaces[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("network-interfaces" + "." + strconv.Itoa(i)) } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("network-interfaces" + "." + strconv.Itoa(i)) + } + return err } } @@ -264,16 +306,300 @@ func (m *FullVMConfiguration) validateNetworkInterfaces(formats strfmt.Registry) } func (m *FullVMConfiguration) validateVsock(formats strfmt.Registry) error { - if swag.IsZero(m.Vsock) { // not required return nil } if m.Vsock != nil { if err := m.Vsock.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("vsock") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("vsock") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this full Vm configuration based on the context it is used +func (m *FullVMConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBalloon(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateBootSource(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDrives(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLogger(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMachineConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMetrics(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMmdsConfig(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNetworkInterfaces(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVsock(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *FullVMConfiguration) contextValidateBalloon(ctx context.Context, formats strfmt.Registry) error { + + if m.Balloon != nil { + + if swag.IsZero(m.Balloon) { // not required + return nil + } + + if err := m.Balloon.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("balloon") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("balloon") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateBootSource(ctx context.Context, formats strfmt.Registry) error { + + if m.BootSource != nil { + + if swag.IsZero(m.BootSource) { // not required + return nil + } + + if err := m.BootSource.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("boot-source") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("boot-source") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateDrives(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Drives); i++ { + + if m.Drives[i] != nil { + + if swag.IsZero(m.Drives[i]) { // not required + return nil + } + + if err := m.Drives[i].ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("drives" + "." + strconv.Itoa(i)) + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("drives" + "." + strconv.Itoa(i)) + } + + return err + } + } + + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateLogger(ctx context.Context, formats strfmt.Registry) error { + + if m.Logger != nil { + + if swag.IsZero(m.Logger) { // not required + return nil + } + + if err := m.Logger.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("logger") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("logger") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateMachineConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.MachineConfig != nil { + + if swag.IsZero(m.MachineConfig) { // not required + return nil + } + + if err := m.MachineConfig.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("machine-config") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("machine-config") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateMetrics(ctx context.Context, formats strfmt.Registry) error { + + if m.Metrics != nil { + + if swag.IsZero(m.Metrics) { // not required + return nil + } + + if err := m.Metrics.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("metrics") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("metrics") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateMmdsConfig(ctx context.Context, formats strfmt.Registry) error { + + if m.MmdsConfig != nil { + + if swag.IsZero(m.MmdsConfig) { // not required + return nil + } + + if err := m.MmdsConfig.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("mmds-config") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("mmds-config") + } + + return err + } + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateNetworkInterfaces(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.NetworkInterfaces); i++ { + + if m.NetworkInterfaces[i] != nil { + + if swag.IsZero(m.NetworkInterfaces[i]) { // not required + return nil + } + + if err := m.NetworkInterfaces[i].ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("network-interfaces" + "." + strconv.Itoa(i)) + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("network-interfaces" + "." + strconv.Itoa(i)) + } + + return err + } + } + + } + + return nil +} + +func (m *FullVMConfiguration) contextValidateVsock(ctx context.Context, formats strfmt.Registry) error { + + if m.Vsock != nil { + + if swag.IsZero(m.Vsock) { // not required + return nil + } + + if err := m.Vsock.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("vsock") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("vsock") + } + return err } } diff --git a/client/models/instance_action_info.go b/client/models/instance_action_info.go index e7438e9b..a9e88b3c 100644 --- a/client/models/instance_action_info.go +++ b/client/models/instance_action_info.go @@ -19,22 +19,23 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InstanceActionInfo Variant wrapper containing the real action. +// // swagger:model InstanceActionInfo type InstanceActionInfo struct { // Enumeration indicating what type of action is contained in the payload // Required: true - // Enum: [FlushMetrics InstanceStart SendCtrlAltDel] + // Enum: ["FlushMetrics","InstanceStart","SendCtrlAltDel"] ActionType *string `json:"action_type"` } @@ -52,7 +53,7 @@ func (m *InstanceActionInfo) Validate(formats strfmt.Registry) error { return nil } -var instanceActionInfoTypeActionTypePropEnum []interface{} +var instanceActionInfoTypeActionTypePropEnum []any func init() { var res []string @@ -78,7 +79,7 @@ const ( // prop value enum func (m *InstanceActionInfo) validateActionTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, instanceActionInfoTypeActionTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, instanceActionInfoTypeActionTypePropEnum, true); err != nil { return err } return nil @@ -98,6 +99,11 @@ func (m *InstanceActionInfo) validateActionType(formats strfmt.Registry) error { return nil } +// ContextValidate validates this instance action info based on context it is used +func (m *InstanceActionInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InstanceActionInfo) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/instance_info.go b/client/models/instance_info.go index 1c2c8997..ddd17f2d 100644 --- a/client/models/instance_info.go +++ b/client/models/instance_info.go @@ -19,16 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // InstanceInfo Describes MicroVM instance information. +// // swagger:model InstanceInfo type InstanceInfo struct { @@ -42,7 +43,7 @@ type InstanceInfo struct { // The current detailed state (Not started, Running, Paused) of the Firecracker instance. This value is read-only for the control-plane. // Required: true - // Enum: [Not started Running Paused] + // Enum: ["Not started","Running","Paused"] State *string `json:"state"` // MicroVM hypervisor build version. @@ -94,7 +95,7 @@ func (m *InstanceInfo) validateID(formats strfmt.Registry) error { return nil } -var instanceInfoTypeStatePropEnum []interface{} +var instanceInfoTypeStatePropEnum []any func init() { var res []string @@ -120,7 +121,7 @@ const ( // prop value enum func (m *InstanceInfo) validateStateEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, instanceInfoTypeStatePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, instanceInfoTypeStatePropEnum, true); err != nil { return err } return nil @@ -149,6 +150,11 @@ func (m *InstanceInfo) validateVmmVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validates this instance info based on context it is used +func (m *InstanceInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *InstanceInfo) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/logger.go b/client/models/logger.go index d15cf68b..85698100 100644 --- a/client/models/logger.go +++ b/client/models/logger.go @@ -19,21 +19,22 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Logger Describes the configuration option for the logging capability. +// // swagger:model Logger type Logger struct { // Set the level. The possible values are case-insensitive. - // Enum: [Error Warning Info Debug] + // Enum: ["Error","Warning","Info","Debug"] Level *string `json:"level,omitempty"` // Path to the named pipe or file for the human readable log output. @@ -65,7 +66,7 @@ func (m *Logger) Validate(formats strfmt.Registry) error { return nil } -var loggerTypeLevelPropEnum []interface{} +var loggerTypeLevelPropEnum []any func init() { var res []string @@ -94,14 +95,13 @@ const ( // prop value enum func (m *Logger) validateLevelEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, loggerTypeLevelPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, loggerTypeLevelPropEnum, true); err != nil { return err } return nil } func (m *Logger) validateLevel(formats strfmt.Registry) error { - if swag.IsZero(m.Level) { // not required return nil } @@ -123,6 +123,11 @@ func (m *Logger) validateLogPath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this logger based on context it is used +func (m *Logger) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Logger) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/machine_configuration.go b/client/models/machine_configuration.go index 8cde7bf0..d5cce376 100644 --- a/client/models/machine_configuration.go +++ b/client/models/machine_configuration.go @@ -19,19 +19,22 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // MachineConfiguration Describes the number of vCPUs, memory size, SMT capabilities and the CPU template. +// // swagger:model MachineConfiguration type MachineConfiguration struct { // cpu template - CPUTemplate CPUTemplate `json:"cpu_template,omitempty"` + CPUTemplate *CPUTemplate `json:"cpu_template,omitempty"` // Memory size of VM // Required: true @@ -73,16 +76,23 @@ func (m *MachineConfiguration) Validate(formats strfmt.Registry) error { } func (m *MachineConfiguration) validateCPUTemplate(formats strfmt.Registry) error { - if swag.IsZero(m.CPUTemplate) { // not required return nil } - if err := m.CPUTemplate.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("cpu_template") + if m.CPUTemplate != nil { + if err := m.CPUTemplate.Validate(formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("cpu_template") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("cpu_template") + } + + return err } - return err } return nil @@ -103,17 +113,56 @@ func (m *MachineConfiguration) validateVcpuCount(formats strfmt.Registry) error return err } - if err := validate.MinimumInt("vcpu_count", "body", int64(*m.VcpuCount), 1, false); err != nil { + if err := validate.MinimumInt("vcpu_count", "body", *m.VcpuCount, 1, false); err != nil { return err } - if err := validate.MaximumInt("vcpu_count", "body", int64(*m.VcpuCount), 32, false); err != nil { + if err := validate.MaximumInt("vcpu_count", "body", *m.VcpuCount, 32, false); err != nil { return err } return nil } +// ContextValidate validate this machine configuration based on the context it is used +func (m *MachineConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCPUTemplate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MachineConfiguration) contextValidateCPUTemplate(ctx context.Context, formats strfmt.Registry) error { + + if m.CPUTemplate != nil { + + if swag.IsZero(m.CPUTemplate) { // not required + return nil + } + + if err := m.CPUTemplate.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("cpu_template") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("cpu_template") + } + + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *MachineConfiguration) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/memory_backend.go b/client/models/memory_backend.go index c0a58b81..ee4b752b 100644 --- a/client/models/memory_backend.go +++ b/client/models/memory_backend.go @@ -19,16 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // MemoryBackend memory backend +// // swagger:model MemoryBackend type MemoryBackend struct { @@ -38,7 +39,7 @@ type MemoryBackend struct { // backend type // Required: true - // Enum: [File Uffd] + // Enum: ["File","Uffd"] BackendType *string `json:"backend_type"` } @@ -69,7 +70,7 @@ func (m *MemoryBackend) validateBackendPath(formats strfmt.Registry) error { return nil } -var memoryBackendTypeBackendTypePropEnum []interface{} +var memoryBackendTypeBackendTypePropEnum []any func init() { var res []string @@ -92,7 +93,7 @@ const ( // prop value enum func (m *MemoryBackend) validateBackendTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, memoryBackendTypeBackendTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, memoryBackendTypeBackendTypePropEnum, true); err != nil { return err } return nil @@ -112,6 +113,11 @@ func (m *MemoryBackend) validateBackendType(formats strfmt.Registry) error { return nil } +// ContextValidate validates this memory backend based on context it is used +func (m *MemoryBackend) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *MemoryBackend) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/metrics.go b/client/models/metrics.go index 4d6fc972..49b6a2dd 100644 --- a/client/models/metrics.go +++ b/client/models/metrics.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Metrics Describes the configuration option for the metrics capability. +// // swagger:model Metrics type Metrics struct { @@ -58,6 +60,11 @@ func (m *Metrics) validateMetricsPath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this metrics based on context it is used +func (m *Metrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Metrics) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/mmds_config.go b/client/models/mmds_config.go index 659d9899..4375bbae 100644 --- a/client/models/mmds_config.go +++ b/client/models/mmds_config.go @@ -19,16 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // MmdsConfig Defines the MMDS configuration. +// // swagger:model MmdsConfig type MmdsConfig struct { @@ -40,7 +41,7 @@ type MmdsConfig struct { NetworkInterfaces []string `json:"network_interfaces"` // Enumeration indicating the MMDS version to be configured. - // Enum: [V1 V2] + // Enum: ["V1","V2"] Version *string `json:"version,omitempty"` } @@ -71,7 +72,7 @@ func (m *MmdsConfig) validateNetworkInterfaces(formats strfmt.Registry) error { return nil } -var mmdsConfigTypeVersionPropEnum []interface{} +var mmdsConfigTypeVersionPropEnum []any func init() { var res []string @@ -94,14 +95,13 @@ const ( // prop value enum func (m *MmdsConfig) validateVersionEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, mmdsConfigTypeVersionPropEnum); err != nil { + if err := validate.EnumCase(path, location, value, mmdsConfigTypeVersionPropEnum, true); err != nil { return err } return nil } func (m *MmdsConfig) validateVersion(formats strfmt.Registry) error { - if swag.IsZero(m.Version) { // not required return nil } @@ -114,6 +114,11 @@ func (m *MmdsConfig) validateVersion(formats strfmt.Registry) error { return nil } +// ContextValidate validates this mmds config based on context it is used +func (m *MmdsConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *MmdsConfig) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/mmds_contents_object.go b/client/models/mmds_contents_object.go index 314ec9f8..eb85908c 100644 --- a/client/models/mmds_contents_object.go +++ b/client/models/mmds_contents_object.go @@ -19,5 +19,6 @@ package models // Editing this file might prove futile when you re-run the swagger generate command // MmdsContentsObject Describes the contents of MMDS in JSON format. +// // swagger:model MmdsContentsObject -type MmdsContentsObject interface{} +type MmdsContentsObject any diff --git a/client/models/network_interface.go b/client/models/network_interface.go index 1962d6f0..84335929 100644 --- a/client/models/network_interface.go +++ b/client/models/network_interface.go @@ -19,14 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // NetworkInterface Defines a network interface. +// // swagger:model NetworkInterface type NetworkInterface struct { @@ -93,16 +96,21 @@ func (m *NetworkInterface) validateIfaceID(formats strfmt.Registry) error { } func (m *NetworkInterface) validateRxRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.RxRateLimiter) { // not required return nil } if m.RxRateLimiter != nil { if err := m.RxRateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("rx_rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rx_rate_limiter") + } + return err } } @@ -111,16 +119,89 @@ func (m *NetworkInterface) validateRxRateLimiter(formats strfmt.Registry) error } func (m *NetworkInterface) validateTxRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.TxRateLimiter) { // not required return nil } if m.TxRateLimiter != nil { if err := m.TxRateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("tx_rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("tx_rate_limiter") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this network interface based on the context it is used +func (m *NetworkInterface) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRxRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTxRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NetworkInterface) contextValidateRxRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.RxRateLimiter != nil { + + if swag.IsZero(m.RxRateLimiter) { // not required + return nil + } + + if err := m.RxRateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("rx_rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rx_rate_limiter") + } + + return err + } + } + + return nil +} + +func (m *NetworkInterface) contextValidateTxRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.TxRateLimiter != nil { + + if swag.IsZero(m.TxRateLimiter) { // not required + return nil + } + + if err := m.TxRateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("tx_rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("tx_rate_limiter") + } + return err } } diff --git a/client/models/partial_drive.go b/client/models/partial_drive.go index 6c85ef7b..71747eec 100644 --- a/client/models/partial_drive.go +++ b/client/models/partial_drive.go @@ -19,14 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PartialDrive partial drive +// // swagger:model PartialDrive type PartialDrive struct { @@ -69,16 +72,60 @@ func (m *PartialDrive) validateDriveID(formats strfmt.Registry) error { } func (m *PartialDrive) validateRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.RateLimiter) { // not required return nil } if m.RateLimiter != nil { if err := m.RateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this partial drive based on the context it is used +func (m *PartialDrive) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PartialDrive) contextValidateRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.RateLimiter != nil { + + if swag.IsZero(m.RateLimiter) { // not required + return nil + } + + if err := m.RateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rate_limiter") + } + return err } } diff --git a/client/models/partial_network_interface.go b/client/models/partial_network_interface.go index c73f3e50..6c595519 100644 --- a/client/models/partial_network_interface.go +++ b/client/models/partial_network_interface.go @@ -19,14 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // PartialNetworkInterface Defines a partial network interface structure, used to update the rate limiters for that interface, after microvm start. +// // swagger:model PartialNetworkInterface type PartialNetworkInterface struct { @@ -73,16 +76,21 @@ func (m *PartialNetworkInterface) validateIfaceID(formats strfmt.Registry) error } func (m *PartialNetworkInterface) validateRxRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.RxRateLimiter) { // not required return nil } if m.RxRateLimiter != nil { if err := m.RxRateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("rx_rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rx_rate_limiter") + } + return err } } @@ -91,16 +99,89 @@ func (m *PartialNetworkInterface) validateRxRateLimiter(formats strfmt.Registry) } func (m *PartialNetworkInterface) validateTxRateLimiter(formats strfmt.Registry) error { - if swag.IsZero(m.TxRateLimiter) { // not required return nil } if m.TxRateLimiter != nil { if err := m.TxRateLimiter.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("tx_rate_limiter") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("tx_rate_limiter") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this partial network interface based on the context it is used +func (m *PartialNetworkInterface) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRxRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTxRateLimiter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PartialNetworkInterface) contextValidateRxRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.RxRateLimiter != nil { + + if swag.IsZero(m.RxRateLimiter) { // not required + return nil + } + + if err := m.RxRateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("rx_rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("rx_rate_limiter") + } + + return err + } + } + + return nil +} + +func (m *PartialNetworkInterface) contextValidateTxRateLimiter(ctx context.Context, formats strfmt.Registry) error { + + if m.TxRateLimiter != nil { + + if swag.IsZero(m.TxRateLimiter) { // not required + return nil + } + + if err := m.TxRateLimiter.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("tx_rate_limiter") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("tx_rate_limiter") + } + return err } } diff --git a/client/models/rate_limiter.go b/client/models/rate_limiter.go index 42b2d0a7..a8dd2cb3 100644 --- a/client/models/rate_limiter.go +++ b/client/models/rate_limiter.go @@ -19,13 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // RateLimiter Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. +// // swagger:model RateLimiter type RateLimiter struct { @@ -55,16 +58,21 @@ func (m *RateLimiter) Validate(formats strfmt.Registry) error { } func (m *RateLimiter) validateBandwidth(formats strfmt.Registry) error { - if swag.IsZero(m.Bandwidth) { // not required return nil } if m.Bandwidth != nil { if err := m.Bandwidth.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("bandwidth") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("bandwidth") + } + return err } } @@ -73,16 +81,89 @@ func (m *RateLimiter) validateBandwidth(formats strfmt.Registry) error { } func (m *RateLimiter) validateOps(formats strfmt.Registry) error { - if swag.IsZero(m.Ops) { // not required return nil } if m.Ops != nil { if err := m.Ops.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("ops") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("ops") + } + + return err + } + } + + return nil +} + +// ContextValidate validate this rate limiter based on the context it is used +func (m *RateLimiter) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateBandwidth(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateOps(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RateLimiter) contextValidateBandwidth(ctx context.Context, formats strfmt.Registry) error { + + if m.Bandwidth != nil { + + if swag.IsZero(m.Bandwidth) { // not required + return nil + } + + if err := m.Bandwidth.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("bandwidth") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("bandwidth") + } + + return err + } + } + + return nil +} + +func (m *RateLimiter) contextValidateOps(ctx context.Context, formats strfmt.Registry) error { + + if m.Ops != nil { + + if swag.IsZero(m.Ops) { // not required + return nil + } + + if err := m.Ops.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("ops") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("ops") + } + return err } } diff --git a/client/models/snapshot_create_params.go b/client/models/snapshot_create_params.go index 79091abc..13f88a29 100644 --- a/client/models/snapshot_create_params.go +++ b/client/models/snapshot_create_params.go @@ -19,16 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SnapshotCreateParams snapshot create params +// // swagger:model SnapshotCreateParams type SnapshotCreateParams struct { @@ -41,7 +42,7 @@ type SnapshotCreateParams struct { SnapshotPath *string `json:"snapshot_path"` // Type of snapshot to create. It is optional and by default, a full snapshot is created. - // Enum: [Full Diff] + // Enum: ["Full","Diff"] SnapshotType string `json:"snapshot_type,omitempty"` // The microVM version for which we want to create the snapshot. It is optional and it defaults to the current version. @@ -88,7 +89,7 @@ func (m *SnapshotCreateParams) validateSnapshotPath(formats strfmt.Registry) err return nil } -var snapshotCreateParamsTypeSnapshotTypePropEnum []interface{} +var snapshotCreateParamsTypeSnapshotTypePropEnum []any func init() { var res []string @@ -111,14 +112,13 @@ const ( // prop value enum func (m *SnapshotCreateParams) validateSnapshotTypeEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, snapshotCreateParamsTypeSnapshotTypePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, snapshotCreateParamsTypeSnapshotTypePropEnum, true); err != nil { return err } return nil } func (m *SnapshotCreateParams) validateSnapshotType(formats strfmt.Registry) error { - if swag.IsZero(m.SnapshotType) { // not required return nil } @@ -131,6 +131,11 @@ func (m *SnapshotCreateParams) validateSnapshotType(formats strfmt.Registry) err return nil } +// ContextValidate validates this snapshot create params based on context it is used +func (m *SnapshotCreateParams) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *SnapshotCreateParams) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/snapshot_load_params.go b/client/models/snapshot_load_params.go index b16beaec..43786850 100644 --- a/client/models/snapshot_load_params.go +++ b/client/models/snapshot_load_params.go @@ -19,14 +19,17 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" + stderrors "errors" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // SnapshotLoadParams Defines the configuration used for handling snapshot resume. Exactly one of the two `mem_*` fields must be present in the body of the request. +// // swagger:model SnapshotLoadParams type SnapshotLoadParams struct { @@ -66,16 +69,21 @@ func (m *SnapshotLoadParams) Validate(formats strfmt.Registry) error { } func (m *SnapshotLoadParams) validateMemBackend(formats strfmt.Registry) error { - if swag.IsZero(m.MemBackend) { // not required return nil } if m.MemBackend != nil { if err := m.MemBackend.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { return ve.ValidateName("mem_backend") } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("mem_backend") + } + return err } } @@ -92,6 +100,45 @@ func (m *SnapshotLoadParams) validateSnapshotPath(formats strfmt.Registry) error return nil } +// ContextValidate validate this snapshot load params based on the context it is used +func (m *SnapshotLoadParams) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMemBackend(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SnapshotLoadParams) contextValidateMemBackend(ctx context.Context, formats strfmt.Registry) error { + + if m.MemBackend != nil { + + if swag.IsZero(m.MemBackend) { // not required + return nil + } + + if err := m.MemBackend.ContextValidate(ctx, formats); err != nil { + ve := new(errors.Validation) + if stderrors.As(err, &ve) { + return ve.ValidateName("mem_backend") + } + ce := new(errors.CompositeError) + if stderrors.As(err, &ce) { + return ce.ValidateName("mem_backend") + } + + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *SnapshotLoadParams) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/token_bucket.go b/client/models/token_bucket.go index 56c759cb..e82dbf72 100644 --- a/client/models/token_bucket.go +++ b/client/models/token_bucket.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // TokenBucket Defines a token bucket with a maximum capacity (size), an initial burst size (one_time_burst) and an interval for refilling purposes (refill_time). The refill-rate is derived from size and refill_time, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill_rate. +// // swagger:model TokenBucket type TokenBucket struct { @@ -68,12 +70,11 @@ func (m *TokenBucket) Validate(formats strfmt.Registry) error { } func (m *TokenBucket) validateOneTimeBurst(formats strfmt.Registry) error { - if swag.IsZero(m.OneTimeBurst) { // not required return nil } - if err := validate.MinimumInt("one_time_burst", "body", int64(*m.OneTimeBurst), 0, false); err != nil { + if err := validate.MinimumInt("one_time_burst", "body", *m.OneTimeBurst, 0, false); err != nil { return err } @@ -86,7 +87,7 @@ func (m *TokenBucket) validateRefillTime(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("refill_time", "body", int64(*m.RefillTime), 0, false); err != nil { + if err := validate.MinimumInt("refill_time", "body", *m.RefillTime, 0, false); err != nil { return err } @@ -99,13 +100,18 @@ func (m *TokenBucket) validateSize(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("size", "body", int64(*m.Size), 0, false); err != nil { + if err := validate.MinimumInt("size", "body", *m.Size, 0, false); err != nil { return err } return nil } +// ContextValidate validates this token bucket based on context it is used +func (m *TokenBucket) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *TokenBucket) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/vm.go b/client/models/vm.go index 8ca5e71f..3d472a27 100644 --- a/client/models/vm.go +++ b/client/models/vm.go @@ -19,22 +19,23 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "encoding/json" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // VM Defines the microVM running state. It is especially useful in the snapshotting context. +// // swagger:model Vm type VM struct { // state // Required: true - // Enum: [Paused Resumed] + // Enum: ["Paused","Resumed"] State *string `json:"state"` } @@ -52,7 +53,7 @@ func (m *VM) Validate(formats strfmt.Registry) error { return nil } -var vmTypeStatePropEnum []interface{} +var vmTypeStatePropEnum []any func init() { var res []string @@ -75,7 +76,7 @@ const ( // prop value enum func (m *VM) validateStateEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, vmTypeStatePropEnum); err != nil { + if err := validate.EnumCase(path, location, value, vmTypeStatePropEnum, true); err != nil { return err } return nil @@ -95,6 +96,11 @@ func (m *VM) validateState(formats strfmt.Registry) error { return nil } +// ContextValidate validates this Vm based on context it is used +func (m *VM) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *VM) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/models/vsock.go b/client/models/vsock.go index 55457fdc..89a4a2c4 100644 --- a/client/models/vsock.go +++ b/client/models/vsock.go @@ -19,14 +19,16 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "context" "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" ) // Vsock Defines a vsock device, backed by a set of Unix Domain Sockets, on the host side. For host-initiated connections, Firecracker will be listening on the Unix socket identified by the path `uds_path`. Firecracker will create this socket, bind and listen on it. Host-initiated connections will be performed by connection to this socket and issuing a connection forwarding request to the desired guest-side vsock port (i.e. `CONNECT 52\n`, to connect to port 52). For guest-initiated connections, Firecracker will expect host software to be bound and listening on Unix sockets at `uds_path_`. E.g. "/path/to/host_vsock.sock_52" for port number 52. +// // swagger:model Vsock type Vsock struct { @@ -67,7 +69,7 @@ func (m *Vsock) validateGuestCid(formats strfmt.Registry) error { return err } - if err := validate.MinimumInt("guest_cid", "body", int64(*m.GuestCid), 3, false); err != nil { + if err := validate.MinimumInt("guest_cid", "body", *m.GuestCid, 3, false); err != nil { return err } @@ -83,6 +85,11 @@ func (m *Vsock) validateUdsPath(formats strfmt.Registry) error { return nil } +// ContextValidate validates this vsock based on context it is used +func (m *Vsock) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // MarshalBinary interface implementation func (m *Vsock) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/client/operations/create_snapshot_parameters.go b/client/operations/create_snapshot_parameters.go index cb3bab20..66abb267 100644 --- a/client/operations/create_snapshot_parameters.go +++ b/client/operations/create_snapshot_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewCreateSnapshotParams creates a new CreateSnapshotParams object -// with the default values initialized. +// NewCreateSnapshotParams creates a new CreateSnapshotParams 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 NewCreateSnapshotParams() *CreateSnapshotParams { - var () return &CreateSnapshotParams{ - timeout: cr.DefaultTimeout, } } // NewCreateSnapshotParamsWithTimeout creates a new CreateSnapshotParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateSnapshotParamsWithTimeout(timeout time.Duration) *CreateSnapshotParams { - var () return &CreateSnapshotParams{ - timeout: timeout, } } // NewCreateSnapshotParamsWithContext creates a new CreateSnapshotParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateSnapshotParamsWithContext(ctx context.Context) *CreateSnapshotParams { - var () return &CreateSnapshotParams{ - Context: ctx, } } // NewCreateSnapshotParamsWithHTTPClient creates a new CreateSnapshotParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateSnapshotParamsWithHTTPClient(client *http.Client) *CreateSnapshotParams { - var () return &CreateSnapshotParams{ HTTPClient: client, } } -/*CreateSnapshotParams contains all the parameters to send to the API endpoint -for the create snapshot operation typically these are written to a http.Request +/* +CreateSnapshotParams contains all the parameters to send to the API endpoint + + for the create snapshot operation. + + Typically these are written to a http.Request. */ type CreateSnapshotParams struct { - /*Body - The configuration used for creating a snaphot. + /* Body. + The configuration used for creating a snaphot. */ Body *models.SnapshotCreateParams @@ -87,6 +87,21 @@ type CreateSnapshotParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create snapshot params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateSnapshotParams) WithDefaults() *CreateSnapshotParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create snapshot params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateSnapshotParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create snapshot params func (o *CreateSnapshotParams) WithTimeout(timeout time.Duration) *CreateSnapshotParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *CreateSnapshotParams) WriteToRequest(r runtime.ClientRequest, reg strfm return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/create_snapshot_responses.go b/client/operations/create_snapshot_responses.go index 3f897d38..7c33dd20 100644 --- a/client/operations/create_snapshot_responses.go +++ b/client/operations/create_snapshot_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // CreateSnapshotReader is a Reader for the CreateSnapshot structure. @@ -35,7 +36,7 @@ type CreateSnapshotReader struct { } // ReadResponse reads a server response into the received o. -func (o *CreateSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *CreateSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewCreateSnapshotNoContent() @@ -66,15 +67,50 @@ func NewCreateSnapshotNoContent() *CreateSnapshotNoContent { return &CreateSnapshotNoContent{} } -/*CreateSnapshotNoContent handles this case with default header values. +/* +CreateSnapshotNoContent describes a response with status code 204, with default header values. Snapshot created */ type CreateSnapshotNoContent struct { } +// IsSuccess returns true when this create snapshot no content response has a 2xx status code +func (o *CreateSnapshotNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create snapshot no content response has a 3xx status code +func (o *CreateSnapshotNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create snapshot no content response has a 4xx status code +func (o *CreateSnapshotNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this create snapshot no content response has a 5xx status code +func (o *CreateSnapshotNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this create snapshot no content response a status code equal to that given +func (o *CreateSnapshotNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the create snapshot no content response +func (o *CreateSnapshotNoContent) Code() int { + return 204 +} + func (o *CreateSnapshotNoContent) Error() string { - return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotNoContent ", 204) + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotNoContent", 204) +} + +func (o *CreateSnapshotNoContent) String() string { + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotNoContent", 204) } func (o *CreateSnapshotNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewCreateSnapshotBadRequest() *CreateSnapshotBadRequest { return &CreateSnapshotBadRequest{} } -/*CreateSnapshotBadRequest handles this case with default header values. +/* +CreateSnapshotBadRequest describes a response with status code 400, with default header values. Snapshot cannot be created due to bad input */ @@ -95,8 +132,44 @@ type CreateSnapshotBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this create snapshot bad request response has a 2xx status code +func (o *CreateSnapshotBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create snapshot bad request response has a 3xx status code +func (o *CreateSnapshotBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create snapshot bad request response has a 4xx status code +func (o *CreateSnapshotBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this create snapshot bad request response has a 5xx status code +func (o *CreateSnapshotBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this create snapshot bad request response a status code equal to that given +func (o *CreateSnapshotBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the create snapshot bad request response +func (o *CreateSnapshotBadRequest) Code() int { + return 400 +} + func (o *CreateSnapshotBadRequest) Error() string { - return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotBadRequest %s", 400, payload) +} + +func (o *CreateSnapshotBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotBadRequest %s", 400, payload) } func (o *CreateSnapshotBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *CreateSnapshotBadRequest) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewCreateSnapshotDefault(code int) *CreateSnapshotDefault { } } -/*CreateSnapshotDefault handles this case with default header values. +/* +CreateSnapshotDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type CreateSnapshotDefault struct { Payload *models.Error } +// IsSuccess returns true when this create snapshot default response has a 2xx status code +func (o *CreateSnapshotDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create snapshot default response has a 3xx status code +func (o *CreateSnapshotDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create snapshot default response has a 4xx status code +func (o *CreateSnapshotDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create snapshot default response has a 5xx status code +func (o *CreateSnapshotDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create snapshot default response a status code equal to that given +func (o *CreateSnapshotDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create snapshot default response func (o *CreateSnapshotDefault) Code() int { return o._statusCode } func (o *CreateSnapshotDefault) Error() string { - return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshot default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshot default %s", o._statusCode, payload) +} + +func (o *CreateSnapshotDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshot default %s", o._statusCode, payload) } func (o *CreateSnapshotDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *CreateSnapshotDefault) readResponse(response runtime.ClientResponse, co o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/create_sync_action_parameters.go b/client/operations/create_sync_action_parameters.go index 4b1ff320..899ed4fa 100644 --- a/client/operations/create_sync_action_parameters.go +++ b/client/operations/create_sync_action_parameters.go @@ -26,57 +26,57 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewCreateSyncActionParams creates a new CreateSyncActionParams object -// with the default values initialized. +// NewCreateSyncActionParams creates a new CreateSyncActionParams 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 NewCreateSyncActionParams() *CreateSyncActionParams { - var () return &CreateSyncActionParams{ - timeout: cr.DefaultTimeout, } } // NewCreateSyncActionParamsWithTimeout creates a new CreateSyncActionParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewCreateSyncActionParamsWithTimeout(timeout time.Duration) *CreateSyncActionParams { - var () return &CreateSyncActionParams{ - timeout: timeout, } } // NewCreateSyncActionParamsWithContext creates a new CreateSyncActionParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewCreateSyncActionParamsWithContext(ctx context.Context) *CreateSyncActionParams { - var () return &CreateSyncActionParams{ - Context: ctx, } } // NewCreateSyncActionParamsWithHTTPClient creates a new CreateSyncActionParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewCreateSyncActionParamsWithHTTPClient(client *http.Client) *CreateSyncActionParams { - var () return &CreateSyncActionParams{ HTTPClient: client, } } -/*CreateSyncActionParams contains all the parameters to send to the API endpoint -for the create sync action operation typically these are written to a http.Request +/* +CreateSyncActionParams contains all the parameters to send to the API endpoint + + for the create sync action operation. + + Typically these are written to a http.Request. */ type CreateSyncActionParams struct { - /*Info*/ + // Info. Info *models.InstanceActionInfo timeout time.Duration @@ -84,6 +84,21 @@ type CreateSyncActionParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the create sync action params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateSyncActionParams) WithDefaults() *CreateSyncActionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create sync action params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateSyncActionParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the create sync action params func (o *CreateSyncActionParams) WithTimeout(timeout time.Duration) *CreateSyncActionParams { o.SetTimeout(timeout) @@ -135,7 +150,6 @@ func (o *CreateSyncActionParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error - if o.Info != nil { if err := r.SetBodyParam(o.Info); err != nil { return err diff --git a/client/operations/create_sync_action_responses.go b/client/operations/create_sync_action_responses.go index c4bb2a5f..5a0bdc82 100644 --- a/client/operations/create_sync_action_responses.go +++ b/client/operations/create_sync_action_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // CreateSyncActionReader is a Reader for the CreateSyncAction structure. @@ -35,7 +36,7 @@ type CreateSyncActionReader struct { } // ReadResponse reads a server response into the received o. -func (o *CreateSyncActionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *CreateSyncActionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewCreateSyncActionNoContent() @@ -66,15 +67,50 @@ func NewCreateSyncActionNoContent() *CreateSyncActionNoContent { return &CreateSyncActionNoContent{} } -/*CreateSyncActionNoContent handles this case with default header values. +/* +CreateSyncActionNoContent describes a response with status code 204, with default header values. The update was successful */ type CreateSyncActionNoContent struct { } +// IsSuccess returns true when this create sync action no content response has a 2xx status code +func (o *CreateSyncActionNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create sync action no content response has a 3xx status code +func (o *CreateSyncActionNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create sync action no content response has a 4xx status code +func (o *CreateSyncActionNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this create sync action no content response has a 5xx status code +func (o *CreateSyncActionNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this create sync action no content response a status code equal to that given +func (o *CreateSyncActionNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the create sync action no content response +func (o *CreateSyncActionNoContent) Code() int { + return 204 +} + func (o *CreateSyncActionNoContent) Error() string { - return fmt.Sprintf("[PUT /actions][%d] createSyncActionNoContent ", 204) + return fmt.Sprintf("[PUT /actions][%d] createSyncActionNoContent", 204) +} + +func (o *CreateSyncActionNoContent) String() string { + return fmt.Sprintf("[PUT /actions][%d] createSyncActionNoContent", 204) } func (o *CreateSyncActionNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewCreateSyncActionBadRequest() *CreateSyncActionBadRequest { return &CreateSyncActionBadRequest{} } -/*CreateSyncActionBadRequest handles this case with default header values. +/* +CreateSyncActionBadRequest describes a response with status code 400, with default header values. The action cannot be executed due to bad input */ @@ -95,8 +132,44 @@ type CreateSyncActionBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this create sync action bad request response has a 2xx status code +func (o *CreateSyncActionBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create sync action bad request response has a 3xx status code +func (o *CreateSyncActionBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create sync action bad request response has a 4xx status code +func (o *CreateSyncActionBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this create sync action bad request response has a 5xx status code +func (o *CreateSyncActionBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this create sync action bad request response a status code equal to that given +func (o *CreateSyncActionBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the create sync action bad request response +func (o *CreateSyncActionBadRequest) Code() int { + return 400 +} + func (o *CreateSyncActionBadRequest) Error() string { - return fmt.Sprintf("[PUT /actions][%d] createSyncActionBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /actions][%d] createSyncActionBadRequest %s", 400, payload) +} + +func (o *CreateSyncActionBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /actions][%d] createSyncActionBadRequest %s", 400, payload) } func (o *CreateSyncActionBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *CreateSyncActionBadRequest) readResponse(response runtime.ClientRespons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewCreateSyncActionDefault(code int) *CreateSyncActionDefault { } } -/*CreateSyncActionDefault handles this case with default header values. +/* +CreateSyncActionDefault describes a response with status code -1, with default header values. Internal Server Error */ @@ -132,13 +206,44 @@ type CreateSyncActionDefault struct { Payload *models.Error } +// IsSuccess returns true when this create sync action default response has a 2xx status code +func (o *CreateSyncActionDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this create sync action default response has a 3xx status code +func (o *CreateSyncActionDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this create sync action default response has a 4xx status code +func (o *CreateSyncActionDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this create sync action default response has a 5xx status code +func (o *CreateSyncActionDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this create sync action default response a status code equal to that given +func (o *CreateSyncActionDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the create sync action default response func (o *CreateSyncActionDefault) Code() int { return o._statusCode } func (o *CreateSyncActionDefault) Error() string { - return fmt.Sprintf("[PUT /actions][%d] createSyncAction default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /actions][%d] createSyncAction default %s", o._statusCode, payload) +} + +func (o *CreateSyncActionDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /actions][%d] createSyncAction default %s", o._statusCode, payload) } func (o *CreateSyncActionDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *CreateSyncActionDefault) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/describe_balloon_config_parameters.go b/client/operations/describe_balloon_config_parameters.go index fa5f4cf8..9f0de0eb 100644 --- a/client/operations/describe_balloon_config_parameters.go +++ b/client/operations/describe_balloon_config_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDescribeBalloonConfigParams creates a new DescribeBalloonConfigParams object -// with the default values initialized. +// NewDescribeBalloonConfigParams creates a new DescribeBalloonConfigParams 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 NewDescribeBalloonConfigParams() *DescribeBalloonConfigParams { - return &DescribeBalloonConfigParams{ - timeout: cr.DefaultTimeout, } } // NewDescribeBalloonConfigParamsWithTimeout creates a new DescribeBalloonConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDescribeBalloonConfigParamsWithTimeout(timeout time.Duration) *DescribeBalloonConfigParams { - return &DescribeBalloonConfigParams{ - timeout: timeout, } } // NewDescribeBalloonConfigParamsWithContext creates a new DescribeBalloonConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDescribeBalloonConfigParamsWithContext(ctx context.Context) *DescribeBalloonConfigParams { - return &DescribeBalloonConfigParams{ - Context: ctx, } } // NewDescribeBalloonConfigParamsWithHTTPClient creates a new DescribeBalloonConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDescribeBalloonConfigParamsWithHTTPClient(client *http.Client) *DescribeBalloonConfigParams { - return &DescribeBalloonConfigParams{ HTTPClient: client, } } -/*DescribeBalloonConfigParams contains all the parameters to send to the API endpoint -for the describe balloon config operation typically these are written to a http.Request +/* +DescribeBalloonConfigParams contains all the parameters to send to the API endpoint + + for the describe balloon config operation. + + Typically these are written to a http.Request. */ type DescribeBalloonConfigParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type DescribeBalloonConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the describe balloon config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeBalloonConfigParams) WithDefaults() *DescribeBalloonConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the describe balloon config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeBalloonConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the describe balloon config params func (o *DescribeBalloonConfigParams) WithTimeout(timeout time.Duration) *DescribeBalloonConfigParams { o.SetTimeout(timeout) diff --git a/client/operations/describe_balloon_config_responses.go b/client/operations/describe_balloon_config_responses.go index caf402f8..1ec2d85f 100644 --- a/client/operations/describe_balloon_config_responses.go +++ b/client/operations/describe_balloon_config_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // DescribeBalloonConfigReader is a Reader for the DescribeBalloonConfig structure. @@ -35,7 +36,7 @@ type DescribeBalloonConfigReader struct { } // ReadResponse reads a server response into the received o. -func (o *DescribeBalloonConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *DescribeBalloonConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewDescribeBalloonConfigOK() @@ -66,7 +67,8 @@ func NewDescribeBalloonConfigOK() *DescribeBalloonConfigOK { return &DescribeBalloonConfigOK{} } -/*DescribeBalloonConfigOK handles this case with default header values. +/* +DescribeBalloonConfigOK describes a response with status code 200, with default header values. The balloon device configuration */ @@ -74,8 +76,44 @@ type DescribeBalloonConfigOK struct { Payload *models.Balloon } +// IsSuccess returns true when this describe balloon config o k response has a 2xx status code +func (o *DescribeBalloonConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this describe balloon config o k response has a 3xx status code +func (o *DescribeBalloonConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this describe balloon config o k response has a 4xx status code +func (o *DescribeBalloonConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this describe balloon config o k response has a 5xx status code +func (o *DescribeBalloonConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this describe balloon config o k response a status code equal to that given +func (o *DescribeBalloonConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the describe balloon config o k response +func (o *DescribeBalloonConfigOK) Code() int { + return 200 +} + func (o *DescribeBalloonConfigOK) Error() string { - return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigOK %s", 200, payload) +} + +func (o *DescribeBalloonConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigOK %s", 200, payload) } func (o *DescribeBalloonConfigOK) GetPayload() *models.Balloon { @@ -87,7 +125,7 @@ func (o *DescribeBalloonConfigOK) readResponse(response runtime.ClientResponse, o.Payload = new(models.Balloon) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -99,7 +137,8 @@ func NewDescribeBalloonConfigBadRequest() *DescribeBalloonConfigBadRequest { return &DescribeBalloonConfigBadRequest{} } -/*DescribeBalloonConfigBadRequest handles this case with default header values. +/* +DescribeBalloonConfigBadRequest describes a response with status code 400, with default header values. Balloon device not configured. */ @@ -107,8 +146,44 @@ type DescribeBalloonConfigBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this describe balloon config bad request response has a 2xx status code +func (o *DescribeBalloonConfigBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this describe balloon config bad request response has a 3xx status code +func (o *DescribeBalloonConfigBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this describe balloon config bad request response has a 4xx status code +func (o *DescribeBalloonConfigBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this describe balloon config bad request response has a 5xx status code +func (o *DescribeBalloonConfigBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this describe balloon config bad request response a status code equal to that given +func (o *DescribeBalloonConfigBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the describe balloon config bad request response +func (o *DescribeBalloonConfigBadRequest) Code() int { + return 400 +} + func (o *DescribeBalloonConfigBadRequest) Error() string { - return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigBadRequest %s", 400, payload) +} + +func (o *DescribeBalloonConfigBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfigBadRequest %s", 400, payload) } func (o *DescribeBalloonConfigBadRequest) GetPayload() *models.Error { @@ -120,7 +195,7 @@ func (o *DescribeBalloonConfigBadRequest) readResponse(response runtime.ClientRe o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -134,7 +209,8 @@ func NewDescribeBalloonConfigDefault(code int) *DescribeBalloonConfigDefault { } } -/*DescribeBalloonConfigDefault handles this case with default header values. +/* +DescribeBalloonConfigDefault describes a response with status code -1, with default header values. Internal Server Error */ @@ -144,13 +220,44 @@ type DescribeBalloonConfigDefault struct { Payload *models.Error } +// IsSuccess returns true when this describe balloon config default response has a 2xx status code +func (o *DescribeBalloonConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this describe balloon config default response has a 3xx status code +func (o *DescribeBalloonConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this describe balloon config default response has a 4xx status code +func (o *DescribeBalloonConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this describe balloon config default response has a 5xx status code +func (o *DescribeBalloonConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this describe balloon config default response a status code equal to that given +func (o *DescribeBalloonConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the describe balloon config default response func (o *DescribeBalloonConfigDefault) Code() int { return o._statusCode } func (o *DescribeBalloonConfigDefault) Error() string { - return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfig default %s", o._statusCode, payload) +} + +func (o *DescribeBalloonConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon][%d] describeBalloonConfig default %s", o._statusCode, payload) } func (o *DescribeBalloonConfigDefault) GetPayload() *models.Error { @@ -162,7 +269,7 @@ func (o *DescribeBalloonConfigDefault) readResponse(response runtime.ClientRespo o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/describe_balloon_stats_parameters.go b/client/operations/describe_balloon_stats_parameters.go index 1766ce72..e097d5b0 100644 --- a/client/operations/describe_balloon_stats_parameters.go +++ b/client/operations/describe_balloon_stats_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDescribeBalloonStatsParams creates a new DescribeBalloonStatsParams object -// with the default values initialized. +// NewDescribeBalloonStatsParams creates a new DescribeBalloonStatsParams 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 NewDescribeBalloonStatsParams() *DescribeBalloonStatsParams { - return &DescribeBalloonStatsParams{ - timeout: cr.DefaultTimeout, } } // NewDescribeBalloonStatsParamsWithTimeout creates a new DescribeBalloonStatsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDescribeBalloonStatsParamsWithTimeout(timeout time.Duration) *DescribeBalloonStatsParams { - return &DescribeBalloonStatsParams{ - timeout: timeout, } } // NewDescribeBalloonStatsParamsWithContext creates a new DescribeBalloonStatsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDescribeBalloonStatsParamsWithContext(ctx context.Context) *DescribeBalloonStatsParams { - return &DescribeBalloonStatsParams{ - Context: ctx, } } // NewDescribeBalloonStatsParamsWithHTTPClient creates a new DescribeBalloonStatsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDescribeBalloonStatsParamsWithHTTPClient(client *http.Client) *DescribeBalloonStatsParams { - return &DescribeBalloonStatsParams{ HTTPClient: client, } } -/*DescribeBalloonStatsParams contains all the parameters to send to the API endpoint -for the describe balloon stats operation typically these are written to a http.Request +/* +DescribeBalloonStatsParams contains all the parameters to send to the API endpoint + + for the describe balloon stats operation. + + Typically these are written to a http.Request. */ type DescribeBalloonStatsParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type DescribeBalloonStatsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the describe balloon stats params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeBalloonStatsParams) WithDefaults() *DescribeBalloonStatsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the describe balloon stats params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeBalloonStatsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the describe balloon stats params func (o *DescribeBalloonStatsParams) WithTimeout(timeout time.Duration) *DescribeBalloonStatsParams { o.SetTimeout(timeout) diff --git a/client/operations/describe_balloon_stats_responses.go b/client/operations/describe_balloon_stats_responses.go index f9f2ad4e..92e60087 100644 --- a/client/operations/describe_balloon_stats_responses.go +++ b/client/operations/describe_balloon_stats_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // DescribeBalloonStatsReader is a Reader for the DescribeBalloonStats structure. @@ -35,7 +36,7 @@ type DescribeBalloonStatsReader struct { } // ReadResponse reads a server response into the received o. -func (o *DescribeBalloonStatsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *DescribeBalloonStatsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewDescribeBalloonStatsOK() @@ -66,7 +67,8 @@ func NewDescribeBalloonStatsOK() *DescribeBalloonStatsOK { return &DescribeBalloonStatsOK{} } -/*DescribeBalloonStatsOK handles this case with default header values. +/* +DescribeBalloonStatsOK describes a response with status code 200, with default header values. The balloon device statistics */ @@ -74,8 +76,44 @@ type DescribeBalloonStatsOK struct { Payload *models.BalloonStats } +// IsSuccess returns true when this describe balloon stats o k response has a 2xx status code +func (o *DescribeBalloonStatsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this describe balloon stats o k response has a 3xx status code +func (o *DescribeBalloonStatsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this describe balloon stats o k response has a 4xx status code +func (o *DescribeBalloonStatsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this describe balloon stats o k response has a 5xx status code +func (o *DescribeBalloonStatsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this describe balloon stats o k response a status code equal to that given +func (o *DescribeBalloonStatsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the describe balloon stats o k response +func (o *DescribeBalloonStatsOK) Code() int { + return 200 +} + func (o *DescribeBalloonStatsOK) Error() string { - return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsOK %s", 200, payload) +} + +func (o *DescribeBalloonStatsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsOK %s", 200, payload) } func (o *DescribeBalloonStatsOK) GetPayload() *models.BalloonStats { @@ -87,7 +125,7 @@ func (o *DescribeBalloonStatsOK) readResponse(response runtime.ClientResponse, c o.Payload = new(models.BalloonStats) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -99,7 +137,8 @@ func NewDescribeBalloonStatsBadRequest() *DescribeBalloonStatsBadRequest { return &DescribeBalloonStatsBadRequest{} } -/*DescribeBalloonStatsBadRequest handles this case with default header values. +/* +DescribeBalloonStatsBadRequest describes a response with status code 400, with default header values. The balloon device statistics were not enabled when the device was configured. */ @@ -107,8 +146,44 @@ type DescribeBalloonStatsBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this describe balloon stats bad request response has a 2xx status code +func (o *DescribeBalloonStatsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this describe balloon stats bad request response has a 3xx status code +func (o *DescribeBalloonStatsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this describe balloon stats bad request response has a 4xx status code +func (o *DescribeBalloonStatsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this describe balloon stats bad request response has a 5xx status code +func (o *DescribeBalloonStatsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this describe balloon stats bad request response a status code equal to that given +func (o *DescribeBalloonStatsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the describe balloon stats bad request response +func (o *DescribeBalloonStatsBadRequest) Code() int { + return 400 +} + func (o *DescribeBalloonStatsBadRequest) Error() string { - return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsBadRequest %s", 400, payload) +} + +func (o *DescribeBalloonStatsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStatsBadRequest %s", 400, payload) } func (o *DescribeBalloonStatsBadRequest) GetPayload() *models.Error { @@ -120,7 +195,7 @@ func (o *DescribeBalloonStatsBadRequest) readResponse(response runtime.ClientRes o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -134,7 +209,8 @@ func NewDescribeBalloonStatsDefault(code int) *DescribeBalloonStatsDefault { } } -/*DescribeBalloonStatsDefault handles this case with default header values. +/* +DescribeBalloonStatsDefault describes a response with status code -1, with default header values. Internal Server Error */ @@ -144,13 +220,44 @@ type DescribeBalloonStatsDefault struct { Payload *models.Error } +// IsSuccess returns true when this describe balloon stats default response has a 2xx status code +func (o *DescribeBalloonStatsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this describe balloon stats default response has a 3xx status code +func (o *DescribeBalloonStatsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this describe balloon stats default response has a 4xx status code +func (o *DescribeBalloonStatsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this describe balloon stats default response has a 5xx status code +func (o *DescribeBalloonStatsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this describe balloon stats default response a status code equal to that given +func (o *DescribeBalloonStatsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the describe balloon stats default response func (o *DescribeBalloonStatsDefault) Code() int { return o._statusCode } func (o *DescribeBalloonStatsDefault) Error() string { - return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStats default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStats default %s", o._statusCode, payload) +} + +func (o *DescribeBalloonStatsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /balloon/statistics][%d] describeBalloonStats default %s", o._statusCode, payload) } func (o *DescribeBalloonStatsDefault) GetPayload() *models.Error { @@ -162,7 +269,7 @@ func (o *DescribeBalloonStatsDefault) readResponse(response runtime.ClientRespon o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/describe_instance_parameters.go b/client/operations/describe_instance_parameters.go index 0513619b..3dc154c3 100644 --- a/client/operations/describe_instance_parameters.go +++ b/client/operations/describe_instance_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewDescribeInstanceParams creates a new DescribeInstanceParams object -// with the default values initialized. +// NewDescribeInstanceParams creates a new DescribeInstanceParams 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 NewDescribeInstanceParams() *DescribeInstanceParams { - return &DescribeInstanceParams{ - timeout: cr.DefaultTimeout, } } // NewDescribeInstanceParamsWithTimeout creates a new DescribeInstanceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewDescribeInstanceParamsWithTimeout(timeout time.Duration) *DescribeInstanceParams { - return &DescribeInstanceParams{ - timeout: timeout, } } // NewDescribeInstanceParamsWithContext creates a new DescribeInstanceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewDescribeInstanceParamsWithContext(ctx context.Context) *DescribeInstanceParams { - return &DescribeInstanceParams{ - Context: ctx, } } // NewDescribeInstanceParamsWithHTTPClient creates a new DescribeInstanceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewDescribeInstanceParamsWithHTTPClient(client *http.Client) *DescribeInstanceParams { - return &DescribeInstanceParams{ HTTPClient: client, } } -/*DescribeInstanceParams contains all the parameters to send to the API endpoint -for the describe instance operation typically these are written to a http.Request +/* +DescribeInstanceParams contains all the parameters to send to the API endpoint + + for the describe instance operation. + + Typically these are written to a http.Request. */ type DescribeInstanceParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type DescribeInstanceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the describe instance params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeInstanceParams) WithDefaults() *DescribeInstanceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the describe instance params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DescribeInstanceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the describe instance params func (o *DescribeInstanceParams) WithTimeout(timeout time.Duration) *DescribeInstanceParams { o.SetTimeout(timeout) diff --git a/client/operations/describe_instance_responses.go b/client/operations/describe_instance_responses.go index 94a659a0..4708a2b5 100644 --- a/client/operations/describe_instance_responses.go +++ b/client/operations/describe_instance_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // DescribeInstanceReader is a Reader for the DescribeInstance structure. @@ -35,7 +36,7 @@ type DescribeInstanceReader struct { } // ReadResponse reads a server response into the received o. -func (o *DescribeInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *DescribeInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewDescribeInstanceOK() @@ -60,7 +61,8 @@ func NewDescribeInstanceOK() *DescribeInstanceOK { return &DescribeInstanceOK{} } -/*DescribeInstanceOK handles this case with default header values. +/* +DescribeInstanceOK describes a response with status code 200, with default header values. The instance information */ @@ -68,8 +70,44 @@ type DescribeInstanceOK struct { Payload *models.InstanceInfo } +// IsSuccess returns true when this describe instance o k response has a 2xx status code +func (o *DescribeInstanceOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this describe instance o k response has a 3xx status code +func (o *DescribeInstanceOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this describe instance o k response has a 4xx status code +func (o *DescribeInstanceOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this describe instance o k response has a 5xx status code +func (o *DescribeInstanceOK) IsServerError() bool { + return false +} + +// IsCode returns true when this describe instance o k response a status code equal to that given +func (o *DescribeInstanceOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the describe instance o k response +func (o *DescribeInstanceOK) Code() int { + return 200 +} + func (o *DescribeInstanceOK) Error() string { - return fmt.Sprintf("[GET /][%d] describeInstanceOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /][%d] describeInstanceOK %s", 200, payload) +} + +func (o *DescribeInstanceOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /][%d] describeInstanceOK %s", 200, payload) } func (o *DescribeInstanceOK) GetPayload() *models.InstanceInfo { @@ -81,7 +119,7 @@ func (o *DescribeInstanceOK) readResponse(response runtime.ClientResponse, consu o.Payload = new(models.InstanceInfo) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -95,7 +133,8 @@ func NewDescribeInstanceDefault(code int) *DescribeInstanceDefault { } } -/*DescribeInstanceDefault handles this case with default header values. +/* +DescribeInstanceDefault describes a response with status code -1, with default header values. Internal Server Error */ @@ -105,13 +144,44 @@ type DescribeInstanceDefault struct { Payload *models.Error } +// IsSuccess returns true when this describe instance default response has a 2xx status code +func (o *DescribeInstanceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this describe instance default response has a 3xx status code +func (o *DescribeInstanceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this describe instance default response has a 4xx status code +func (o *DescribeInstanceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this describe instance default response has a 5xx status code +func (o *DescribeInstanceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this describe instance default response a status code equal to that given +func (o *DescribeInstanceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the describe instance default response func (o *DescribeInstanceDefault) Code() int { return o._statusCode } func (o *DescribeInstanceDefault) Error() string { - return fmt.Sprintf("[GET /][%d] describeInstance default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /][%d] describeInstance default %s", o._statusCode, payload) +} + +func (o *DescribeInstanceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /][%d] describeInstance default %s", o._statusCode, payload) } func (o *DescribeInstanceDefault) GetPayload() *models.Error { @@ -123,7 +193,7 @@ func (o *DescribeInstanceDefault) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/get_export_vm_config_parameters.go b/client/operations/get_export_vm_config_parameters.go index c2c4b92b..313592b0 100644 --- a/client/operations/get_export_vm_config_parameters.go +++ b/client/operations/get_export_vm_config_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetExportVMConfigParams creates a new GetExportVMConfigParams object -// with the default values initialized. +// NewGetExportVMConfigParams creates a new GetExportVMConfigParams 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 NewGetExportVMConfigParams() *GetExportVMConfigParams { - return &GetExportVMConfigParams{ - timeout: cr.DefaultTimeout, } } // NewGetExportVMConfigParamsWithTimeout creates a new GetExportVMConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetExportVMConfigParamsWithTimeout(timeout time.Duration) *GetExportVMConfigParams { - return &GetExportVMConfigParams{ - timeout: timeout, } } // NewGetExportVMConfigParamsWithContext creates a new GetExportVMConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetExportVMConfigParamsWithContext(ctx context.Context) *GetExportVMConfigParams { - return &GetExportVMConfigParams{ - Context: ctx, } } // NewGetExportVMConfigParamsWithHTTPClient creates a new GetExportVMConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetExportVMConfigParamsWithHTTPClient(client *http.Client) *GetExportVMConfigParams { - return &GetExportVMConfigParams{ HTTPClient: client, } } -/*GetExportVMConfigParams contains all the parameters to send to the API endpoint -for the get export Vm config operation typically these are written to a http.Request +/* +GetExportVMConfigParams contains all the parameters to send to the API endpoint + + for the get export Vm config operation. + + Typically these are written to a http.Request. */ type GetExportVMConfigParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type GetExportVMConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get export Vm config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExportVMConfigParams) WithDefaults() *GetExportVMConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get export Vm config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetExportVMConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get export Vm config params func (o *GetExportVMConfigParams) WithTimeout(timeout time.Duration) *GetExportVMConfigParams { o.SetTimeout(timeout) diff --git a/client/operations/get_export_vm_config_responses.go b/client/operations/get_export_vm_config_responses.go index 8a614527..879f4bb4 100644 --- a/client/operations/get_export_vm_config_responses.go +++ b/client/operations/get_export_vm_config_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // GetExportVMConfigReader is a Reader for the GetExportVMConfig structure. @@ -35,7 +36,7 @@ type GetExportVMConfigReader struct { } // ReadResponse reads a server response into the received o. -func (o *GetExportVMConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *GetExportVMConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewGetExportVMConfigOK() @@ -60,7 +61,8 @@ func NewGetExportVMConfigOK() *GetExportVMConfigOK { return &GetExportVMConfigOK{} } -/*GetExportVMConfigOK handles this case with default header values. +/* +GetExportVMConfigOK describes a response with status code 200, with default header values. OK */ @@ -68,8 +70,44 @@ type GetExportVMConfigOK struct { Payload *models.FullVMConfiguration } +// IsSuccess returns true when this get export Vm config o k response has a 2xx status code +func (o *GetExportVMConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get export Vm config o k response has a 3xx status code +func (o *GetExportVMConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get export Vm config o k response has a 4xx status code +func (o *GetExportVMConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get export Vm config o k response has a 5xx status code +func (o *GetExportVMConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get export Vm config o k response a status code equal to that given +func (o *GetExportVMConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get export Vm config o k response +func (o *GetExportVMConfigOK) Code() int { + return 200 +} + func (o *GetExportVMConfigOK) Error() string { - return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfigOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfigOK %s", 200, payload) +} + +func (o *GetExportVMConfigOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfigOK %s", 200, payload) } func (o *GetExportVMConfigOK) GetPayload() *models.FullVMConfiguration { @@ -81,7 +119,7 @@ func (o *GetExportVMConfigOK) readResponse(response runtime.ClientResponse, cons o.Payload = new(models.FullVMConfiguration) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -95,7 +133,8 @@ func NewGetExportVMConfigDefault(code int) *GetExportVMConfigDefault { } } -/*GetExportVMConfigDefault handles this case with default header values. +/* +GetExportVMConfigDefault describes a response with status code -1, with default header values. Internal server error */ @@ -105,13 +144,44 @@ type GetExportVMConfigDefault struct { Payload *models.Error } +// IsSuccess returns true when this get export Vm config default response has a 2xx status code +func (o *GetExportVMConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get export Vm config default response has a 3xx status code +func (o *GetExportVMConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get export Vm config default response has a 4xx status code +func (o *GetExportVMConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get export Vm config default response has a 5xx status code +func (o *GetExportVMConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get export Vm config default response a status code equal to that given +func (o *GetExportVMConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get export Vm config default response func (o *GetExportVMConfigDefault) Code() int { return o._statusCode } func (o *GetExportVMConfigDefault) Error() string { - return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfig default %s", o._statusCode, payload) +} + +func (o *GetExportVMConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /vm/config][%d] getExportVmConfig default %s", o._statusCode, payload) } func (o *GetExportVMConfigDefault) GetPayload() *models.Error { @@ -123,7 +193,7 @@ func (o *GetExportVMConfigDefault) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/get_firecracker_version_parameters.go b/client/operations/get_firecracker_version_parameters.go index 5779fc12..4029ae04 100644 --- a/client/operations/get_firecracker_version_parameters.go +++ b/client/operations/get_firecracker_version_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetFirecrackerVersionParams creates a new GetFirecrackerVersionParams object -// with the default values initialized. +// NewGetFirecrackerVersionParams creates a new GetFirecrackerVersionParams 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 NewGetFirecrackerVersionParams() *GetFirecrackerVersionParams { - return &GetFirecrackerVersionParams{ - timeout: cr.DefaultTimeout, } } // NewGetFirecrackerVersionParamsWithTimeout creates a new GetFirecrackerVersionParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetFirecrackerVersionParamsWithTimeout(timeout time.Duration) *GetFirecrackerVersionParams { - return &GetFirecrackerVersionParams{ - timeout: timeout, } } // NewGetFirecrackerVersionParamsWithContext creates a new GetFirecrackerVersionParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetFirecrackerVersionParamsWithContext(ctx context.Context) *GetFirecrackerVersionParams { - return &GetFirecrackerVersionParams{ - Context: ctx, } } // NewGetFirecrackerVersionParamsWithHTTPClient creates a new GetFirecrackerVersionParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetFirecrackerVersionParamsWithHTTPClient(client *http.Client) *GetFirecrackerVersionParams { - return &GetFirecrackerVersionParams{ HTTPClient: client, } } -/*GetFirecrackerVersionParams contains all the parameters to send to the API endpoint -for the get firecracker version operation typically these are written to a http.Request +/* +GetFirecrackerVersionParams contains all the parameters to send to the API endpoint + + for the get firecracker version operation. + + Typically these are written to a http.Request. */ type GetFirecrackerVersionParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type GetFirecrackerVersionParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get firecracker version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetFirecrackerVersionParams) WithDefaults() *GetFirecrackerVersionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get firecracker version params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetFirecrackerVersionParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get firecracker version params func (o *GetFirecrackerVersionParams) WithTimeout(timeout time.Duration) *GetFirecrackerVersionParams { o.SetTimeout(timeout) diff --git a/client/operations/get_firecracker_version_responses.go b/client/operations/get_firecracker_version_responses.go index 3651899f..24121237 100644 --- a/client/operations/get_firecracker_version_responses.go +++ b/client/operations/get_firecracker_version_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // GetFirecrackerVersionReader is a Reader for the GetFirecrackerVersion structure. @@ -35,7 +36,7 @@ type GetFirecrackerVersionReader struct { } // ReadResponse reads a server response into the received o. -func (o *GetFirecrackerVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *GetFirecrackerVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewGetFirecrackerVersionOK() @@ -60,7 +61,8 @@ func NewGetFirecrackerVersionOK() *GetFirecrackerVersionOK { return &GetFirecrackerVersionOK{} } -/*GetFirecrackerVersionOK handles this case with default header values. +/* +GetFirecrackerVersionOK describes a response with status code 200, with default header values. OK */ @@ -68,8 +70,44 @@ type GetFirecrackerVersionOK struct { Payload *models.FirecrackerVersion } +// IsSuccess returns true when this get firecracker version o k response has a 2xx status code +func (o *GetFirecrackerVersionOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get firecracker version o k response has a 3xx status code +func (o *GetFirecrackerVersionOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get firecracker version o k response has a 4xx status code +func (o *GetFirecrackerVersionOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get firecracker version o k response has a 5xx status code +func (o *GetFirecrackerVersionOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get firecracker version o k response a status code equal to that given +func (o *GetFirecrackerVersionOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get firecracker version o k response +func (o *GetFirecrackerVersionOK) Code() int { + return 200 +} + func (o *GetFirecrackerVersionOK) Error() string { - return fmt.Sprintf("[GET /version][%d] getFirecrackerVersionOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getFirecrackerVersionOK %s", 200, payload) +} + +func (o *GetFirecrackerVersionOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getFirecrackerVersionOK %s", 200, payload) } func (o *GetFirecrackerVersionOK) GetPayload() *models.FirecrackerVersion { @@ -81,7 +119,7 @@ func (o *GetFirecrackerVersionOK) readResponse(response runtime.ClientResponse, o.Payload = new(models.FirecrackerVersion) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -95,7 +133,8 @@ func NewGetFirecrackerVersionDefault(code int) *GetFirecrackerVersionDefault { } } -/*GetFirecrackerVersionDefault handles this case with default header values. +/* +GetFirecrackerVersionDefault describes a response with status code -1, with default header values. Internal server error */ @@ -105,13 +144,44 @@ type GetFirecrackerVersionDefault struct { Payload *models.Error } +// IsSuccess returns true when this get firecracker version default response has a 2xx status code +func (o *GetFirecrackerVersionDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get firecracker version default response has a 3xx status code +func (o *GetFirecrackerVersionDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get firecracker version default response has a 4xx status code +func (o *GetFirecrackerVersionDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get firecracker version default response has a 5xx status code +func (o *GetFirecrackerVersionDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get firecracker version default response a status code equal to that given +func (o *GetFirecrackerVersionDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get firecracker version default response func (o *GetFirecrackerVersionDefault) Code() int { return o._statusCode } func (o *GetFirecrackerVersionDefault) Error() string { - return fmt.Sprintf("[GET /version][%d] getFirecrackerVersion default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getFirecrackerVersion default %s", o._statusCode, payload) +} + +func (o *GetFirecrackerVersionDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /version][%d] getFirecrackerVersion default %s", o._statusCode, payload) } func (o *GetFirecrackerVersionDefault) GetPayload() *models.Error { @@ -123,7 +193,7 @@ func (o *GetFirecrackerVersionDefault) readResponse(response runtime.ClientRespo o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/get_machine_configuration_parameters.go b/client/operations/get_machine_configuration_parameters.go index 1dbae634..acc80539 100644 --- a/client/operations/get_machine_configuration_parameters.go +++ b/client/operations/get_machine_configuration_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetMachineConfigurationParams creates a new GetMachineConfigurationParams object -// with the default values initialized. +// NewGetMachineConfigurationParams creates a new GetMachineConfigurationParams 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 NewGetMachineConfigurationParams() *GetMachineConfigurationParams { - return &GetMachineConfigurationParams{ - timeout: cr.DefaultTimeout, } } // NewGetMachineConfigurationParamsWithTimeout creates a new GetMachineConfigurationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetMachineConfigurationParamsWithTimeout(timeout time.Duration) *GetMachineConfigurationParams { - return &GetMachineConfigurationParams{ - timeout: timeout, } } // NewGetMachineConfigurationParamsWithContext creates a new GetMachineConfigurationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetMachineConfigurationParamsWithContext(ctx context.Context) *GetMachineConfigurationParams { - return &GetMachineConfigurationParams{ - Context: ctx, } } // NewGetMachineConfigurationParamsWithHTTPClient creates a new GetMachineConfigurationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetMachineConfigurationParamsWithHTTPClient(client *http.Client) *GetMachineConfigurationParams { - return &GetMachineConfigurationParams{ HTTPClient: client, } } -/*GetMachineConfigurationParams contains all the parameters to send to the API endpoint -for the get machine configuration operation typically these are written to a http.Request +/* +GetMachineConfigurationParams contains all the parameters to send to the API endpoint + + for the get machine configuration operation. + + Typically these are written to a http.Request. */ type GetMachineConfigurationParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type GetMachineConfigurationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMachineConfigurationParams) WithDefaults() *GetMachineConfigurationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMachineConfigurationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get machine configuration params func (o *GetMachineConfigurationParams) WithTimeout(timeout time.Duration) *GetMachineConfigurationParams { o.SetTimeout(timeout) diff --git a/client/operations/get_machine_configuration_responses.go b/client/operations/get_machine_configuration_responses.go index da3095ed..c8f2a103 100644 --- a/client/operations/get_machine_configuration_responses.go +++ b/client/operations/get_machine_configuration_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // GetMachineConfigurationReader is a Reader for the GetMachineConfiguration structure. @@ -35,7 +36,7 @@ type GetMachineConfigurationReader struct { } // ReadResponse reads a server response into the received o. -func (o *GetMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *GetMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewGetMachineConfigurationOK() @@ -60,7 +61,8 @@ func NewGetMachineConfigurationOK() *GetMachineConfigurationOK { return &GetMachineConfigurationOK{} } -/*GetMachineConfigurationOK handles this case with default header values. +/* +GetMachineConfigurationOK describes a response with status code 200, with default header values. OK */ @@ -68,8 +70,44 @@ type GetMachineConfigurationOK struct { Payload *models.MachineConfiguration } +// IsSuccess returns true when this get machine configuration o k response has a 2xx status code +func (o *GetMachineConfigurationOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get machine configuration o k response has a 3xx status code +func (o *GetMachineConfigurationOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get machine configuration o k response has a 4xx status code +func (o *GetMachineConfigurationOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get machine configuration o k response has a 5xx status code +func (o *GetMachineConfigurationOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get machine configuration o k response a status code equal to that given +func (o *GetMachineConfigurationOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get machine configuration o k response +func (o *GetMachineConfigurationOK) Code() int { + return 200 +} + func (o *GetMachineConfigurationOK) Error() string { - return fmt.Sprintf("[GET /machine-config][%d] getMachineConfigurationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /machine-config][%d] getMachineConfigurationOK %s", 200, payload) +} + +func (o *GetMachineConfigurationOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /machine-config][%d] getMachineConfigurationOK %s", 200, payload) } func (o *GetMachineConfigurationOK) GetPayload() *models.MachineConfiguration { @@ -81,7 +119,7 @@ func (o *GetMachineConfigurationOK) readResponse(response runtime.ClientResponse o.Payload = new(models.MachineConfiguration) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -95,7 +133,8 @@ func NewGetMachineConfigurationDefault(code int) *GetMachineConfigurationDefault } } -/*GetMachineConfigurationDefault handles this case with default header values. +/* +GetMachineConfigurationDefault describes a response with status code -1, with default header values. Internal server error */ @@ -105,13 +144,44 @@ type GetMachineConfigurationDefault struct { Payload *models.Error } +// IsSuccess returns true when this get machine configuration default response has a 2xx status code +func (o *GetMachineConfigurationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get machine configuration default response has a 3xx status code +func (o *GetMachineConfigurationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get machine configuration default response has a 4xx status code +func (o *GetMachineConfigurationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get machine configuration default response has a 5xx status code +func (o *GetMachineConfigurationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get machine configuration default response a status code equal to that given +func (o *GetMachineConfigurationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get machine configuration default response func (o *GetMachineConfigurationDefault) Code() int { return o._statusCode } func (o *GetMachineConfigurationDefault) Error() string { - return fmt.Sprintf("[GET /machine-config][%d] getMachineConfiguration default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /machine-config][%d] getMachineConfiguration default %s", o._statusCode, payload) +} + +func (o *GetMachineConfigurationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /machine-config][%d] getMachineConfiguration default %s", o._statusCode, payload) } func (o *GetMachineConfigurationDefault) GetPayload() *models.Error { @@ -123,7 +193,7 @@ func (o *GetMachineConfigurationDefault) readResponse(response runtime.ClientRes o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/get_mmds_parameters.go b/client/operations/get_mmds_parameters.go index 82294e2c..ac913c0f 100644 --- a/client/operations/get_mmds_parameters.go +++ b/client/operations/get_mmds_parameters.go @@ -26,51 +26,51 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) -// NewGetMmdsParams creates a new GetMmdsParams object -// with the default values initialized. +// NewGetMmdsParams creates a new GetMmdsParams 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 NewGetMmdsParams() *GetMmdsParams { - return &GetMmdsParams{ - timeout: cr.DefaultTimeout, } } // NewGetMmdsParamsWithTimeout creates a new GetMmdsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewGetMmdsParamsWithTimeout(timeout time.Duration) *GetMmdsParams { - return &GetMmdsParams{ - timeout: timeout, } } // NewGetMmdsParamsWithContext creates a new GetMmdsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewGetMmdsParamsWithContext(ctx context.Context) *GetMmdsParams { - return &GetMmdsParams{ - Context: ctx, } } // NewGetMmdsParamsWithHTTPClient creates a new GetMmdsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewGetMmdsParamsWithHTTPClient(client *http.Client) *GetMmdsParams { - return &GetMmdsParams{ HTTPClient: client, } } -/*GetMmdsParams contains all the parameters to send to the API endpoint -for the get mmds operation typically these are written to a http.Request +/* +GetMmdsParams contains all the parameters to send to the API endpoint + + for the get mmds operation. + + Typically these are written to a http.Request. */ type GetMmdsParams struct { timeout time.Duration @@ -78,6 +78,21 @@ type GetMmdsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the get mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMmdsParams) WithDefaults() *GetMmdsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMmdsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the get mmds params func (o *GetMmdsParams) WithTimeout(timeout time.Duration) *GetMmdsParams { o.SetTimeout(timeout) diff --git a/client/operations/get_mmds_responses.go b/client/operations/get_mmds_responses.go index f8f9a9c7..97d4551d 100644 --- a/client/operations/get_mmds_responses.go +++ b/client/operations/get_mmds_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // GetMmdsReader is a Reader for the GetMmds structure. @@ -35,7 +36,7 @@ type GetMmdsReader struct { } // ReadResponse reads a server response into the received o. -func (o *GetMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *GetMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 200: result := NewGetMmdsOK() @@ -66,26 +67,63 @@ func NewGetMmdsOK() *GetMmdsOK { return &GetMmdsOK{} } -/*GetMmdsOK handles this case with default header values. +/* +GetMmdsOK describes a response with status code 200, with default header values. The MMDS data store JSON. */ type GetMmdsOK struct { - Payload interface{} + Payload any +} + +// IsSuccess returns true when this get mmds o k response has a 2xx status code +func (o *GetMmdsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get mmds o k response has a 3xx status code +func (o *GetMmdsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get mmds o k response has a 4xx status code +func (o *GetMmdsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get mmds o k response has a 5xx status code +func (o *GetMmdsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get mmds o k response a status code equal to that given +func (o *GetMmdsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get mmds o k response +func (o *GetMmdsOK) Code() int { + return 200 } func (o *GetMmdsOK) Error() string { - return fmt.Sprintf("[GET /mmds][%d] getMmdsOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmdsOK %s", 200, payload) } -func (o *GetMmdsOK) GetPayload() interface{} { +func (o *GetMmdsOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmdsOK %s", 200, payload) +} + +func (o *GetMmdsOK) GetPayload() any { return o.Payload } func (o *GetMmdsOK) 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 { + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -97,7 +135,8 @@ func NewGetMmdsNotFound() *GetMmdsNotFound { return &GetMmdsNotFound{} } -/*GetMmdsNotFound handles this case with default header values. +/* +GetMmdsNotFound describes a response with status code 404, with default header values. The MMDS data store content can not be found. */ @@ -105,8 +144,44 @@ type GetMmdsNotFound struct { Payload *models.Error } +// IsSuccess returns true when this get mmds not found response has a 2xx status code +func (o *GetMmdsNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get mmds not found response has a 3xx status code +func (o *GetMmdsNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get mmds not found response has a 4xx status code +func (o *GetMmdsNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this get mmds not found response has a 5xx status code +func (o *GetMmdsNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this get mmds not found response a status code equal to that given +func (o *GetMmdsNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the get mmds not found response +func (o *GetMmdsNotFound) Code() int { + return 404 +} + func (o *GetMmdsNotFound) Error() string { - return fmt.Sprintf("[GET /mmds][%d] getMmdsNotFound %+v", 404, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmdsNotFound %s", 404, payload) +} + +func (o *GetMmdsNotFound) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmdsNotFound %s", 404, payload) } func (o *GetMmdsNotFound) GetPayload() *models.Error { @@ -118,7 +193,7 @@ func (o *GetMmdsNotFound) readResponse(response runtime.ClientResponse, consumer o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -132,7 +207,8 @@ func NewGetMmdsDefault(code int) *GetMmdsDefault { } } -/*GetMmdsDefault handles this case with default header values. +/* +GetMmdsDefault describes a response with status code -1, with default header values. Internal server error */ @@ -142,13 +218,44 @@ type GetMmdsDefault struct { Payload *models.Error } +// IsSuccess returns true when this get mmds default response has a 2xx status code +func (o *GetMmdsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this get mmds default response has a 3xx status code +func (o *GetMmdsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this get mmds default response has a 4xx status code +func (o *GetMmdsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this get mmds default response has a 5xx status code +func (o *GetMmdsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this get mmds default response a status code equal to that given +func (o *GetMmdsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the get mmds default response func (o *GetMmdsDefault) Code() int { return o._statusCode } func (o *GetMmdsDefault) Error() string { - return fmt.Sprintf("[GET /mmds][%d] getMmds default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmds default %s", o._statusCode, payload) +} + +func (o *GetMmdsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /mmds][%d] getMmds default %s", o._statusCode, payload) } func (o *GetMmdsDefault) GetPayload() *models.Error { @@ -160,7 +267,7 @@ func (o *GetMmdsDefault) readResponse(response runtime.ClientResponse, consumer o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/load_snapshot_parameters.go b/client/operations/load_snapshot_parameters.go index b9630e74..5c74c850 100644 --- a/client/operations/load_snapshot_parameters.go +++ b/client/operations/load_snapshot_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewLoadSnapshotParams creates a new LoadSnapshotParams object -// with the default values initialized. +// NewLoadSnapshotParams creates a new LoadSnapshotParams 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 NewLoadSnapshotParams() *LoadSnapshotParams { - var () return &LoadSnapshotParams{ - timeout: cr.DefaultTimeout, } } // NewLoadSnapshotParamsWithTimeout creates a new LoadSnapshotParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewLoadSnapshotParamsWithTimeout(timeout time.Duration) *LoadSnapshotParams { - var () return &LoadSnapshotParams{ - timeout: timeout, } } // NewLoadSnapshotParamsWithContext creates a new LoadSnapshotParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewLoadSnapshotParamsWithContext(ctx context.Context) *LoadSnapshotParams { - var () return &LoadSnapshotParams{ - Context: ctx, } } // NewLoadSnapshotParamsWithHTTPClient creates a new LoadSnapshotParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewLoadSnapshotParamsWithHTTPClient(client *http.Client) *LoadSnapshotParams { - var () return &LoadSnapshotParams{ HTTPClient: client, } } -/*LoadSnapshotParams contains all the parameters to send to the API endpoint -for the load snapshot operation typically these are written to a http.Request +/* +LoadSnapshotParams contains all the parameters to send to the API endpoint + + for the load snapshot operation. + + Typically these are written to a http.Request. */ type LoadSnapshotParams struct { - /*Body - The configuration used for loading a snaphot. + /* Body. + The configuration used for loading a snaphot. */ Body *models.SnapshotLoadParams @@ -87,6 +87,21 @@ type LoadSnapshotParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the load snapshot params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoadSnapshotParams) WithDefaults() *LoadSnapshotParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the load snapshot params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *LoadSnapshotParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the load snapshot params func (o *LoadSnapshotParams) WithTimeout(timeout time.Duration) *LoadSnapshotParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *LoadSnapshotParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/load_snapshot_responses.go b/client/operations/load_snapshot_responses.go index dfec0e27..b9383d7e 100644 --- a/client/operations/load_snapshot_responses.go +++ b/client/operations/load_snapshot_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // LoadSnapshotReader is a Reader for the LoadSnapshot structure. @@ -35,7 +36,7 @@ type LoadSnapshotReader struct { } // ReadResponse reads a server response into the received o. -func (o *LoadSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *LoadSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewLoadSnapshotNoContent() @@ -66,15 +67,50 @@ func NewLoadSnapshotNoContent() *LoadSnapshotNoContent { return &LoadSnapshotNoContent{} } -/*LoadSnapshotNoContent handles this case with default header values. +/* +LoadSnapshotNoContent describes a response with status code 204, with default header values. Snapshot loaded */ type LoadSnapshotNoContent struct { } +// IsSuccess returns true when this load snapshot no content response has a 2xx status code +func (o *LoadSnapshotNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this load snapshot no content response has a 3xx status code +func (o *LoadSnapshotNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this load snapshot no content response has a 4xx status code +func (o *LoadSnapshotNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this load snapshot no content response has a 5xx status code +func (o *LoadSnapshotNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this load snapshot no content response a status code equal to that given +func (o *LoadSnapshotNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the load snapshot no content response +func (o *LoadSnapshotNoContent) Code() int { + return 204 +} + func (o *LoadSnapshotNoContent) Error() string { - return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotNoContent ", 204) + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotNoContent", 204) +} + +func (o *LoadSnapshotNoContent) String() string { + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotNoContent", 204) } func (o *LoadSnapshotNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewLoadSnapshotBadRequest() *LoadSnapshotBadRequest { return &LoadSnapshotBadRequest{} } -/*LoadSnapshotBadRequest handles this case with default header values. +/* +LoadSnapshotBadRequest describes a response with status code 400, with default header values. Snapshot cannot be loaded due to bad input */ @@ -95,8 +132,44 @@ type LoadSnapshotBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this load snapshot bad request response has a 2xx status code +func (o *LoadSnapshotBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this load snapshot bad request response has a 3xx status code +func (o *LoadSnapshotBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this load snapshot bad request response has a 4xx status code +func (o *LoadSnapshotBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this load snapshot bad request response has a 5xx status code +func (o *LoadSnapshotBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this load snapshot bad request response a status code equal to that given +func (o *LoadSnapshotBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the load snapshot bad request response +func (o *LoadSnapshotBadRequest) Code() int { + return 400 +} + func (o *LoadSnapshotBadRequest) Error() string { - return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotBadRequest %s", 400, payload) +} + +func (o *LoadSnapshotBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotBadRequest %s", 400, payload) } func (o *LoadSnapshotBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *LoadSnapshotBadRequest) readResponse(response runtime.ClientResponse, c o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewLoadSnapshotDefault(code int) *LoadSnapshotDefault { } } -/*LoadSnapshotDefault handles this case with default header values. +/* +LoadSnapshotDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type LoadSnapshotDefault struct { Payload *models.Error } +// IsSuccess returns true when this load snapshot default response has a 2xx status code +func (o *LoadSnapshotDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this load snapshot default response has a 3xx status code +func (o *LoadSnapshotDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this load snapshot default response has a 4xx status code +func (o *LoadSnapshotDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this load snapshot default response has a 5xx status code +func (o *LoadSnapshotDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this load snapshot default response a status code equal to that given +func (o *LoadSnapshotDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the load snapshot default response func (o *LoadSnapshotDefault) Code() int { return o._statusCode } func (o *LoadSnapshotDefault) Error() string { - return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshot default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshot default %s", o._statusCode, payload) +} + +func (o *LoadSnapshotDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshot default %s", o._statusCode, payload) } func (o *LoadSnapshotDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *LoadSnapshotDefault) readResponse(response runtime.ClientResponse, cons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_balloon_parameters.go b/client/operations/patch_balloon_parameters.go index 86606a1c..5b1e8975 100644 --- a/client/operations/patch_balloon_parameters.go +++ b/client/operations/patch_balloon_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchBalloonParams creates a new PatchBalloonParams object -// with the default values initialized. +// NewPatchBalloonParams creates a new PatchBalloonParams 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 NewPatchBalloonParams() *PatchBalloonParams { - var () return &PatchBalloonParams{ - timeout: cr.DefaultTimeout, } } // NewPatchBalloonParamsWithTimeout creates a new PatchBalloonParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchBalloonParamsWithTimeout(timeout time.Duration) *PatchBalloonParams { - var () return &PatchBalloonParams{ - timeout: timeout, } } // NewPatchBalloonParamsWithContext creates a new PatchBalloonParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchBalloonParamsWithContext(ctx context.Context) *PatchBalloonParams { - var () return &PatchBalloonParams{ - Context: ctx, } } // NewPatchBalloonParamsWithHTTPClient creates a new PatchBalloonParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchBalloonParamsWithHTTPClient(client *http.Client) *PatchBalloonParams { - var () return &PatchBalloonParams{ HTTPClient: client, } } -/*PatchBalloonParams contains all the parameters to send to the API endpoint -for the patch balloon operation typically these are written to a http.Request +/* +PatchBalloonParams contains all the parameters to send to the API endpoint + + for the patch balloon operation. + + Typically these are written to a http.Request. */ type PatchBalloonParams struct { - /*Body - Balloon properties + /* Body. + Balloon properties */ Body *models.BalloonUpdate @@ -87,6 +87,21 @@ type PatchBalloonParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch balloon params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchBalloonParams) WithDefaults() *PatchBalloonParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch balloon params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchBalloonParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch balloon params func (o *PatchBalloonParams) WithTimeout(timeout time.Duration) *PatchBalloonParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PatchBalloonParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_balloon_responses.go b/client/operations/patch_balloon_responses.go index 41e5a420..4c239bcc 100644 --- a/client/operations/patch_balloon_responses.go +++ b/client/operations/patch_balloon_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchBalloonReader is a Reader for the PatchBalloon structure. @@ -35,7 +36,7 @@ type PatchBalloonReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchBalloonReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchBalloonReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchBalloonNoContent() @@ -66,15 +67,50 @@ func NewPatchBalloonNoContent() *PatchBalloonNoContent { return &PatchBalloonNoContent{} } -/*PatchBalloonNoContent handles this case with default header values. +/* +PatchBalloonNoContent describes a response with status code 204, with default header values. Balloon device updated */ type PatchBalloonNoContent struct { } +// IsSuccess returns true when this patch balloon no content response has a 2xx status code +func (o *PatchBalloonNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch balloon no content response has a 3xx status code +func (o *PatchBalloonNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch balloon no content response has a 4xx status code +func (o *PatchBalloonNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch balloon no content response has a 5xx status code +func (o *PatchBalloonNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch balloon no content response a status code equal to that given +func (o *PatchBalloonNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch balloon no content response +func (o *PatchBalloonNoContent) Code() int { + return 204 +} + func (o *PatchBalloonNoContent) Error() string { - return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonNoContent ", 204) + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonNoContent", 204) +} + +func (o *PatchBalloonNoContent) String() string { + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonNoContent", 204) } func (o *PatchBalloonNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchBalloonBadRequest() *PatchBalloonBadRequest { return &PatchBalloonBadRequest{} } -/*PatchBalloonBadRequest handles this case with default header values. +/* +PatchBalloonBadRequest describes a response with status code 400, with default header values. Balloon device cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchBalloonBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch balloon bad request response has a 2xx status code +func (o *PatchBalloonBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch balloon bad request response has a 3xx status code +func (o *PatchBalloonBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch balloon bad request response has a 4xx status code +func (o *PatchBalloonBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch balloon bad request response has a 5xx status code +func (o *PatchBalloonBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch balloon bad request response a status code equal to that given +func (o *PatchBalloonBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch balloon bad request response +func (o *PatchBalloonBadRequest) Code() int { + return 400 +} + func (o *PatchBalloonBadRequest) Error() string { - return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonBadRequest %s", 400, payload) +} + +func (o *PatchBalloonBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloonBadRequest %s", 400, payload) } func (o *PatchBalloonBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchBalloonBadRequest) readResponse(response runtime.ClientResponse, c o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchBalloonDefault(code int) *PatchBalloonDefault { } } -/*PatchBalloonDefault handles this case with default header values. +/* +PatchBalloonDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchBalloonDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch balloon default response has a 2xx status code +func (o *PatchBalloonDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch balloon default response has a 3xx status code +func (o *PatchBalloonDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch balloon default response has a 4xx status code +func (o *PatchBalloonDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch balloon default response has a 5xx status code +func (o *PatchBalloonDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch balloon default response a status code equal to that given +func (o *PatchBalloonDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch balloon default response func (o *PatchBalloonDefault) Code() int { return o._statusCode } func (o *PatchBalloonDefault) Error() string { - return fmt.Sprintf("[PATCH /balloon][%d] patchBalloon default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloon default %s", o._statusCode, payload) +} + +func (o *PatchBalloonDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon][%d] patchBalloon default %s", o._statusCode, payload) } func (o *PatchBalloonDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchBalloonDefault) readResponse(response runtime.ClientResponse, cons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_balloon_stats_interval_parameters.go b/client/operations/patch_balloon_stats_interval_parameters.go index 69e3792f..25a65ac2 100644 --- a/client/operations/patch_balloon_stats_interval_parameters.go +++ b/client/operations/patch_balloon_stats_interval_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchBalloonStatsIntervalParams creates a new PatchBalloonStatsIntervalParams object -// with the default values initialized. +// NewPatchBalloonStatsIntervalParams creates a new PatchBalloonStatsIntervalParams 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 NewPatchBalloonStatsIntervalParams() *PatchBalloonStatsIntervalParams { - var () return &PatchBalloonStatsIntervalParams{ - timeout: cr.DefaultTimeout, } } // NewPatchBalloonStatsIntervalParamsWithTimeout creates a new PatchBalloonStatsIntervalParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchBalloonStatsIntervalParamsWithTimeout(timeout time.Duration) *PatchBalloonStatsIntervalParams { - var () return &PatchBalloonStatsIntervalParams{ - timeout: timeout, } } // NewPatchBalloonStatsIntervalParamsWithContext creates a new PatchBalloonStatsIntervalParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchBalloonStatsIntervalParamsWithContext(ctx context.Context) *PatchBalloonStatsIntervalParams { - var () return &PatchBalloonStatsIntervalParams{ - Context: ctx, } } // NewPatchBalloonStatsIntervalParamsWithHTTPClient creates a new PatchBalloonStatsIntervalParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchBalloonStatsIntervalParamsWithHTTPClient(client *http.Client) *PatchBalloonStatsIntervalParams { - var () return &PatchBalloonStatsIntervalParams{ HTTPClient: client, } } -/*PatchBalloonStatsIntervalParams contains all the parameters to send to the API endpoint -for the patch balloon stats interval operation typically these are written to a http.Request +/* +PatchBalloonStatsIntervalParams contains all the parameters to send to the API endpoint + + for the patch balloon stats interval operation. + + Typically these are written to a http.Request. */ type PatchBalloonStatsIntervalParams struct { - /*Body - Balloon properties + /* Body. + Balloon properties */ Body *models.BalloonStatsUpdate @@ -87,6 +87,21 @@ type PatchBalloonStatsIntervalParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch balloon stats interval params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchBalloonStatsIntervalParams) WithDefaults() *PatchBalloonStatsIntervalParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch balloon stats interval params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchBalloonStatsIntervalParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch balloon stats interval params func (o *PatchBalloonStatsIntervalParams) WithTimeout(timeout time.Duration) *PatchBalloonStatsIntervalParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PatchBalloonStatsIntervalParams) WriteToRequest(r runtime.ClientRequest return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_balloon_stats_interval_responses.go b/client/operations/patch_balloon_stats_interval_responses.go index 87ca9a7c..378f2d06 100644 --- a/client/operations/patch_balloon_stats_interval_responses.go +++ b/client/operations/patch_balloon_stats_interval_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchBalloonStatsIntervalReader is a Reader for the PatchBalloonStatsInterval structure. @@ -35,7 +36,7 @@ type PatchBalloonStatsIntervalReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchBalloonStatsIntervalReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchBalloonStatsIntervalReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchBalloonStatsIntervalNoContent() @@ -66,15 +67,50 @@ func NewPatchBalloonStatsIntervalNoContent() *PatchBalloonStatsIntervalNoContent return &PatchBalloonStatsIntervalNoContent{} } -/*PatchBalloonStatsIntervalNoContent handles this case with default header values. +/* +PatchBalloonStatsIntervalNoContent describes a response with status code 204, with default header values. Balloon statistics interval updated */ type PatchBalloonStatsIntervalNoContent struct { } +// IsSuccess returns true when this patch balloon stats interval no content response has a 2xx status code +func (o *PatchBalloonStatsIntervalNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch balloon stats interval no content response has a 3xx status code +func (o *PatchBalloonStatsIntervalNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch balloon stats interval no content response has a 4xx status code +func (o *PatchBalloonStatsIntervalNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch balloon stats interval no content response has a 5xx status code +func (o *PatchBalloonStatsIntervalNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch balloon stats interval no content response a status code equal to that given +func (o *PatchBalloonStatsIntervalNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch balloon stats interval no content response +func (o *PatchBalloonStatsIntervalNoContent) Code() int { + return 204 +} + func (o *PatchBalloonStatsIntervalNoContent) Error() string { - return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalNoContent ", 204) + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalNoContent", 204) +} + +func (o *PatchBalloonStatsIntervalNoContent) String() string { + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalNoContent", 204) } func (o *PatchBalloonStatsIntervalNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchBalloonStatsIntervalBadRequest() *PatchBalloonStatsIntervalBadReque return &PatchBalloonStatsIntervalBadRequest{} } -/*PatchBalloonStatsIntervalBadRequest handles this case with default header values. +/* +PatchBalloonStatsIntervalBadRequest describes a response with status code 400, with default header values. Balloon statistics interval cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchBalloonStatsIntervalBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch balloon stats interval bad request response has a 2xx status code +func (o *PatchBalloonStatsIntervalBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch balloon stats interval bad request response has a 3xx status code +func (o *PatchBalloonStatsIntervalBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch balloon stats interval bad request response has a 4xx status code +func (o *PatchBalloonStatsIntervalBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch balloon stats interval bad request response has a 5xx status code +func (o *PatchBalloonStatsIntervalBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch balloon stats interval bad request response a status code equal to that given +func (o *PatchBalloonStatsIntervalBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch balloon stats interval bad request response +func (o *PatchBalloonStatsIntervalBadRequest) Code() int { + return 400 +} + func (o *PatchBalloonStatsIntervalBadRequest) Error() string { - return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalBadRequest %s", 400, payload) +} + +func (o *PatchBalloonStatsIntervalBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsIntervalBadRequest %s", 400, payload) } func (o *PatchBalloonStatsIntervalBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchBalloonStatsIntervalBadRequest) readResponse(response runtime.Clie o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchBalloonStatsIntervalDefault(code int) *PatchBalloonStatsIntervalDef } } -/*PatchBalloonStatsIntervalDefault handles this case with default header values. +/* +PatchBalloonStatsIntervalDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchBalloonStatsIntervalDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch balloon stats interval default response has a 2xx status code +func (o *PatchBalloonStatsIntervalDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch balloon stats interval default response has a 3xx status code +func (o *PatchBalloonStatsIntervalDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch balloon stats interval default response has a 4xx status code +func (o *PatchBalloonStatsIntervalDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch balloon stats interval default response has a 5xx status code +func (o *PatchBalloonStatsIntervalDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch balloon stats interval default response a status code equal to that given +func (o *PatchBalloonStatsIntervalDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch balloon stats interval default response func (o *PatchBalloonStatsIntervalDefault) Code() int { return o._statusCode } func (o *PatchBalloonStatsIntervalDefault) Error() string { - return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsInterval default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsInterval default %s", o._statusCode, payload) +} + +func (o *PatchBalloonStatsIntervalDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /balloon/statistics][%d] patchBalloonStatsInterval default %s", o._statusCode, payload) } func (o *PatchBalloonStatsIntervalDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchBalloonStatsIntervalDefault) readResponse(response runtime.ClientR o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_guest_drive_by_id_parameters.go b/client/operations/patch_guest_drive_by_id_parameters.go index 8667c434..f96edd0e 100644 --- a/client/operations/patch_guest_drive_by_id_parameters.go +++ b/client/operations/patch_guest_drive_by_id_parameters.go @@ -26,64 +26,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchGuestDriveByIDParams creates a new PatchGuestDriveByIDParams object -// with the default values initialized. +// NewPatchGuestDriveByIDParams creates a new PatchGuestDriveByIDParams 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 NewPatchGuestDriveByIDParams() *PatchGuestDriveByIDParams { - var () return &PatchGuestDriveByIDParams{ - timeout: cr.DefaultTimeout, } } // NewPatchGuestDriveByIDParamsWithTimeout creates a new PatchGuestDriveByIDParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchGuestDriveByIDParamsWithTimeout(timeout time.Duration) *PatchGuestDriveByIDParams { - var () return &PatchGuestDriveByIDParams{ - timeout: timeout, } } // NewPatchGuestDriveByIDParamsWithContext creates a new PatchGuestDriveByIDParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchGuestDriveByIDParamsWithContext(ctx context.Context) *PatchGuestDriveByIDParams { - var () return &PatchGuestDriveByIDParams{ - Context: ctx, } } // NewPatchGuestDriveByIDParamsWithHTTPClient creates a new PatchGuestDriveByIDParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchGuestDriveByIDParamsWithHTTPClient(client *http.Client) *PatchGuestDriveByIDParams { - var () return &PatchGuestDriveByIDParams{ HTTPClient: client, } } -/*PatchGuestDriveByIDParams contains all the parameters to send to the API endpoint -for the patch guest drive by ID operation typically these are written to a http.Request +/* +PatchGuestDriveByIDParams contains all the parameters to send to the API endpoint + + for the patch guest drive by ID operation. + + Typically these are written to a http.Request. */ type PatchGuestDriveByIDParams struct { - /*Body - Guest drive properties + /* Body. + Guest drive properties */ Body *models.PartialDrive - /*DriveID - The id of the guest drive + /* DriveID. + + The id of the guest drive */ DriveID string @@ -92,6 +93,21 @@ type PatchGuestDriveByIDParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch guest drive by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchGuestDriveByIDParams) WithDefaults() *PatchGuestDriveByIDParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch guest drive by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchGuestDriveByIDParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch guest drive by ID params func (o *PatchGuestDriveByIDParams) WithTimeout(timeout time.Duration) *PatchGuestDriveByIDParams { o.SetTimeout(timeout) @@ -154,7 +170,6 @@ func (o *PatchGuestDriveByIDParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_guest_drive_by_id_responses.go b/client/operations/patch_guest_drive_by_id_responses.go index 1270919b..7af1f626 100644 --- a/client/operations/patch_guest_drive_by_id_responses.go +++ b/client/operations/patch_guest_drive_by_id_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchGuestDriveByIDReader is a Reader for the PatchGuestDriveByID structure. @@ -35,7 +36,7 @@ type PatchGuestDriveByIDReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchGuestDriveByIDNoContent() @@ -66,15 +67,50 @@ func NewPatchGuestDriveByIDNoContent() *PatchGuestDriveByIDNoContent { return &PatchGuestDriveByIDNoContent{} } -/*PatchGuestDriveByIDNoContent handles this case with default header values. +/* +PatchGuestDriveByIDNoContent describes a response with status code 204, with default header values. Drive updated */ type PatchGuestDriveByIDNoContent struct { } +// IsSuccess returns true when this patch guest drive by Id no content response has a 2xx status code +func (o *PatchGuestDriveByIDNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch guest drive by Id no content response has a 3xx status code +func (o *PatchGuestDriveByIDNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch guest drive by Id no content response has a 4xx status code +func (o *PatchGuestDriveByIDNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch guest drive by Id no content response has a 5xx status code +func (o *PatchGuestDriveByIDNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch guest drive by Id no content response a status code equal to that given +func (o *PatchGuestDriveByIDNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch guest drive by Id no content response +func (o *PatchGuestDriveByIDNoContent) Code() int { + return 204 +} + func (o *PatchGuestDriveByIDNoContent) Error() string { - return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdNoContent ", 204) + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdNoContent", 204) +} + +func (o *PatchGuestDriveByIDNoContent) String() string { + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdNoContent", 204) } func (o *PatchGuestDriveByIDNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchGuestDriveByIDBadRequest() *PatchGuestDriveByIDBadRequest { return &PatchGuestDriveByIDBadRequest{} } -/*PatchGuestDriveByIDBadRequest handles this case with default header values. +/* +PatchGuestDriveByIDBadRequest describes a response with status code 400, with default header values. Drive cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchGuestDriveByIDBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch guest drive by Id bad request response has a 2xx status code +func (o *PatchGuestDriveByIDBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch guest drive by Id bad request response has a 3xx status code +func (o *PatchGuestDriveByIDBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch guest drive by Id bad request response has a 4xx status code +func (o *PatchGuestDriveByIDBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch guest drive by Id bad request response has a 5xx status code +func (o *PatchGuestDriveByIDBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch guest drive by Id bad request response a status code equal to that given +func (o *PatchGuestDriveByIDBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch guest drive by Id bad request response +func (o *PatchGuestDriveByIDBadRequest) Code() int { + return 400 +} + func (o *PatchGuestDriveByIDBadRequest) Error() string { - return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdBadRequest %s", 400, payload) +} + +func (o *PatchGuestDriveByIDBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByIdBadRequest %s", 400, payload) } func (o *PatchGuestDriveByIDBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchGuestDriveByIDBadRequest) readResponse(response runtime.ClientResp o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchGuestDriveByIDDefault(code int) *PatchGuestDriveByIDDefault { } } -/*PatchGuestDriveByIDDefault handles this case with default header values. +/* +PatchGuestDriveByIDDefault describes a response with status code -1, with default header values. Internal server error. */ @@ -132,13 +206,44 @@ type PatchGuestDriveByIDDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch guest drive by ID default response has a 2xx status code +func (o *PatchGuestDriveByIDDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch guest drive by ID default response has a 3xx status code +func (o *PatchGuestDriveByIDDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch guest drive by ID default response has a 4xx status code +func (o *PatchGuestDriveByIDDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch guest drive by ID default response has a 5xx status code +func (o *PatchGuestDriveByIDDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch guest drive by ID default response a status code equal to that given +func (o *PatchGuestDriveByIDDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch guest drive by ID default response func (o *PatchGuestDriveByIDDefault) Code() int { return o._statusCode } func (o *PatchGuestDriveByIDDefault) Error() string { - return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByID default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByID default %s", o._statusCode, payload) +} + +func (o *PatchGuestDriveByIDDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /drives/{drive_id}][%d] patchGuestDriveByID default %s", o._statusCode, payload) } func (o *PatchGuestDriveByIDDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchGuestDriveByIDDefault) readResponse(response runtime.ClientRespons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_guest_network_interface_by_id_parameters.go b/client/operations/patch_guest_network_interface_by_id_parameters.go index 12f6337d..cf32461e 100644 --- a/client/operations/patch_guest_network_interface_by_id_parameters.go +++ b/client/operations/patch_guest_network_interface_by_id_parameters.go @@ -26,64 +26,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchGuestNetworkInterfaceByIDParams creates a new PatchGuestNetworkInterfaceByIDParams object -// with the default values initialized. +// NewPatchGuestNetworkInterfaceByIDParams creates a new PatchGuestNetworkInterfaceByIDParams 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 NewPatchGuestNetworkInterfaceByIDParams() *PatchGuestNetworkInterfaceByIDParams { - var () return &PatchGuestNetworkInterfaceByIDParams{ - timeout: cr.DefaultTimeout, } } // NewPatchGuestNetworkInterfaceByIDParamsWithTimeout creates a new PatchGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchGuestNetworkInterfaceByIDParamsWithTimeout(timeout time.Duration) *PatchGuestNetworkInterfaceByIDParams { - var () return &PatchGuestNetworkInterfaceByIDParams{ - timeout: timeout, } } // NewPatchGuestNetworkInterfaceByIDParamsWithContext creates a new PatchGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchGuestNetworkInterfaceByIDParamsWithContext(ctx context.Context) *PatchGuestNetworkInterfaceByIDParams { - var () return &PatchGuestNetworkInterfaceByIDParams{ - Context: ctx, } } // NewPatchGuestNetworkInterfaceByIDParamsWithHTTPClient creates a new PatchGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchGuestNetworkInterfaceByIDParamsWithHTTPClient(client *http.Client) *PatchGuestNetworkInterfaceByIDParams { - var () return &PatchGuestNetworkInterfaceByIDParams{ HTTPClient: client, } } -/*PatchGuestNetworkInterfaceByIDParams contains all the parameters to send to the API endpoint -for the patch guest network interface by ID operation typically these are written to a http.Request +/* +PatchGuestNetworkInterfaceByIDParams contains all the parameters to send to the API endpoint + + for the patch guest network interface by ID operation. + + Typically these are written to a http.Request. */ type PatchGuestNetworkInterfaceByIDParams struct { - /*Body - A subset of the guest network interface properties + /* Body. + A subset of the guest network interface properties */ Body *models.PartialNetworkInterface - /*IfaceID - The id of the guest network interface + /* IfaceID. + + The id of the guest network interface */ IfaceID string @@ -92,6 +93,21 @@ type PatchGuestNetworkInterfaceByIDParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch guest network interface by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchGuestNetworkInterfaceByIDParams) WithDefaults() *PatchGuestNetworkInterfaceByIDParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch guest network interface by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchGuestNetworkInterfaceByIDParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch guest network interface by ID params func (o *PatchGuestNetworkInterfaceByIDParams) WithTimeout(timeout time.Duration) *PatchGuestNetworkInterfaceByIDParams { o.SetTimeout(timeout) @@ -154,7 +170,6 @@ func (o *PatchGuestNetworkInterfaceByIDParams) WriteToRequest(r runtime.ClientRe return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_guest_network_interface_by_id_responses.go b/client/operations/patch_guest_network_interface_by_id_responses.go index 5b8ec57a..0dc07c01 100644 --- a/client/operations/patch_guest_network_interface_by_id_responses.go +++ b/client/operations/patch_guest_network_interface_by_id_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchGuestNetworkInterfaceByIDReader is a Reader for the PatchGuestNetworkInterfaceByID structure. @@ -35,7 +36,7 @@ type PatchGuestNetworkInterfaceByIDReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchGuestNetworkInterfaceByIDNoContent() @@ -66,15 +67,50 @@ func NewPatchGuestNetworkInterfaceByIDNoContent() *PatchGuestNetworkInterfaceByI return &PatchGuestNetworkInterfaceByIDNoContent{} } -/*PatchGuestNetworkInterfaceByIDNoContent handles this case with default header values. +/* +PatchGuestNetworkInterfaceByIDNoContent describes a response with status code 204, with default header values. Network interface updated */ type PatchGuestNetworkInterfaceByIDNoContent struct { } +// IsSuccess returns true when this patch guest network interface by Id no content response has a 2xx status code +func (o *PatchGuestNetworkInterfaceByIDNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch guest network interface by Id no content response has a 3xx status code +func (o *PatchGuestNetworkInterfaceByIDNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch guest network interface by Id no content response has a 4xx status code +func (o *PatchGuestNetworkInterfaceByIDNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch guest network interface by Id no content response has a 5xx status code +func (o *PatchGuestNetworkInterfaceByIDNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch guest network interface by Id no content response a status code equal to that given +func (o *PatchGuestNetworkInterfaceByIDNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch guest network interface by Id no content response +func (o *PatchGuestNetworkInterfaceByIDNoContent) Code() int { + return 204 +} + func (o *PatchGuestNetworkInterfaceByIDNoContent) Error() string { - return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdNoContent ", 204) + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdNoContent", 204) +} + +func (o *PatchGuestNetworkInterfaceByIDNoContent) String() string { + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdNoContent", 204) } func (o *PatchGuestNetworkInterfaceByIDNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchGuestNetworkInterfaceByIDBadRequest() *PatchGuestNetworkInterfaceBy return &PatchGuestNetworkInterfaceByIDBadRequest{} } -/*PatchGuestNetworkInterfaceByIDBadRequest handles this case with default header values. +/* +PatchGuestNetworkInterfaceByIDBadRequest describes a response with status code 400, with default header values. Network interface cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchGuestNetworkInterfaceByIDBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch guest network interface by Id bad request response has a 2xx status code +func (o *PatchGuestNetworkInterfaceByIDBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch guest network interface by Id bad request response has a 3xx status code +func (o *PatchGuestNetworkInterfaceByIDBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch guest network interface by Id bad request response has a 4xx status code +func (o *PatchGuestNetworkInterfaceByIDBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch guest network interface by Id bad request response has a 5xx status code +func (o *PatchGuestNetworkInterfaceByIDBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch guest network interface by Id bad request response a status code equal to that given +func (o *PatchGuestNetworkInterfaceByIDBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch guest network interface by Id bad request response +func (o *PatchGuestNetworkInterfaceByIDBadRequest) Code() int { + return 400 +} + func (o *PatchGuestNetworkInterfaceByIDBadRequest) Error() string { - return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdBadRequest %s", 400, payload) +} + +func (o *PatchGuestNetworkInterfaceByIDBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByIdBadRequest %s", 400, payload) } func (o *PatchGuestNetworkInterfaceByIDBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchGuestNetworkInterfaceByIDBadRequest) readResponse(response runtime o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchGuestNetworkInterfaceByIDDefault(code int) *PatchGuestNetworkInterf } } -/*PatchGuestNetworkInterfaceByIDDefault handles this case with default header values. +/* +PatchGuestNetworkInterfaceByIDDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchGuestNetworkInterfaceByIDDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch guest network interface by ID default response has a 2xx status code +func (o *PatchGuestNetworkInterfaceByIDDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch guest network interface by ID default response has a 3xx status code +func (o *PatchGuestNetworkInterfaceByIDDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch guest network interface by ID default response has a 4xx status code +func (o *PatchGuestNetworkInterfaceByIDDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch guest network interface by ID default response has a 5xx status code +func (o *PatchGuestNetworkInterfaceByIDDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch guest network interface by ID default response a status code equal to that given +func (o *PatchGuestNetworkInterfaceByIDDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch guest network interface by ID default response func (o *PatchGuestNetworkInterfaceByIDDefault) Code() int { return o._statusCode } func (o *PatchGuestNetworkInterfaceByIDDefault) Error() string { - return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByID default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByID default %s", o._statusCode, payload) +} + +func (o *PatchGuestNetworkInterfaceByIDDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /network-interfaces/{iface_id}][%d] patchGuestNetworkInterfaceByID default %s", o._statusCode, payload) } func (o *PatchGuestNetworkInterfaceByIDDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchGuestNetworkInterfaceByIDDefault) readResponse(response runtime.Cl o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_machine_configuration_parameters.go b/client/operations/patch_machine_configuration_parameters.go index 06308ce5..a3cf61a6 100644 --- a/client/operations/patch_machine_configuration_parameters.go +++ b/client/operations/patch_machine_configuration_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchMachineConfigurationParams creates a new PatchMachineConfigurationParams object -// with the default values initialized. +// NewPatchMachineConfigurationParams creates a new PatchMachineConfigurationParams 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 NewPatchMachineConfigurationParams() *PatchMachineConfigurationParams { - var () return &PatchMachineConfigurationParams{ - timeout: cr.DefaultTimeout, } } // NewPatchMachineConfigurationParamsWithTimeout creates a new PatchMachineConfigurationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchMachineConfigurationParamsWithTimeout(timeout time.Duration) *PatchMachineConfigurationParams { - var () return &PatchMachineConfigurationParams{ - timeout: timeout, } } // NewPatchMachineConfigurationParamsWithContext creates a new PatchMachineConfigurationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchMachineConfigurationParamsWithContext(ctx context.Context) *PatchMachineConfigurationParams { - var () return &PatchMachineConfigurationParams{ - Context: ctx, } } // NewPatchMachineConfigurationParamsWithHTTPClient creates a new PatchMachineConfigurationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchMachineConfigurationParamsWithHTTPClient(client *http.Client) *PatchMachineConfigurationParams { - var () return &PatchMachineConfigurationParams{ HTTPClient: client, } } -/*PatchMachineConfigurationParams contains all the parameters to send to the API endpoint -for the patch machine configuration operation typically these are written to a http.Request +/* +PatchMachineConfigurationParams contains all the parameters to send to the API endpoint + + for the patch machine configuration operation. + + Typically these are written to a http.Request. */ type PatchMachineConfigurationParams struct { - /*Body - A subset of Machine Configuration Parameters + /* Body. + A subset of Machine Configuration Parameters */ Body *models.MachineConfiguration @@ -87,6 +87,21 @@ type PatchMachineConfigurationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchMachineConfigurationParams) WithDefaults() *PatchMachineConfigurationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchMachineConfigurationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch machine configuration params func (o *PatchMachineConfigurationParams) WithTimeout(timeout time.Duration) *PatchMachineConfigurationParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PatchMachineConfigurationParams) WriteToRequest(r runtime.ClientRequest return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_machine_configuration_responses.go b/client/operations/patch_machine_configuration_responses.go index e62a34d5..bbb82bbf 100644 --- a/client/operations/patch_machine_configuration_responses.go +++ b/client/operations/patch_machine_configuration_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchMachineConfigurationReader is a Reader for the PatchMachineConfiguration structure. @@ -35,7 +36,7 @@ type PatchMachineConfigurationReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchMachineConfigurationNoContent() @@ -66,15 +67,50 @@ func NewPatchMachineConfigurationNoContent() *PatchMachineConfigurationNoContent return &PatchMachineConfigurationNoContent{} } -/*PatchMachineConfigurationNoContent handles this case with default header values. +/* +PatchMachineConfigurationNoContent describes a response with status code 204, with default header values. Machine Configuration created/updated */ type PatchMachineConfigurationNoContent struct { } +// IsSuccess returns true when this patch machine configuration no content response has a 2xx status code +func (o *PatchMachineConfigurationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch machine configuration no content response has a 3xx status code +func (o *PatchMachineConfigurationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch machine configuration no content response has a 4xx status code +func (o *PatchMachineConfigurationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch machine configuration no content response has a 5xx status code +func (o *PatchMachineConfigurationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch machine configuration no content response a status code equal to that given +func (o *PatchMachineConfigurationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch machine configuration no content response +func (o *PatchMachineConfigurationNoContent) Code() int { + return 204 +} + func (o *PatchMachineConfigurationNoContent) Error() string { - return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationNoContent ", 204) + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationNoContent", 204) +} + +func (o *PatchMachineConfigurationNoContent) String() string { + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationNoContent", 204) } func (o *PatchMachineConfigurationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchMachineConfigurationBadRequest() *PatchMachineConfigurationBadReque return &PatchMachineConfigurationBadRequest{} } -/*PatchMachineConfigurationBadRequest handles this case with default header values. +/* +PatchMachineConfigurationBadRequest describes a response with status code 400, with default header values. Machine Configuration cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchMachineConfigurationBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch machine configuration bad request response has a 2xx status code +func (o *PatchMachineConfigurationBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch machine configuration bad request response has a 3xx status code +func (o *PatchMachineConfigurationBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch machine configuration bad request response has a 4xx status code +func (o *PatchMachineConfigurationBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch machine configuration bad request response has a 5xx status code +func (o *PatchMachineConfigurationBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch machine configuration bad request response a status code equal to that given +func (o *PatchMachineConfigurationBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch machine configuration bad request response +func (o *PatchMachineConfigurationBadRequest) Code() int { + return 400 +} + func (o *PatchMachineConfigurationBadRequest) Error() string { - return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationBadRequest %s", 400, payload) +} + +func (o *PatchMachineConfigurationBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfigurationBadRequest %s", 400, payload) } func (o *PatchMachineConfigurationBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchMachineConfigurationBadRequest) readResponse(response runtime.Clie o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchMachineConfigurationDefault(code int) *PatchMachineConfigurationDef } } -/*PatchMachineConfigurationDefault handles this case with default header values. +/* +PatchMachineConfigurationDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchMachineConfigurationDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch machine configuration default response has a 2xx status code +func (o *PatchMachineConfigurationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch machine configuration default response has a 3xx status code +func (o *PatchMachineConfigurationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch machine configuration default response has a 4xx status code +func (o *PatchMachineConfigurationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch machine configuration default response has a 5xx status code +func (o *PatchMachineConfigurationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch machine configuration default response a status code equal to that given +func (o *PatchMachineConfigurationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch machine configuration default response func (o *PatchMachineConfigurationDefault) Code() int { return o._statusCode } func (o *PatchMachineConfigurationDefault) Error() string { - return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfiguration default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfiguration default %s", o._statusCode, payload) +} + +func (o *PatchMachineConfigurationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /machine-config][%d] patchMachineConfiguration default %s", o._statusCode, payload) } func (o *PatchMachineConfigurationDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchMachineConfigurationDefault) readResponse(response runtime.ClientR o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_mmds_parameters.go b/client/operations/patch_mmds_parameters.go index 6534fde7..0c47c88d 100644 --- a/client/operations/patch_mmds_parameters.go +++ b/client/operations/patch_mmds_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchMmdsParams creates a new PatchMmdsParams object -// with the default values initialized. +// NewPatchMmdsParams creates a new PatchMmdsParams 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 NewPatchMmdsParams() *PatchMmdsParams { - var () return &PatchMmdsParams{ - timeout: cr.DefaultTimeout, } } // NewPatchMmdsParamsWithTimeout creates a new PatchMmdsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchMmdsParamsWithTimeout(timeout time.Duration) *PatchMmdsParams { - var () return &PatchMmdsParams{ - timeout: timeout, } } // NewPatchMmdsParamsWithContext creates a new PatchMmdsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchMmdsParamsWithContext(ctx context.Context) *PatchMmdsParams { - var () return &PatchMmdsParams{ - Context: ctx, } } // NewPatchMmdsParamsWithHTTPClient creates a new PatchMmdsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchMmdsParamsWithHTTPClient(client *http.Client) *PatchMmdsParams { - var () return &PatchMmdsParams{ HTTPClient: client, } } -/*PatchMmdsParams contains all the parameters to send to the API endpoint -for the patch mmds operation typically these are written to a http.Request +/* +PatchMmdsParams contains all the parameters to send to the API endpoint + + for the patch mmds operation. + + Typically these are written to a http.Request. */ type PatchMmdsParams struct { - /*Body - The MMDS data store patch JSON. + /* Body. + The MMDS data store patch JSON. */ Body models.MmdsContentsObject @@ -87,6 +87,21 @@ type PatchMmdsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchMmdsParams) WithDefaults() *PatchMmdsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchMmdsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch mmds params func (o *PatchMmdsParams) WithTimeout(timeout time.Duration) *PatchMmdsParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PatchMmdsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_mmds_responses.go b/client/operations/patch_mmds_responses.go index 6e545dfb..69ea1f11 100644 --- a/client/operations/patch_mmds_responses.go +++ b/client/operations/patch_mmds_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchMmdsReader is a Reader for the PatchMmds structure. @@ -35,7 +36,7 @@ type PatchMmdsReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchMmdsNoContent() @@ -66,15 +67,50 @@ func NewPatchMmdsNoContent() *PatchMmdsNoContent { return &PatchMmdsNoContent{} } -/*PatchMmdsNoContent handles this case with default header values. +/* +PatchMmdsNoContent describes a response with status code 204, with default header values. MMDS data store updated. */ type PatchMmdsNoContent struct { } +// IsSuccess returns true when this patch mmds no content response has a 2xx status code +func (o *PatchMmdsNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch mmds no content response has a 3xx status code +func (o *PatchMmdsNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch mmds no content response has a 4xx status code +func (o *PatchMmdsNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch mmds no content response has a 5xx status code +func (o *PatchMmdsNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch mmds no content response a status code equal to that given +func (o *PatchMmdsNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch mmds no content response +func (o *PatchMmdsNoContent) Code() int { + return 204 +} + func (o *PatchMmdsNoContent) Error() string { - return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsNoContent ", 204) + return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsNoContent", 204) +} + +func (o *PatchMmdsNoContent) String() string { + return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsNoContent", 204) } func (o *PatchMmdsNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchMmdsBadRequest() *PatchMmdsBadRequest { return &PatchMmdsBadRequest{} } -/*PatchMmdsBadRequest handles this case with default header values. +/* +PatchMmdsBadRequest describes a response with status code 400, with default header values. MMDS data store cannot be updated due to bad input. */ @@ -95,8 +132,44 @@ type PatchMmdsBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch mmds bad request response has a 2xx status code +func (o *PatchMmdsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch mmds bad request response has a 3xx status code +func (o *PatchMmdsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch mmds bad request response has a 4xx status code +func (o *PatchMmdsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch mmds bad request response has a 5xx status code +func (o *PatchMmdsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch mmds bad request response a status code equal to that given +func (o *PatchMmdsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch mmds bad request response +func (o *PatchMmdsBadRequest) Code() int { + return 400 +} + func (o *PatchMmdsBadRequest) Error() string { - return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsBadRequest %s", 400, payload) +} + +func (o *PatchMmdsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /mmds][%d] patchMmdsBadRequest %s", 400, payload) } func (o *PatchMmdsBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchMmdsBadRequest) readResponse(response runtime.ClientResponse, cons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchMmdsDefault(code int) *PatchMmdsDefault { } } -/*PatchMmdsDefault handles this case with default header values. +/* +PatchMmdsDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchMmdsDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch mmds default response has a 2xx status code +func (o *PatchMmdsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch mmds default response has a 3xx status code +func (o *PatchMmdsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch mmds default response has a 4xx status code +func (o *PatchMmdsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch mmds default response has a 5xx status code +func (o *PatchMmdsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch mmds default response a status code equal to that given +func (o *PatchMmdsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch mmds default response func (o *PatchMmdsDefault) Code() int { return o._statusCode } func (o *PatchMmdsDefault) Error() string { - return fmt.Sprintf("[PATCH /mmds][%d] patchMmds default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /mmds][%d] patchMmds default %s", o._statusCode, payload) +} + +func (o *PatchMmdsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /mmds][%d] patchMmds default %s", o._statusCode, payload) } func (o *PatchMmdsDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchMmdsDefault) readResponse(response runtime.ClientResponse, consume o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/patch_vm_parameters.go b/client/operations/patch_vm_parameters.go index a2e52a95..b94a9bb9 100644 --- a/client/operations/patch_vm_parameters.go +++ b/client/operations/patch_vm_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPatchVMParams creates a new PatchVMParams object -// with the default values initialized. +// NewPatchVMParams creates a new PatchVMParams 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 NewPatchVMParams() *PatchVMParams { - var () return &PatchVMParams{ - timeout: cr.DefaultTimeout, } } // NewPatchVMParamsWithTimeout creates a new PatchVMParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPatchVMParamsWithTimeout(timeout time.Duration) *PatchVMParams { - var () return &PatchVMParams{ - timeout: timeout, } } // NewPatchVMParamsWithContext creates a new PatchVMParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPatchVMParamsWithContext(ctx context.Context) *PatchVMParams { - var () return &PatchVMParams{ - Context: ctx, } } // NewPatchVMParamsWithHTTPClient creates a new PatchVMParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPatchVMParamsWithHTTPClient(client *http.Client) *PatchVMParams { - var () return &PatchVMParams{ HTTPClient: client, } } -/*PatchVMParams contains all the parameters to send to the API endpoint -for the patch Vm operation typically these are written to a http.Request +/* +PatchVMParams contains all the parameters to send to the API endpoint + + for the patch Vm operation. + + Typically these are written to a http.Request. */ type PatchVMParams struct { - /*Body - The microVM state + /* Body. + The microVM state */ Body *models.VM @@ -87,6 +87,21 @@ type PatchVMParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the patch Vm params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchVMParams) WithDefaults() *PatchVMParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch Vm params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchVMParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the patch Vm params func (o *PatchVMParams) WithTimeout(timeout time.Duration) *PatchVMParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PatchVMParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/patch_vm_responses.go b/client/operations/patch_vm_responses.go index 2e9b2f61..b3129e71 100644 --- a/client/operations/patch_vm_responses.go +++ b/client/operations/patch_vm_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PatchVMReader is a Reader for the PatchVM structure. @@ -35,7 +36,7 @@ type PatchVMReader struct { } // ReadResponse reads a server response into the received o. -func (o *PatchVMReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PatchVMReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPatchVMNoContent() @@ -66,15 +67,50 @@ func NewPatchVMNoContent() *PatchVMNoContent { return &PatchVMNoContent{} } -/*PatchVMNoContent handles this case with default header values. +/* +PatchVMNoContent describes a response with status code 204, with default header values. Vm state updated */ type PatchVMNoContent struct { } +// IsSuccess returns true when this patch Vm no content response has a 2xx status code +func (o *PatchVMNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch Vm no content response has a 3xx status code +func (o *PatchVMNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch Vm no content response has a 4xx status code +func (o *PatchVMNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch Vm no content response has a 5xx status code +func (o *PatchVMNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this patch Vm no content response a status code equal to that given +func (o *PatchVMNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the patch Vm no content response +func (o *PatchVMNoContent) Code() int { + return 204 +} + func (o *PatchVMNoContent) Error() string { - return fmt.Sprintf("[PATCH /vm][%d] patchVmNoContent ", 204) + return fmt.Sprintf("[PATCH /vm][%d] patchVmNoContent", 204) +} + +func (o *PatchVMNoContent) String() string { + return fmt.Sprintf("[PATCH /vm][%d] patchVmNoContent", 204) } func (o *PatchVMNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPatchVMBadRequest() *PatchVMBadRequest { return &PatchVMBadRequest{} } -/*PatchVMBadRequest handles this case with default header values. +/* +PatchVMBadRequest describes a response with status code 400, with default header values. Vm state cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PatchVMBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this patch Vm bad request response has a 2xx status code +func (o *PatchVMBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this patch Vm bad request response has a 3xx status code +func (o *PatchVMBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch Vm bad request response has a 4xx status code +func (o *PatchVMBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this patch Vm bad request response has a 5xx status code +func (o *PatchVMBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this patch Vm bad request response a status code equal to that given +func (o *PatchVMBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the patch Vm bad request response +func (o *PatchVMBadRequest) Code() int { + return 400 +} + func (o *PatchVMBadRequest) Error() string { - return fmt.Sprintf("[PATCH /vm][%d] patchVmBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /vm][%d] patchVmBadRequest %s", 400, payload) +} + +func (o *PatchVMBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /vm][%d] patchVmBadRequest %s", 400, payload) } func (o *PatchVMBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PatchVMBadRequest) readResponse(response runtime.ClientResponse, consum o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPatchVMDefault(code int) *PatchVMDefault { } } -/*PatchVMDefault handles this case with default header values. +/* +PatchVMDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PatchVMDefault struct { Payload *models.Error } +// IsSuccess returns true when this patch Vm default response has a 2xx status code +func (o *PatchVMDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this patch Vm default response has a 3xx status code +func (o *PatchVMDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this patch Vm default response has a 4xx status code +func (o *PatchVMDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this patch Vm default response has a 5xx status code +func (o *PatchVMDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this patch Vm default response a status code equal to that given +func (o *PatchVMDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the patch Vm default response func (o *PatchVMDefault) Code() int { return o._statusCode } func (o *PatchVMDefault) Error() string { - return fmt.Sprintf("[PATCH /vm][%d] patchVm default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /vm][%d] patchVm default %s", o._statusCode, payload) +} + +func (o *PatchVMDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PATCH /vm][%d] patchVm default %s", o._statusCode, payload) } func (o *PatchVMDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PatchVMDefault) readResponse(response runtime.ClientResponse, consumer o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_balloon_parameters.go b/client/operations/put_balloon_parameters.go index f63048c9..cba35704 100644 --- a/client/operations/put_balloon_parameters.go +++ b/client/operations/put_balloon_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutBalloonParams creates a new PutBalloonParams object -// with the default values initialized. +// NewPutBalloonParams creates a new PutBalloonParams 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 NewPutBalloonParams() *PutBalloonParams { - var () return &PutBalloonParams{ - timeout: cr.DefaultTimeout, } } // NewPutBalloonParamsWithTimeout creates a new PutBalloonParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutBalloonParamsWithTimeout(timeout time.Duration) *PutBalloonParams { - var () return &PutBalloonParams{ - timeout: timeout, } } // NewPutBalloonParamsWithContext creates a new PutBalloonParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutBalloonParamsWithContext(ctx context.Context) *PutBalloonParams { - var () return &PutBalloonParams{ - Context: ctx, } } // NewPutBalloonParamsWithHTTPClient creates a new PutBalloonParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutBalloonParamsWithHTTPClient(client *http.Client) *PutBalloonParams { - var () return &PutBalloonParams{ HTTPClient: client, } } -/*PutBalloonParams contains all the parameters to send to the API endpoint -for the put balloon operation typically these are written to a http.Request +/* +PutBalloonParams contains all the parameters to send to the API endpoint + + for the put balloon operation. + + Typically these are written to a http.Request. */ type PutBalloonParams struct { - /*Body - Balloon properties + /* Body. + Balloon properties */ Body *models.Balloon @@ -87,6 +87,21 @@ type PutBalloonParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put balloon params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutBalloonParams) WithDefaults() *PutBalloonParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put balloon params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutBalloonParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put balloon params func (o *PutBalloonParams) WithTimeout(timeout time.Duration) *PutBalloonParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutBalloonParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_balloon_responses.go b/client/operations/put_balloon_responses.go index f1ed3e3c..8224f312 100644 --- a/client/operations/put_balloon_responses.go +++ b/client/operations/put_balloon_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutBalloonReader is a Reader for the PutBalloon structure. @@ -35,7 +36,7 @@ type PutBalloonReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutBalloonReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutBalloonReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutBalloonNoContent() @@ -66,15 +67,50 @@ func NewPutBalloonNoContent() *PutBalloonNoContent { return &PutBalloonNoContent{} } -/*PutBalloonNoContent handles this case with default header values. +/* +PutBalloonNoContent describes a response with status code 204, with default header values. Balloon device created/updated */ type PutBalloonNoContent struct { } +// IsSuccess returns true when this put balloon no content response has a 2xx status code +func (o *PutBalloonNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put balloon no content response has a 3xx status code +func (o *PutBalloonNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put balloon no content response has a 4xx status code +func (o *PutBalloonNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put balloon no content response has a 5xx status code +func (o *PutBalloonNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put balloon no content response a status code equal to that given +func (o *PutBalloonNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put balloon no content response +func (o *PutBalloonNoContent) Code() int { + return 204 +} + func (o *PutBalloonNoContent) Error() string { - return fmt.Sprintf("[PUT /balloon][%d] putBalloonNoContent ", 204) + return fmt.Sprintf("[PUT /balloon][%d] putBalloonNoContent", 204) +} + +func (o *PutBalloonNoContent) String() string { + return fmt.Sprintf("[PUT /balloon][%d] putBalloonNoContent", 204) } func (o *PutBalloonNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutBalloonBadRequest() *PutBalloonBadRequest { return &PutBalloonBadRequest{} } -/*PutBalloonBadRequest handles this case with default header values. +/* +PutBalloonBadRequest describes a response with status code 400, with default header values. Balloon device cannot be created/updated due to bad input */ @@ -95,8 +132,44 @@ type PutBalloonBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put balloon bad request response has a 2xx status code +func (o *PutBalloonBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put balloon bad request response has a 3xx status code +func (o *PutBalloonBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put balloon bad request response has a 4xx status code +func (o *PutBalloonBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put balloon bad request response has a 5xx status code +func (o *PutBalloonBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put balloon bad request response a status code equal to that given +func (o *PutBalloonBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put balloon bad request response +func (o *PutBalloonBadRequest) Code() int { + return 400 +} + func (o *PutBalloonBadRequest) Error() string { - return fmt.Sprintf("[PUT /balloon][%d] putBalloonBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /balloon][%d] putBalloonBadRequest %s", 400, payload) +} + +func (o *PutBalloonBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /balloon][%d] putBalloonBadRequest %s", 400, payload) } func (o *PutBalloonBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutBalloonBadRequest) readResponse(response runtime.ClientResponse, con o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutBalloonDefault(code int) *PutBalloonDefault { } } -/*PutBalloonDefault handles this case with default header values. +/* +PutBalloonDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutBalloonDefault struct { Payload *models.Error } +// IsSuccess returns true when this put balloon default response has a 2xx status code +func (o *PutBalloonDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put balloon default response has a 3xx status code +func (o *PutBalloonDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put balloon default response has a 4xx status code +func (o *PutBalloonDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put balloon default response has a 5xx status code +func (o *PutBalloonDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put balloon default response a status code equal to that given +func (o *PutBalloonDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put balloon default response func (o *PutBalloonDefault) Code() int { return o._statusCode } func (o *PutBalloonDefault) Error() string { - return fmt.Sprintf("[PUT /balloon][%d] putBalloon default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /balloon][%d] putBalloon default %s", o._statusCode, payload) +} + +func (o *PutBalloonDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /balloon][%d] putBalloon default %s", o._statusCode, payload) } func (o *PutBalloonDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutBalloonDefault) readResponse(response runtime.ClientResponse, consum o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_cpu_configuration_parameters.go b/client/operations/put_cpu_configuration_parameters.go index 6c30b446..9c14e0f2 100644 --- a/client/operations/put_cpu_configuration_parameters.go +++ b/client/operations/put_cpu_configuration_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutCPUConfigurationParams creates a new PutCPUConfigurationParams object -// with the default values initialized. +// NewPutCPUConfigurationParams creates a new PutCPUConfigurationParams 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 NewPutCPUConfigurationParams() *PutCPUConfigurationParams { - var () return &PutCPUConfigurationParams{ - timeout: cr.DefaultTimeout, } } // NewPutCPUConfigurationParamsWithTimeout creates a new PutCPUConfigurationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutCPUConfigurationParamsWithTimeout(timeout time.Duration) *PutCPUConfigurationParams { - var () return &PutCPUConfigurationParams{ - timeout: timeout, } } // NewPutCPUConfigurationParamsWithContext creates a new PutCPUConfigurationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutCPUConfigurationParamsWithContext(ctx context.Context) *PutCPUConfigurationParams { - var () return &PutCPUConfigurationParams{ - Context: ctx, } } // NewPutCPUConfigurationParamsWithHTTPClient creates a new PutCPUConfigurationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutCPUConfigurationParamsWithHTTPClient(client *http.Client) *PutCPUConfigurationParams { - var () return &PutCPUConfigurationParams{ HTTPClient: client, } } -/*PutCPUConfigurationParams contains all the parameters to send to the API endpoint -for the put Cpu configuration operation typically these are written to a http.Request +/* +PutCPUConfigurationParams contains all the parameters to send to the API endpoint + + for the put Cpu configuration operation. + + Typically these are written to a http.Request. */ type PutCPUConfigurationParams struct { - /*Body - CPU configuration request + /* Body. + CPU configuration request */ Body *models.CPUConfig @@ -87,6 +87,21 @@ type PutCPUConfigurationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put Cpu configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutCPUConfigurationParams) WithDefaults() *PutCPUConfigurationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put Cpu configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutCPUConfigurationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put Cpu configuration params func (o *PutCPUConfigurationParams) WithTimeout(timeout time.Duration) *PutCPUConfigurationParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutCPUConfigurationParams) WriteToRequest(r runtime.ClientRequest, reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_cpu_configuration_responses.go b/client/operations/put_cpu_configuration_responses.go index fd9e9ed8..ccc5b0a8 100644 --- a/client/operations/put_cpu_configuration_responses.go +++ b/client/operations/put_cpu_configuration_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutCPUConfigurationReader is a Reader for the PutCPUConfiguration structure. @@ -35,7 +36,7 @@ type PutCPUConfigurationReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutCPUConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutCPUConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutCPUConfigurationNoContent() @@ -66,15 +67,50 @@ func NewPutCPUConfigurationNoContent() *PutCPUConfigurationNoContent { return &PutCPUConfigurationNoContent{} } -/*PutCPUConfigurationNoContent handles this case with default header values. +/* +PutCPUConfigurationNoContent describes a response with status code 204, with default header values. CPU configuration set successfully */ type PutCPUConfigurationNoContent struct { } +// IsSuccess returns true when this put Cpu configuration no content response has a 2xx status code +func (o *PutCPUConfigurationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put Cpu configuration no content response has a 3xx status code +func (o *PutCPUConfigurationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put Cpu configuration no content response has a 4xx status code +func (o *PutCPUConfigurationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put Cpu configuration no content response has a 5xx status code +func (o *PutCPUConfigurationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put Cpu configuration no content response a status code equal to that given +func (o *PutCPUConfigurationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put Cpu configuration no content response +func (o *PutCPUConfigurationNoContent) Code() int { + return 204 +} + func (o *PutCPUConfigurationNoContent) Error() string { - return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationNoContent ", 204) + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationNoContent", 204) +} + +func (o *PutCPUConfigurationNoContent) String() string { + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationNoContent", 204) } func (o *PutCPUConfigurationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutCPUConfigurationBadRequest() *PutCPUConfigurationBadRequest { return &PutCPUConfigurationBadRequest{} } -/*PutCPUConfigurationBadRequest handles this case with default header values. +/* +PutCPUConfigurationBadRequest describes a response with status code 400, with default header values. CPU configuration cannot be updated due to invalid input format */ @@ -95,8 +132,44 @@ type PutCPUConfigurationBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put Cpu configuration bad request response has a 2xx status code +func (o *PutCPUConfigurationBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put Cpu configuration bad request response has a 3xx status code +func (o *PutCPUConfigurationBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put Cpu configuration bad request response has a 4xx status code +func (o *PutCPUConfigurationBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put Cpu configuration bad request response has a 5xx status code +func (o *PutCPUConfigurationBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put Cpu configuration bad request response a status code equal to that given +func (o *PutCPUConfigurationBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put Cpu configuration bad request response +func (o *PutCPUConfigurationBadRequest) Code() int { + return 400 +} + func (o *PutCPUConfigurationBadRequest) Error() string { - return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationBadRequest %s", 400, payload) +} + +func (o *PutCPUConfigurationBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationBadRequest %s", 400, payload) } func (o *PutCPUConfigurationBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutCPUConfigurationBadRequest) readResponse(response runtime.ClientResp o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutCPUConfigurationDefault(code int) *PutCPUConfigurationDefault { } } -/*PutCPUConfigurationDefault handles this case with default header values. +/* +PutCPUConfigurationDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutCPUConfigurationDefault struct { Payload *models.Error } +// IsSuccess returns true when this put Cpu configuration default response has a 2xx status code +func (o *PutCPUConfigurationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put Cpu configuration default response has a 3xx status code +func (o *PutCPUConfigurationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put Cpu configuration default response has a 4xx status code +func (o *PutCPUConfigurationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put Cpu configuration default response has a 5xx status code +func (o *PutCPUConfigurationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put Cpu configuration default response a status code equal to that given +func (o *PutCPUConfigurationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put Cpu configuration default response func (o *PutCPUConfigurationDefault) Code() int { return o._statusCode } func (o *PutCPUConfigurationDefault) Error() string { - return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfiguration default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfiguration default %s", o._statusCode, payload) +} + +func (o *PutCPUConfigurationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfiguration default %s", o._statusCode, payload) } func (o *PutCPUConfigurationDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutCPUConfigurationDefault) readResponse(response runtime.ClientRespons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_entropy_device_parameters.go b/client/operations/put_entropy_device_parameters.go index ffe36898..e82d49e1 100644 --- a/client/operations/put_entropy_device_parameters.go +++ b/client/operations/put_entropy_device_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutEntropyDeviceParams creates a new PutEntropyDeviceParams object -// with the default values initialized. +// NewPutEntropyDeviceParams creates a new PutEntropyDeviceParams 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 NewPutEntropyDeviceParams() *PutEntropyDeviceParams { - var () return &PutEntropyDeviceParams{ - timeout: cr.DefaultTimeout, } } // NewPutEntropyDeviceParamsWithTimeout creates a new PutEntropyDeviceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutEntropyDeviceParamsWithTimeout(timeout time.Duration) *PutEntropyDeviceParams { - var () return &PutEntropyDeviceParams{ - timeout: timeout, } } // NewPutEntropyDeviceParamsWithContext creates a new PutEntropyDeviceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutEntropyDeviceParamsWithContext(ctx context.Context) *PutEntropyDeviceParams { - var () return &PutEntropyDeviceParams{ - Context: ctx, } } // NewPutEntropyDeviceParamsWithHTTPClient creates a new PutEntropyDeviceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutEntropyDeviceParamsWithHTTPClient(client *http.Client) *PutEntropyDeviceParams { - var () return &PutEntropyDeviceParams{ HTTPClient: client, } } -/*PutEntropyDeviceParams contains all the parameters to send to the API endpoint -for the put entropy device operation typically these are written to a http.Request +/* +PutEntropyDeviceParams contains all the parameters to send to the API endpoint + + for the put entropy device operation. + + Typically these are written to a http.Request. */ type PutEntropyDeviceParams struct { - /*Body - Guest entropy device properties + /* Body. + Guest entropy device properties */ Body *models.EntropyDevice @@ -87,6 +87,21 @@ type PutEntropyDeviceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put entropy device params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutEntropyDeviceParams) WithDefaults() *PutEntropyDeviceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put entropy device params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutEntropyDeviceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put entropy device params func (o *PutEntropyDeviceParams) WithTimeout(timeout time.Duration) *PutEntropyDeviceParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutEntropyDeviceParams) WriteToRequest(r runtime.ClientRequest, reg str return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_entropy_device_responses.go b/client/operations/put_entropy_device_responses.go index de171755..964b0137 100644 --- a/client/operations/put_entropy_device_responses.go +++ b/client/operations/put_entropy_device_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutEntropyDeviceReader is a Reader for the PutEntropyDevice structure. @@ -35,7 +36,7 @@ type PutEntropyDeviceReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutEntropyDeviceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutEntropyDeviceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutEntropyDeviceNoContent() @@ -60,15 +61,50 @@ func NewPutEntropyDeviceNoContent() *PutEntropyDeviceNoContent { return &PutEntropyDeviceNoContent{} } -/*PutEntropyDeviceNoContent handles this case with default header values. +/* +PutEntropyDeviceNoContent describes a response with status code 204, with default header values. Entropy device created */ type PutEntropyDeviceNoContent struct { } +// IsSuccess returns true when this put entropy device no content response has a 2xx status code +func (o *PutEntropyDeviceNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put entropy device no content response has a 3xx status code +func (o *PutEntropyDeviceNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put entropy device no content response has a 4xx status code +func (o *PutEntropyDeviceNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put entropy device no content response has a 5xx status code +func (o *PutEntropyDeviceNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put entropy device no content response a status code equal to that given +func (o *PutEntropyDeviceNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put entropy device no content response +func (o *PutEntropyDeviceNoContent) Code() int { + return 204 +} + func (o *PutEntropyDeviceNoContent) Error() string { - return fmt.Sprintf("[PUT /entropy][%d] putEntropyDeviceNoContent ", 204) + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDeviceNoContent", 204) +} + +func (o *PutEntropyDeviceNoContent) String() string { + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDeviceNoContent", 204) } func (o *PutEntropyDeviceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -83,7 +119,8 @@ func NewPutEntropyDeviceDefault(code int) *PutEntropyDeviceDefault { } } -/*PutEntropyDeviceDefault handles this case with default header values. +/* +PutEntropyDeviceDefault describes a response with status code -1, with default header values. Internal server error */ @@ -93,13 +130,44 @@ type PutEntropyDeviceDefault struct { Payload *models.Error } +// IsSuccess returns true when this put entropy device default response has a 2xx status code +func (o *PutEntropyDeviceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put entropy device default response has a 3xx status code +func (o *PutEntropyDeviceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put entropy device default response has a 4xx status code +func (o *PutEntropyDeviceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put entropy device default response has a 5xx status code +func (o *PutEntropyDeviceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put entropy device default response a status code equal to that given +func (o *PutEntropyDeviceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put entropy device default response func (o *PutEntropyDeviceDefault) Code() int { return o._statusCode } func (o *PutEntropyDeviceDefault) Error() string { - return fmt.Sprintf("[PUT /entropy][%d] putEntropyDevice default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDevice default %s", o._statusCode, payload) +} + +func (o *PutEntropyDeviceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDevice default %s", o._statusCode, payload) } func (o *PutEntropyDeviceDefault) GetPayload() *models.Error { @@ -111,7 +179,7 @@ func (o *PutEntropyDeviceDefault) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_guest_boot_source_parameters.go b/client/operations/put_guest_boot_source_parameters.go index 318219d4..bad9cd0f 100644 --- a/client/operations/put_guest_boot_source_parameters.go +++ b/client/operations/put_guest_boot_source_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutGuestBootSourceParams creates a new PutGuestBootSourceParams object -// with the default values initialized. +// NewPutGuestBootSourceParams creates a new PutGuestBootSourceParams 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 NewPutGuestBootSourceParams() *PutGuestBootSourceParams { - var () return &PutGuestBootSourceParams{ - timeout: cr.DefaultTimeout, } } // NewPutGuestBootSourceParamsWithTimeout creates a new PutGuestBootSourceParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutGuestBootSourceParamsWithTimeout(timeout time.Duration) *PutGuestBootSourceParams { - var () return &PutGuestBootSourceParams{ - timeout: timeout, } } // NewPutGuestBootSourceParamsWithContext creates a new PutGuestBootSourceParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutGuestBootSourceParamsWithContext(ctx context.Context) *PutGuestBootSourceParams { - var () return &PutGuestBootSourceParams{ - Context: ctx, } } // NewPutGuestBootSourceParamsWithHTTPClient creates a new PutGuestBootSourceParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutGuestBootSourceParamsWithHTTPClient(client *http.Client) *PutGuestBootSourceParams { - var () return &PutGuestBootSourceParams{ HTTPClient: client, } } -/*PutGuestBootSourceParams contains all the parameters to send to the API endpoint -for the put guest boot source operation typically these are written to a http.Request +/* +PutGuestBootSourceParams contains all the parameters to send to the API endpoint + + for the put guest boot source operation. + + Typically these are written to a http.Request. */ type PutGuestBootSourceParams struct { - /*Body - Guest boot source properties + /* Body. + Guest boot source properties */ Body *models.BootSource @@ -87,6 +87,21 @@ type PutGuestBootSourceParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put guest boot source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestBootSourceParams) WithDefaults() *PutGuestBootSourceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put guest boot source params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestBootSourceParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put guest boot source params func (o *PutGuestBootSourceParams) WithTimeout(timeout time.Duration) *PutGuestBootSourceParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutGuestBootSourceParams) WriteToRequest(r runtime.ClientRequest, reg s return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_guest_boot_source_responses.go b/client/operations/put_guest_boot_source_responses.go index cf543ab0..fcfaea48 100644 --- a/client/operations/put_guest_boot_source_responses.go +++ b/client/operations/put_guest_boot_source_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutGuestBootSourceReader is a Reader for the PutGuestBootSource structure. @@ -35,7 +36,7 @@ type PutGuestBootSourceReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutGuestBootSourceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutGuestBootSourceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutGuestBootSourceNoContent() @@ -66,15 +67,50 @@ func NewPutGuestBootSourceNoContent() *PutGuestBootSourceNoContent { return &PutGuestBootSourceNoContent{} } -/*PutGuestBootSourceNoContent handles this case with default header values. +/* +PutGuestBootSourceNoContent describes a response with status code 204, with default header values. Boot source created/updated */ type PutGuestBootSourceNoContent struct { } +// IsSuccess returns true when this put guest boot source no content response has a 2xx status code +func (o *PutGuestBootSourceNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put guest boot source no content response has a 3xx status code +func (o *PutGuestBootSourceNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest boot source no content response has a 4xx status code +func (o *PutGuestBootSourceNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put guest boot source no content response has a 5xx status code +func (o *PutGuestBootSourceNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest boot source no content response a status code equal to that given +func (o *PutGuestBootSourceNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put guest boot source no content response +func (o *PutGuestBootSourceNoContent) Code() int { + return 204 +} + func (o *PutGuestBootSourceNoContent) Error() string { - return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceNoContent ", 204) + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceNoContent", 204) +} + +func (o *PutGuestBootSourceNoContent) String() string { + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceNoContent", 204) } func (o *PutGuestBootSourceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutGuestBootSourceBadRequest() *PutGuestBootSourceBadRequest { return &PutGuestBootSourceBadRequest{} } -/*PutGuestBootSourceBadRequest handles this case with default header values. +/* +PutGuestBootSourceBadRequest describes a response with status code 400, with default header values. Boot source cannot be created due to bad input */ @@ -95,8 +132,44 @@ type PutGuestBootSourceBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put guest boot source bad request response has a 2xx status code +func (o *PutGuestBootSourceBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put guest boot source bad request response has a 3xx status code +func (o *PutGuestBootSourceBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest boot source bad request response has a 4xx status code +func (o *PutGuestBootSourceBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put guest boot source bad request response has a 5xx status code +func (o *PutGuestBootSourceBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest boot source bad request response a status code equal to that given +func (o *PutGuestBootSourceBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put guest boot source bad request response +func (o *PutGuestBootSourceBadRequest) Code() int { + return 400 +} + func (o *PutGuestBootSourceBadRequest) Error() string { - return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceBadRequest %s", 400, payload) +} + +func (o *PutGuestBootSourceBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSourceBadRequest %s", 400, payload) } func (o *PutGuestBootSourceBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutGuestBootSourceBadRequest) readResponse(response runtime.ClientRespo o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutGuestBootSourceDefault(code int) *PutGuestBootSourceDefault { } } -/*PutGuestBootSourceDefault handles this case with default header values. +/* +PutGuestBootSourceDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutGuestBootSourceDefault struct { Payload *models.Error } +// IsSuccess returns true when this put guest boot source default response has a 2xx status code +func (o *PutGuestBootSourceDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put guest boot source default response has a 3xx status code +func (o *PutGuestBootSourceDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put guest boot source default response has a 4xx status code +func (o *PutGuestBootSourceDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put guest boot source default response has a 5xx status code +func (o *PutGuestBootSourceDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put guest boot source default response a status code equal to that given +func (o *PutGuestBootSourceDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put guest boot source default response func (o *PutGuestBootSourceDefault) Code() int { return o._statusCode } func (o *PutGuestBootSourceDefault) Error() string { - return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSource default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSource default %s", o._statusCode, payload) +} + +func (o *PutGuestBootSourceDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /boot-source][%d] putGuestBootSource default %s", o._statusCode, payload) } func (o *PutGuestBootSourceDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutGuestBootSourceDefault) readResponse(response runtime.ClientResponse o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_guest_drive_by_id_parameters.go b/client/operations/put_guest_drive_by_id_parameters.go index 3da0067f..aa4a9cd3 100644 --- a/client/operations/put_guest_drive_by_id_parameters.go +++ b/client/operations/put_guest_drive_by_id_parameters.go @@ -26,64 +26,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutGuestDriveByIDParams creates a new PutGuestDriveByIDParams object -// with the default values initialized. +// NewPutGuestDriveByIDParams creates a new PutGuestDriveByIDParams 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 NewPutGuestDriveByIDParams() *PutGuestDriveByIDParams { - var () return &PutGuestDriveByIDParams{ - timeout: cr.DefaultTimeout, } } // NewPutGuestDriveByIDParamsWithTimeout creates a new PutGuestDriveByIDParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutGuestDriveByIDParamsWithTimeout(timeout time.Duration) *PutGuestDriveByIDParams { - var () return &PutGuestDriveByIDParams{ - timeout: timeout, } } // NewPutGuestDriveByIDParamsWithContext creates a new PutGuestDriveByIDParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutGuestDriveByIDParamsWithContext(ctx context.Context) *PutGuestDriveByIDParams { - var () return &PutGuestDriveByIDParams{ - Context: ctx, } } // NewPutGuestDriveByIDParamsWithHTTPClient creates a new PutGuestDriveByIDParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutGuestDriveByIDParamsWithHTTPClient(client *http.Client) *PutGuestDriveByIDParams { - var () return &PutGuestDriveByIDParams{ HTTPClient: client, } } -/*PutGuestDriveByIDParams contains all the parameters to send to the API endpoint -for the put guest drive by ID operation typically these are written to a http.Request +/* +PutGuestDriveByIDParams contains all the parameters to send to the API endpoint + + for the put guest drive by ID operation. + + Typically these are written to a http.Request. */ type PutGuestDriveByIDParams struct { - /*Body - Guest drive properties + /* Body. + Guest drive properties */ Body *models.Drive - /*DriveID - The id of the guest drive + /* DriveID. + + The id of the guest drive */ DriveID string @@ -92,6 +93,21 @@ type PutGuestDriveByIDParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put guest drive by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestDriveByIDParams) WithDefaults() *PutGuestDriveByIDParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put guest drive by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestDriveByIDParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put guest drive by ID params func (o *PutGuestDriveByIDParams) WithTimeout(timeout time.Duration) *PutGuestDriveByIDParams { o.SetTimeout(timeout) @@ -154,7 +170,6 @@ func (o *PutGuestDriveByIDParams) WriteToRequest(r runtime.ClientRequest, reg st return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_guest_drive_by_id_responses.go b/client/operations/put_guest_drive_by_id_responses.go index ca839446..a3ea87da 100644 --- a/client/operations/put_guest_drive_by_id_responses.go +++ b/client/operations/put_guest_drive_by_id_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutGuestDriveByIDReader is a Reader for the PutGuestDriveByID structure. @@ -35,7 +36,7 @@ type PutGuestDriveByIDReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutGuestDriveByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutGuestDriveByIDNoContent() @@ -66,15 +67,50 @@ func NewPutGuestDriveByIDNoContent() *PutGuestDriveByIDNoContent { return &PutGuestDriveByIDNoContent{} } -/*PutGuestDriveByIDNoContent handles this case with default header values. +/* +PutGuestDriveByIDNoContent describes a response with status code 204, with default header values. Drive created/updated */ type PutGuestDriveByIDNoContent struct { } +// IsSuccess returns true when this put guest drive by Id no content response has a 2xx status code +func (o *PutGuestDriveByIDNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put guest drive by Id no content response has a 3xx status code +func (o *PutGuestDriveByIDNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest drive by Id no content response has a 4xx status code +func (o *PutGuestDriveByIDNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put guest drive by Id no content response has a 5xx status code +func (o *PutGuestDriveByIDNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest drive by Id no content response a status code equal to that given +func (o *PutGuestDriveByIDNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put guest drive by Id no content response +func (o *PutGuestDriveByIDNoContent) Code() int { + return 204 +} + func (o *PutGuestDriveByIDNoContent) Error() string { - return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdNoContent ", 204) + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdNoContent", 204) +} + +func (o *PutGuestDriveByIDNoContent) String() string { + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdNoContent", 204) } func (o *PutGuestDriveByIDNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutGuestDriveByIDBadRequest() *PutGuestDriveByIDBadRequest { return &PutGuestDriveByIDBadRequest{} } -/*PutGuestDriveByIDBadRequest handles this case with default header values. +/* +PutGuestDriveByIDBadRequest describes a response with status code 400, with default header values. Drive cannot be created/updated due to bad input */ @@ -95,8 +132,44 @@ type PutGuestDriveByIDBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put guest drive by Id bad request response has a 2xx status code +func (o *PutGuestDriveByIDBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put guest drive by Id bad request response has a 3xx status code +func (o *PutGuestDriveByIDBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest drive by Id bad request response has a 4xx status code +func (o *PutGuestDriveByIDBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put guest drive by Id bad request response has a 5xx status code +func (o *PutGuestDriveByIDBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest drive by Id bad request response a status code equal to that given +func (o *PutGuestDriveByIDBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put guest drive by Id bad request response +func (o *PutGuestDriveByIDBadRequest) Code() int { + return 400 +} + func (o *PutGuestDriveByIDBadRequest) Error() string { - return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdBadRequest %s", 400, payload) +} + +func (o *PutGuestDriveByIDBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByIdBadRequest %s", 400, payload) } func (o *PutGuestDriveByIDBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutGuestDriveByIDBadRequest) readResponse(response runtime.ClientRespon o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutGuestDriveByIDDefault(code int) *PutGuestDriveByIDDefault { } } -/*PutGuestDriveByIDDefault handles this case with default header values. +/* +PutGuestDriveByIDDefault describes a response with status code -1, with default header values. Internal server error. */ @@ -132,13 +206,44 @@ type PutGuestDriveByIDDefault struct { Payload *models.Error } +// IsSuccess returns true when this put guest drive by ID default response has a 2xx status code +func (o *PutGuestDriveByIDDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put guest drive by ID default response has a 3xx status code +func (o *PutGuestDriveByIDDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put guest drive by ID default response has a 4xx status code +func (o *PutGuestDriveByIDDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put guest drive by ID default response has a 5xx status code +func (o *PutGuestDriveByIDDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put guest drive by ID default response a status code equal to that given +func (o *PutGuestDriveByIDDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put guest drive by ID default response func (o *PutGuestDriveByIDDefault) Code() int { return o._statusCode } func (o *PutGuestDriveByIDDefault) Error() string { - return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByID default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByID default %s", o._statusCode, payload) +} + +func (o *PutGuestDriveByIDDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /drives/{drive_id}][%d] putGuestDriveByID default %s", o._statusCode, payload) } func (o *PutGuestDriveByIDDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutGuestDriveByIDDefault) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_guest_network_interface_by_id_parameters.go b/client/operations/put_guest_network_interface_by_id_parameters.go index 17082193..775bf1f8 100644 --- a/client/operations/put_guest_network_interface_by_id_parameters.go +++ b/client/operations/put_guest_network_interface_by_id_parameters.go @@ -26,64 +26,65 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutGuestNetworkInterfaceByIDParams creates a new PutGuestNetworkInterfaceByIDParams object -// with the default values initialized. +// NewPutGuestNetworkInterfaceByIDParams creates a new PutGuestNetworkInterfaceByIDParams 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 NewPutGuestNetworkInterfaceByIDParams() *PutGuestNetworkInterfaceByIDParams { - var () return &PutGuestNetworkInterfaceByIDParams{ - timeout: cr.DefaultTimeout, } } // NewPutGuestNetworkInterfaceByIDParamsWithTimeout creates a new PutGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutGuestNetworkInterfaceByIDParamsWithTimeout(timeout time.Duration) *PutGuestNetworkInterfaceByIDParams { - var () return &PutGuestNetworkInterfaceByIDParams{ - timeout: timeout, } } // NewPutGuestNetworkInterfaceByIDParamsWithContext creates a new PutGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutGuestNetworkInterfaceByIDParamsWithContext(ctx context.Context) *PutGuestNetworkInterfaceByIDParams { - var () return &PutGuestNetworkInterfaceByIDParams{ - Context: ctx, } } // NewPutGuestNetworkInterfaceByIDParamsWithHTTPClient creates a new PutGuestNetworkInterfaceByIDParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutGuestNetworkInterfaceByIDParamsWithHTTPClient(client *http.Client) *PutGuestNetworkInterfaceByIDParams { - var () return &PutGuestNetworkInterfaceByIDParams{ HTTPClient: client, } } -/*PutGuestNetworkInterfaceByIDParams contains all the parameters to send to the API endpoint -for the put guest network interface by ID operation typically these are written to a http.Request +/* +PutGuestNetworkInterfaceByIDParams contains all the parameters to send to the API endpoint + + for the put guest network interface by ID operation. + + Typically these are written to a http.Request. */ type PutGuestNetworkInterfaceByIDParams struct { - /*Body - Guest network interface properties + /* Body. + Guest network interface properties */ Body *models.NetworkInterface - /*IfaceID - The id of the guest network interface + /* IfaceID. + + The id of the guest network interface */ IfaceID string @@ -92,6 +93,21 @@ type PutGuestNetworkInterfaceByIDParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put guest network interface by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestNetworkInterfaceByIDParams) WithDefaults() *PutGuestNetworkInterfaceByIDParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put guest network interface by ID params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestNetworkInterfaceByIDParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put guest network interface by ID params func (o *PutGuestNetworkInterfaceByIDParams) WithTimeout(timeout time.Duration) *PutGuestNetworkInterfaceByIDParams { o.SetTimeout(timeout) @@ -154,7 +170,6 @@ func (o *PutGuestNetworkInterfaceByIDParams) WriteToRequest(r runtime.ClientRequ return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_guest_network_interface_by_id_responses.go b/client/operations/put_guest_network_interface_by_id_responses.go index b7f4b99a..aa7ddbc9 100644 --- a/client/operations/put_guest_network_interface_by_id_responses.go +++ b/client/operations/put_guest_network_interface_by_id_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutGuestNetworkInterfaceByIDReader is a Reader for the PutGuestNetworkInterfaceByID structure. @@ -35,7 +36,7 @@ type PutGuestNetworkInterfaceByIDReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutGuestNetworkInterfaceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutGuestNetworkInterfaceByIDNoContent() @@ -66,15 +67,50 @@ func NewPutGuestNetworkInterfaceByIDNoContent() *PutGuestNetworkInterfaceByIDNoC return &PutGuestNetworkInterfaceByIDNoContent{} } -/*PutGuestNetworkInterfaceByIDNoContent handles this case with default header values. +/* +PutGuestNetworkInterfaceByIDNoContent describes a response with status code 204, with default header values. Network interface created/updated */ type PutGuestNetworkInterfaceByIDNoContent struct { } +// IsSuccess returns true when this put guest network interface by Id no content response has a 2xx status code +func (o *PutGuestNetworkInterfaceByIDNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put guest network interface by Id no content response has a 3xx status code +func (o *PutGuestNetworkInterfaceByIDNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest network interface by Id no content response has a 4xx status code +func (o *PutGuestNetworkInterfaceByIDNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put guest network interface by Id no content response has a 5xx status code +func (o *PutGuestNetworkInterfaceByIDNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest network interface by Id no content response a status code equal to that given +func (o *PutGuestNetworkInterfaceByIDNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put guest network interface by Id no content response +func (o *PutGuestNetworkInterfaceByIDNoContent) Code() int { + return 204 +} + func (o *PutGuestNetworkInterfaceByIDNoContent) Error() string { - return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdNoContent ", 204) + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdNoContent", 204) +} + +func (o *PutGuestNetworkInterfaceByIDNoContent) String() string { + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdNoContent", 204) } func (o *PutGuestNetworkInterfaceByIDNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutGuestNetworkInterfaceByIDBadRequest() *PutGuestNetworkInterfaceByIDBa return &PutGuestNetworkInterfaceByIDBadRequest{} } -/*PutGuestNetworkInterfaceByIDBadRequest handles this case with default header values. +/* +PutGuestNetworkInterfaceByIDBadRequest describes a response with status code 400, with default header values. Network interface cannot be created due to bad input */ @@ -95,8 +132,44 @@ type PutGuestNetworkInterfaceByIDBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put guest network interface by Id bad request response has a 2xx status code +func (o *PutGuestNetworkInterfaceByIDBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put guest network interface by Id bad request response has a 3xx status code +func (o *PutGuestNetworkInterfaceByIDBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest network interface by Id bad request response has a 4xx status code +func (o *PutGuestNetworkInterfaceByIDBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put guest network interface by Id bad request response has a 5xx status code +func (o *PutGuestNetworkInterfaceByIDBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest network interface by Id bad request response a status code equal to that given +func (o *PutGuestNetworkInterfaceByIDBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put guest network interface by Id bad request response +func (o *PutGuestNetworkInterfaceByIDBadRequest) Code() int { + return 400 +} + func (o *PutGuestNetworkInterfaceByIDBadRequest) Error() string { - return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdBadRequest %s", 400, payload) +} + +func (o *PutGuestNetworkInterfaceByIDBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByIdBadRequest %s", 400, payload) } func (o *PutGuestNetworkInterfaceByIDBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutGuestNetworkInterfaceByIDBadRequest) readResponse(response runtime.C o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutGuestNetworkInterfaceByIDDefault(code int) *PutGuestNetworkInterfaceB } } -/*PutGuestNetworkInterfaceByIDDefault handles this case with default header values. +/* +PutGuestNetworkInterfaceByIDDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutGuestNetworkInterfaceByIDDefault struct { Payload *models.Error } +// IsSuccess returns true when this put guest network interface by ID default response has a 2xx status code +func (o *PutGuestNetworkInterfaceByIDDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put guest network interface by ID default response has a 3xx status code +func (o *PutGuestNetworkInterfaceByIDDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put guest network interface by ID default response has a 4xx status code +func (o *PutGuestNetworkInterfaceByIDDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put guest network interface by ID default response has a 5xx status code +func (o *PutGuestNetworkInterfaceByIDDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put guest network interface by ID default response a status code equal to that given +func (o *PutGuestNetworkInterfaceByIDDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put guest network interface by ID default response func (o *PutGuestNetworkInterfaceByIDDefault) Code() int { return o._statusCode } func (o *PutGuestNetworkInterfaceByIDDefault) Error() string { - return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByID default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByID default %s", o._statusCode, payload) +} + +func (o *PutGuestNetworkInterfaceByIDDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /network-interfaces/{iface_id}][%d] putGuestNetworkInterfaceByID default %s", o._statusCode, payload) } func (o *PutGuestNetworkInterfaceByIDDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutGuestNetworkInterfaceByIDDefault) readResponse(response runtime.Clie o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_guest_vsock_parameters.go b/client/operations/put_guest_vsock_parameters.go index 9147587f..826045d6 100644 --- a/client/operations/put_guest_vsock_parameters.go +++ b/client/operations/put_guest_vsock_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutGuestVsockParams creates a new PutGuestVsockParams object -// with the default values initialized. +// NewPutGuestVsockParams creates a new PutGuestVsockParams 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 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 +// with 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 +// with 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 +// with 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 +/* +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. + Guest vsock properties */ Body *models.Vsock @@ -87,6 +87,21 @@ type PutGuestVsockParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put guest vsock params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestVsockParams) WithDefaults() *PutGuestVsockParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put guest vsock params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutGuestVsockParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put guest vsock params func (o *PutGuestVsockParams) WithTimeout(timeout time.Duration) *PutGuestVsockParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutGuestVsockParams) WriteToRequest(r runtime.ClientRequest, reg strfmt return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_guest_vsock_responses.go b/client/operations/put_guest_vsock_responses.go index 56305bb4..938d049e 100644 --- a/client/operations/put_guest_vsock_responses.go +++ b/client/operations/put_guest_vsock_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutGuestVsockReader is a Reader for the PutGuestVsock structure. @@ -35,7 +36,7 @@ type PutGuestVsockReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutGuestVsockReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutGuestVsockReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutGuestVsockNoContent() @@ -66,15 +67,50 @@ func NewPutGuestVsockNoContent() *PutGuestVsockNoContent { return &PutGuestVsockNoContent{} } -/*PutGuestVsockNoContent handles this case with default header values. +/* +PutGuestVsockNoContent describes a response with status code 204, with default header values. Vsock created/updated */ type PutGuestVsockNoContent struct { } +// IsSuccess returns true when this put guest vsock no content response has a 2xx status code +func (o *PutGuestVsockNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put guest vsock no content response has a 3xx status code +func (o *PutGuestVsockNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest vsock no content response has a 4xx status code +func (o *PutGuestVsockNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put guest vsock no content response has a 5xx status code +func (o *PutGuestVsockNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest vsock no content response a status code equal to that given +func (o *PutGuestVsockNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put guest vsock no content response +func (o *PutGuestVsockNoContent) Code() int { + return 204 +} + func (o *PutGuestVsockNoContent) Error() string { - return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockNoContent ", 204) + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockNoContent", 204) +} + +func (o *PutGuestVsockNoContent) String() string { + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockNoContent", 204) } func (o *PutGuestVsockNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutGuestVsockBadRequest() *PutGuestVsockBadRequest { return &PutGuestVsockBadRequest{} } -/*PutGuestVsockBadRequest handles this case with default header values. +/* +PutGuestVsockBadRequest describes a response with status code 400, with default header values. Vsock cannot be created due to bad input */ @@ -95,8 +132,44 @@ type PutGuestVsockBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put guest vsock bad request response has a 2xx status code +func (o *PutGuestVsockBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put guest vsock bad request response has a 3xx status code +func (o *PutGuestVsockBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put guest vsock bad request response has a 4xx status code +func (o *PutGuestVsockBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put guest vsock bad request response has a 5xx status code +func (o *PutGuestVsockBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put guest vsock bad request response a status code equal to that given +func (o *PutGuestVsockBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put guest vsock bad request response +func (o *PutGuestVsockBadRequest) Code() int { + return 400 +} + func (o *PutGuestVsockBadRequest) Error() string { - return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockBadRequest %s", 400, payload) +} + +func (o *PutGuestVsockBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsockBadRequest %s", 400, payload) } func (o *PutGuestVsockBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutGuestVsockBadRequest) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutGuestVsockDefault(code int) *PutGuestVsockDefault { } } -/*PutGuestVsockDefault handles this case with default header values. +/* +PutGuestVsockDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutGuestVsockDefault struct { Payload *models.Error } +// IsSuccess returns true when this put guest vsock default response has a 2xx status code +func (o *PutGuestVsockDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put guest vsock default response has a 3xx status code +func (o *PutGuestVsockDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put guest vsock default response has a 4xx status code +func (o *PutGuestVsockDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put guest vsock default response has a 5xx status code +func (o *PutGuestVsockDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put guest vsock default response a status code equal to that given +func (o *PutGuestVsockDefault) IsCode(code int) bool { + return o._statusCode == code +} + // 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) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsock default %s", o._statusCode, payload) +} + +func (o *PutGuestVsockDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /vsock][%d] putGuestVsock default %s", o._statusCode, payload) } func (o *PutGuestVsockDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutGuestVsockDefault) readResponse(response runtime.ClientResponse, con o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_logger_parameters.go b/client/operations/put_logger_parameters.go index 8a7a60d8..9cc00cba 100644 --- a/client/operations/put_logger_parameters.go +++ b/client/operations/put_logger_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutLoggerParams creates a new PutLoggerParams object -// with the default values initialized. +// NewPutLoggerParams creates a new PutLoggerParams 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 NewPutLoggerParams() *PutLoggerParams { - var () return &PutLoggerParams{ - timeout: cr.DefaultTimeout, } } // NewPutLoggerParamsWithTimeout creates a new PutLoggerParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutLoggerParamsWithTimeout(timeout time.Duration) *PutLoggerParams { - var () return &PutLoggerParams{ - timeout: timeout, } } // NewPutLoggerParamsWithContext creates a new PutLoggerParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutLoggerParamsWithContext(ctx context.Context) *PutLoggerParams { - var () return &PutLoggerParams{ - Context: ctx, } } // NewPutLoggerParamsWithHTTPClient creates a new PutLoggerParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutLoggerParamsWithHTTPClient(client *http.Client) *PutLoggerParams { - var () return &PutLoggerParams{ HTTPClient: client, } } -/*PutLoggerParams contains all the parameters to send to the API endpoint -for the put logger operation typically these are written to a http.Request +/* +PutLoggerParams contains all the parameters to send to the API endpoint + + for the put logger operation. + + Typically these are written to a http.Request. */ type PutLoggerParams struct { - /*Body - Logging system description + /* Body. + Logging system description */ Body *models.Logger @@ -87,6 +87,21 @@ type PutLoggerParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put logger params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutLoggerParams) WithDefaults() *PutLoggerParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put logger params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutLoggerParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put logger params func (o *PutLoggerParams) WithTimeout(timeout time.Duration) *PutLoggerParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutLoggerParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_logger_responses.go b/client/operations/put_logger_responses.go index d1fc4671..95ec6d21 100644 --- a/client/operations/put_logger_responses.go +++ b/client/operations/put_logger_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutLoggerReader is a Reader for the PutLogger structure. @@ -35,7 +36,7 @@ type PutLoggerReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutLoggerReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutLoggerReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutLoggerNoContent() @@ -66,15 +67,50 @@ func NewPutLoggerNoContent() *PutLoggerNoContent { return &PutLoggerNoContent{} } -/*PutLoggerNoContent handles this case with default header values. +/* +PutLoggerNoContent describes a response with status code 204, with default header values. Logger created. */ type PutLoggerNoContent struct { } +// IsSuccess returns true when this put logger no content response has a 2xx status code +func (o *PutLoggerNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put logger no content response has a 3xx status code +func (o *PutLoggerNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put logger no content response has a 4xx status code +func (o *PutLoggerNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put logger no content response has a 5xx status code +func (o *PutLoggerNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put logger no content response a status code equal to that given +func (o *PutLoggerNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put logger no content response +func (o *PutLoggerNoContent) Code() int { + return 204 +} + func (o *PutLoggerNoContent) Error() string { - return fmt.Sprintf("[PUT /logger][%d] putLoggerNoContent ", 204) + return fmt.Sprintf("[PUT /logger][%d] putLoggerNoContent", 204) +} + +func (o *PutLoggerNoContent) String() string { + return fmt.Sprintf("[PUT /logger][%d] putLoggerNoContent", 204) } func (o *PutLoggerNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutLoggerBadRequest() *PutLoggerBadRequest { return &PutLoggerBadRequest{} } -/*PutLoggerBadRequest handles this case with default header values. +/* +PutLoggerBadRequest describes a response with status code 400, with default header values. Logger cannot be initialized due to bad input. */ @@ -95,8 +132,44 @@ type PutLoggerBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put logger bad request response has a 2xx status code +func (o *PutLoggerBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put logger bad request response has a 3xx status code +func (o *PutLoggerBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put logger bad request response has a 4xx status code +func (o *PutLoggerBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put logger bad request response has a 5xx status code +func (o *PutLoggerBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put logger bad request response a status code equal to that given +func (o *PutLoggerBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put logger bad request response +func (o *PutLoggerBadRequest) Code() int { + return 400 +} + func (o *PutLoggerBadRequest) Error() string { - return fmt.Sprintf("[PUT /logger][%d] putLoggerBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /logger][%d] putLoggerBadRequest %s", 400, payload) +} + +func (o *PutLoggerBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /logger][%d] putLoggerBadRequest %s", 400, payload) } func (o *PutLoggerBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutLoggerBadRequest) readResponse(response runtime.ClientResponse, cons o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutLoggerDefault(code int) *PutLoggerDefault { } } -/*PutLoggerDefault handles this case with default header values. +/* +PutLoggerDefault describes a response with status code -1, with default header values. Internal server error. */ @@ -132,13 +206,44 @@ type PutLoggerDefault struct { Payload *models.Error } +// IsSuccess returns true when this put logger default response has a 2xx status code +func (o *PutLoggerDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put logger default response has a 3xx status code +func (o *PutLoggerDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put logger default response has a 4xx status code +func (o *PutLoggerDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put logger default response has a 5xx status code +func (o *PutLoggerDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put logger default response a status code equal to that given +func (o *PutLoggerDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put logger default response func (o *PutLoggerDefault) Code() int { return o._statusCode } func (o *PutLoggerDefault) Error() string { - return fmt.Sprintf("[PUT /logger][%d] putLogger default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /logger][%d] putLogger default %s", o._statusCode, payload) +} + +func (o *PutLoggerDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /logger][%d] putLogger default %s", o._statusCode, payload) } func (o *PutLoggerDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutLoggerDefault) readResponse(response runtime.ClientResponse, consume o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_machine_configuration_parameters.go b/client/operations/put_machine_configuration_parameters.go index e054d50f..d03432c4 100644 --- a/client/operations/put_machine_configuration_parameters.go +++ b/client/operations/put_machine_configuration_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutMachineConfigurationParams creates a new PutMachineConfigurationParams object -// with the default values initialized. +// NewPutMachineConfigurationParams creates a new PutMachineConfigurationParams 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 NewPutMachineConfigurationParams() *PutMachineConfigurationParams { - var () return &PutMachineConfigurationParams{ - timeout: cr.DefaultTimeout, } } // NewPutMachineConfigurationParamsWithTimeout creates a new PutMachineConfigurationParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutMachineConfigurationParamsWithTimeout(timeout time.Duration) *PutMachineConfigurationParams { - var () return &PutMachineConfigurationParams{ - timeout: timeout, } } // NewPutMachineConfigurationParamsWithContext creates a new PutMachineConfigurationParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutMachineConfigurationParamsWithContext(ctx context.Context) *PutMachineConfigurationParams { - var () return &PutMachineConfigurationParams{ - Context: ctx, } } // NewPutMachineConfigurationParamsWithHTTPClient creates a new PutMachineConfigurationParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutMachineConfigurationParamsWithHTTPClient(client *http.Client) *PutMachineConfigurationParams { - var () return &PutMachineConfigurationParams{ HTTPClient: client, } } -/*PutMachineConfigurationParams contains all the parameters to send to the API endpoint -for the put machine configuration operation typically these are written to a http.Request +/* +PutMachineConfigurationParams contains all the parameters to send to the API endpoint + + for the put machine configuration operation. + + Typically these are written to a http.Request. */ type PutMachineConfigurationParams struct { - /*Body - Machine Configuration Parameters + /* Body. + Machine Configuration Parameters */ Body *models.MachineConfiguration @@ -87,6 +87,21 @@ type PutMachineConfigurationParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMachineConfigurationParams) WithDefaults() *PutMachineConfigurationParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put machine configuration params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMachineConfigurationParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put machine configuration params func (o *PutMachineConfigurationParams) WithTimeout(timeout time.Duration) *PutMachineConfigurationParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutMachineConfigurationParams) WriteToRequest(r runtime.ClientRequest, return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_machine_configuration_responses.go b/client/operations/put_machine_configuration_responses.go index 31f1b2b4..ff6bc981 100644 --- a/client/operations/put_machine_configuration_responses.go +++ b/client/operations/put_machine_configuration_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutMachineConfigurationReader is a Reader for the PutMachineConfiguration structure. @@ -35,7 +36,7 @@ type PutMachineConfigurationReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutMachineConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutMachineConfigurationNoContent() @@ -66,15 +67,50 @@ func NewPutMachineConfigurationNoContent() *PutMachineConfigurationNoContent { return &PutMachineConfigurationNoContent{} } -/*PutMachineConfigurationNoContent handles this case with default header values. +/* +PutMachineConfigurationNoContent describes a response with status code 204, with default header values. Machine Configuration created/updated */ type PutMachineConfigurationNoContent struct { } +// IsSuccess returns true when this put machine configuration no content response has a 2xx status code +func (o *PutMachineConfigurationNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put machine configuration no content response has a 3xx status code +func (o *PutMachineConfigurationNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put machine configuration no content response has a 4xx status code +func (o *PutMachineConfigurationNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put machine configuration no content response has a 5xx status code +func (o *PutMachineConfigurationNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put machine configuration no content response a status code equal to that given +func (o *PutMachineConfigurationNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put machine configuration no content response +func (o *PutMachineConfigurationNoContent) Code() int { + return 204 +} + func (o *PutMachineConfigurationNoContent) Error() string { - return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationNoContent ", 204) + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationNoContent", 204) +} + +func (o *PutMachineConfigurationNoContent) String() string { + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationNoContent", 204) } func (o *PutMachineConfigurationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutMachineConfigurationBadRequest() *PutMachineConfigurationBadRequest { return &PutMachineConfigurationBadRequest{} } -/*PutMachineConfigurationBadRequest handles this case with default header values. +/* +PutMachineConfigurationBadRequest describes a response with status code 400, with default header values. Machine Configuration cannot be updated due to bad input */ @@ -95,8 +132,44 @@ type PutMachineConfigurationBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put machine configuration bad request response has a 2xx status code +func (o *PutMachineConfigurationBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put machine configuration bad request response has a 3xx status code +func (o *PutMachineConfigurationBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put machine configuration bad request response has a 4xx status code +func (o *PutMachineConfigurationBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put machine configuration bad request response has a 5xx status code +func (o *PutMachineConfigurationBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put machine configuration bad request response a status code equal to that given +func (o *PutMachineConfigurationBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put machine configuration bad request response +func (o *PutMachineConfigurationBadRequest) Code() int { + return 400 +} + func (o *PutMachineConfigurationBadRequest) Error() string { - return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationBadRequest %s", 400, payload) +} + +func (o *PutMachineConfigurationBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfigurationBadRequest %s", 400, payload) } func (o *PutMachineConfigurationBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutMachineConfigurationBadRequest) readResponse(response runtime.Client o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutMachineConfigurationDefault(code int) *PutMachineConfigurationDefault } } -/*PutMachineConfigurationDefault handles this case with default header values. +/* +PutMachineConfigurationDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutMachineConfigurationDefault struct { Payload *models.Error } +// IsSuccess returns true when this put machine configuration default response has a 2xx status code +func (o *PutMachineConfigurationDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put machine configuration default response has a 3xx status code +func (o *PutMachineConfigurationDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put machine configuration default response has a 4xx status code +func (o *PutMachineConfigurationDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put machine configuration default response has a 5xx status code +func (o *PutMachineConfigurationDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put machine configuration default response a status code equal to that given +func (o *PutMachineConfigurationDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put machine configuration default response func (o *PutMachineConfigurationDefault) Code() int { return o._statusCode } func (o *PutMachineConfigurationDefault) Error() string { - return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfiguration default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfiguration default %s", o._statusCode, payload) +} + +func (o *PutMachineConfigurationDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /machine-config][%d] putMachineConfiguration default %s", o._statusCode, payload) } func (o *PutMachineConfigurationDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutMachineConfigurationDefault) readResponse(response runtime.ClientRes o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_metrics_parameters.go b/client/operations/put_metrics_parameters.go index 41644fd8..1cdf6004 100644 --- a/client/operations/put_metrics_parameters.go +++ b/client/operations/put_metrics_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutMetricsParams creates a new PutMetricsParams object -// with the default values initialized. +// NewPutMetricsParams creates a new PutMetricsParams 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 NewPutMetricsParams() *PutMetricsParams { - var () return &PutMetricsParams{ - timeout: cr.DefaultTimeout, } } // NewPutMetricsParamsWithTimeout creates a new PutMetricsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutMetricsParamsWithTimeout(timeout time.Duration) *PutMetricsParams { - var () return &PutMetricsParams{ - timeout: timeout, } } // NewPutMetricsParamsWithContext creates a new PutMetricsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutMetricsParamsWithContext(ctx context.Context) *PutMetricsParams { - var () return &PutMetricsParams{ - Context: ctx, } } // NewPutMetricsParamsWithHTTPClient creates a new PutMetricsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutMetricsParamsWithHTTPClient(client *http.Client) *PutMetricsParams { - var () return &PutMetricsParams{ HTTPClient: client, } } -/*PutMetricsParams contains all the parameters to send to the API endpoint -for the put metrics operation typically these are written to a http.Request +/* +PutMetricsParams contains all the parameters to send to the API endpoint + + for the put metrics operation. + + Typically these are written to a http.Request. */ type PutMetricsParams struct { - /*Body - Metrics system description + /* Body. + Metrics system description */ Body *models.Metrics @@ -87,6 +87,21 @@ type PutMetricsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMetricsParams) WithDefaults() *PutMetricsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMetricsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put metrics params func (o *PutMetricsParams) WithTimeout(timeout time.Duration) *PutMetricsParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_metrics_responses.go b/client/operations/put_metrics_responses.go index 8d1c92d8..e55f5eb7 100644 --- a/client/operations/put_metrics_responses.go +++ b/client/operations/put_metrics_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutMetricsReader is a Reader for the PutMetrics structure. @@ -35,7 +36,7 @@ type PutMetricsReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutMetricsNoContent() @@ -66,15 +67,50 @@ func NewPutMetricsNoContent() *PutMetricsNoContent { return &PutMetricsNoContent{} } -/*PutMetricsNoContent handles this case with default header values. +/* +PutMetricsNoContent describes a response with status code 204, with default header values. Metrics system created. */ type PutMetricsNoContent struct { } +// IsSuccess returns true when this put metrics no content response has a 2xx status code +func (o *PutMetricsNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put metrics no content response has a 3xx status code +func (o *PutMetricsNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put metrics no content response has a 4xx status code +func (o *PutMetricsNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put metrics no content response has a 5xx status code +func (o *PutMetricsNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put metrics no content response a status code equal to that given +func (o *PutMetricsNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put metrics no content response +func (o *PutMetricsNoContent) Code() int { + return 204 +} + func (o *PutMetricsNoContent) Error() string { - return fmt.Sprintf("[PUT /metrics][%d] putMetricsNoContent ", 204) + return fmt.Sprintf("[PUT /metrics][%d] putMetricsNoContent", 204) +} + +func (o *PutMetricsNoContent) String() string { + return fmt.Sprintf("[PUT /metrics][%d] putMetricsNoContent", 204) } func (o *PutMetricsNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutMetricsBadRequest() *PutMetricsBadRequest { return &PutMetricsBadRequest{} } -/*PutMetricsBadRequest handles this case with default header values. +/* +PutMetricsBadRequest describes a response with status code 400, with default header values. Metrics system cannot be initialized due to bad input request or metrics system already initialized. */ @@ -95,8 +132,44 @@ type PutMetricsBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put metrics bad request response has a 2xx status code +func (o *PutMetricsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put metrics bad request response has a 3xx status code +func (o *PutMetricsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put metrics bad request response has a 4xx status code +func (o *PutMetricsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put metrics bad request response has a 5xx status code +func (o *PutMetricsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put metrics bad request response a status code equal to that given +func (o *PutMetricsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put metrics bad request response +func (o *PutMetricsBadRequest) Code() int { + return 400 +} + func (o *PutMetricsBadRequest) Error() string { - return fmt.Sprintf("[PUT /metrics][%d] putMetricsBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /metrics][%d] putMetricsBadRequest %s", 400, payload) +} + +func (o *PutMetricsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /metrics][%d] putMetricsBadRequest %s", 400, payload) } func (o *PutMetricsBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutMetricsBadRequest) readResponse(response runtime.ClientResponse, con o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutMetricsDefault(code int) *PutMetricsDefault { } } -/*PutMetricsDefault handles this case with default header values. +/* +PutMetricsDefault describes a response with status code -1, with default header values. Internal server error. */ @@ -132,13 +206,44 @@ type PutMetricsDefault struct { Payload *models.Error } +// IsSuccess returns true when this put metrics default response has a 2xx status code +func (o *PutMetricsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put metrics default response has a 3xx status code +func (o *PutMetricsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put metrics default response has a 4xx status code +func (o *PutMetricsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put metrics default response has a 5xx status code +func (o *PutMetricsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put metrics default response a status code equal to that given +func (o *PutMetricsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put metrics default response func (o *PutMetricsDefault) Code() int { return o._statusCode } func (o *PutMetricsDefault) Error() string { - return fmt.Sprintf("[PUT /metrics][%d] putMetrics default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /metrics][%d] putMetrics default %s", o._statusCode, payload) +} + +func (o *PutMetricsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /metrics][%d] putMetrics default %s", o._statusCode, payload) } func (o *PutMetricsDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutMetricsDefault) readResponse(response runtime.ClientResponse, consum o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_mmds_config_parameters.go b/client/operations/put_mmds_config_parameters.go index 171fe01e..d11dec11 100644 --- a/client/operations/put_mmds_config_parameters.go +++ b/client/operations/put_mmds_config_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutMmdsConfigParams creates a new PutMmdsConfigParams object -// with the default values initialized. +// NewPutMmdsConfigParams creates a new PutMmdsConfigParams 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 NewPutMmdsConfigParams() *PutMmdsConfigParams { - var () return &PutMmdsConfigParams{ - timeout: cr.DefaultTimeout, } } // NewPutMmdsConfigParamsWithTimeout creates a new PutMmdsConfigParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutMmdsConfigParamsWithTimeout(timeout time.Duration) *PutMmdsConfigParams { - var () return &PutMmdsConfigParams{ - timeout: timeout, } } // NewPutMmdsConfigParamsWithContext creates a new PutMmdsConfigParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutMmdsConfigParamsWithContext(ctx context.Context) *PutMmdsConfigParams { - var () return &PutMmdsConfigParams{ - Context: ctx, } } // NewPutMmdsConfigParamsWithHTTPClient creates a new PutMmdsConfigParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutMmdsConfigParamsWithHTTPClient(client *http.Client) *PutMmdsConfigParams { - var () return &PutMmdsConfigParams{ HTTPClient: client, } } -/*PutMmdsConfigParams contains all the parameters to send to the API endpoint -for the put mmds config operation typically these are written to a http.Request +/* +PutMmdsConfigParams contains all the parameters to send to the API endpoint + + for the put mmds config operation. + + Typically these are written to a http.Request. */ type PutMmdsConfigParams struct { - /*Body - The MMDS configuration as JSON. + /* Body. + The MMDS configuration as JSON. */ Body *models.MmdsConfig @@ -87,6 +87,21 @@ type PutMmdsConfigParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put mmds config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMmdsConfigParams) WithDefaults() *PutMmdsConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put mmds config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMmdsConfigParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put mmds config params func (o *PutMmdsConfigParams) WithTimeout(timeout time.Duration) *PutMmdsConfigParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutMmdsConfigParams) WriteToRequest(r runtime.ClientRequest, reg strfmt return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_mmds_config_responses.go b/client/operations/put_mmds_config_responses.go index 8d1483f3..f34da721 100644 --- a/client/operations/put_mmds_config_responses.go +++ b/client/operations/put_mmds_config_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutMmdsConfigReader is a Reader for the PutMmdsConfig structure. @@ -35,7 +36,7 @@ type PutMmdsConfigReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutMmdsConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutMmdsConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutMmdsConfigNoContent() @@ -66,15 +67,50 @@ func NewPutMmdsConfigNoContent() *PutMmdsConfigNoContent { return &PutMmdsConfigNoContent{} } -/*PutMmdsConfigNoContent handles this case with default header values. +/* +PutMmdsConfigNoContent describes a response with status code 204, with default header values. MMDS configuration was created/updated. */ type PutMmdsConfigNoContent struct { } +// IsSuccess returns true when this put mmds config no content response has a 2xx status code +func (o *PutMmdsConfigNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put mmds config no content response has a 3xx status code +func (o *PutMmdsConfigNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put mmds config no content response has a 4xx status code +func (o *PutMmdsConfigNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put mmds config no content response has a 5xx status code +func (o *PutMmdsConfigNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put mmds config no content response a status code equal to that given +func (o *PutMmdsConfigNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put mmds config no content response +func (o *PutMmdsConfigNoContent) Code() int { + return 204 +} + func (o *PutMmdsConfigNoContent) Error() string { - return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigNoContent ", 204) + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigNoContent", 204) +} + +func (o *PutMmdsConfigNoContent) String() string { + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigNoContent", 204) } func (o *PutMmdsConfigNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutMmdsConfigBadRequest() *PutMmdsConfigBadRequest { return &PutMmdsConfigBadRequest{} } -/*PutMmdsConfigBadRequest handles this case with default header values. +/* +PutMmdsConfigBadRequest describes a response with status code 400, with default header values. MMDS configuration cannot be updated due to bad input. */ @@ -95,8 +132,44 @@ type PutMmdsConfigBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put mmds config bad request response has a 2xx status code +func (o *PutMmdsConfigBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put mmds config bad request response has a 3xx status code +func (o *PutMmdsConfigBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put mmds config bad request response has a 4xx status code +func (o *PutMmdsConfigBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put mmds config bad request response has a 5xx status code +func (o *PutMmdsConfigBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put mmds config bad request response a status code equal to that given +func (o *PutMmdsConfigBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put mmds config bad request response +func (o *PutMmdsConfigBadRequest) Code() int { + return 400 +} + func (o *PutMmdsConfigBadRequest) Error() string { - return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigBadRequest %s", 400, payload) +} + +func (o *PutMmdsConfigBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigBadRequest %s", 400, payload) } func (o *PutMmdsConfigBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutMmdsConfigBadRequest) readResponse(response runtime.ClientResponse, o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutMmdsConfigDefault(code int) *PutMmdsConfigDefault { } } -/*PutMmdsConfigDefault handles this case with default header values. +/* +PutMmdsConfigDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutMmdsConfigDefault struct { Payload *models.Error } +// IsSuccess returns true when this put mmds config default response has a 2xx status code +func (o *PutMmdsConfigDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put mmds config default response has a 3xx status code +func (o *PutMmdsConfigDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put mmds config default response has a 4xx status code +func (o *PutMmdsConfigDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put mmds config default response has a 5xx status code +func (o *PutMmdsConfigDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put mmds config default response a status code equal to that given +func (o *PutMmdsConfigDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put mmds config default response func (o *PutMmdsConfigDefault) Code() int { return o._statusCode } func (o *PutMmdsConfigDefault) Error() string { - return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfig default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfig default %s", o._statusCode, payload) +} + +func (o *PutMmdsConfigDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfig default %s", o._statusCode, payload) } func (o *PutMmdsConfigDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutMmdsConfigDefault) readResponse(response runtime.ClientResponse, con o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/client/operations/put_mmds_parameters.go b/client/operations/put_mmds_parameters.go index 2bac5a88..1794dee9 100644 --- a/client/operations/put_mmds_parameters.go +++ b/client/operations/put_mmds_parameters.go @@ -26,59 +26,59 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) -// NewPutMmdsParams creates a new PutMmdsParams object -// with the default values initialized. +// NewPutMmdsParams creates a new PutMmdsParams 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 NewPutMmdsParams() *PutMmdsParams { - var () return &PutMmdsParams{ - timeout: cr.DefaultTimeout, } } // NewPutMmdsParamsWithTimeout creates a new PutMmdsParams object -// with the default values initialized, and the ability to set a timeout on a request +// with the ability to set a timeout on a request. func NewPutMmdsParamsWithTimeout(timeout time.Duration) *PutMmdsParams { - var () return &PutMmdsParams{ - timeout: timeout, } } // NewPutMmdsParamsWithContext creates a new PutMmdsParams object -// with the default values initialized, and the ability to set a context for a request +// with the ability to set a context for a request. func NewPutMmdsParamsWithContext(ctx context.Context) *PutMmdsParams { - var () return &PutMmdsParams{ - Context: ctx, } } // NewPutMmdsParamsWithHTTPClient creates a new PutMmdsParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request +// with the ability to set a custom HTTPClient for a request. func NewPutMmdsParamsWithHTTPClient(client *http.Client) *PutMmdsParams { - var () return &PutMmdsParams{ HTTPClient: client, } } -/*PutMmdsParams contains all the parameters to send to the API endpoint -for the put mmds operation typically these are written to a http.Request +/* +PutMmdsParams contains all the parameters to send to the API endpoint + + for the put mmds operation. + + Typically these are written to a http.Request. */ type PutMmdsParams struct { - /*Body - The MMDS data store as JSON. + /* Body. + The MMDS data store as JSON. */ Body models.MmdsContentsObject @@ -87,6 +87,21 @@ type PutMmdsParams struct { HTTPClient *http.Client } +// WithDefaults hydrates default values in the put mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMmdsParams) WithDefaults() *PutMmdsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put mmds params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutMmdsParams) SetDefaults() { + // no default values defined for this parameter +} + // WithTimeout adds the timeout to the put mmds params func (o *PutMmdsParams) WithTimeout(timeout time.Duration) *PutMmdsParams { o.SetTimeout(timeout) @@ -138,7 +153,6 @@ func (o *PutMmdsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regis return err } var res []error - if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/operations/put_mmds_responses.go b/client/operations/put_mmds_responses.go index 2b204ca4..93e5f6e3 100644 --- a/client/operations/put_mmds_responses.go +++ b/client/operations/put_mmds_responses.go @@ -19,14 +19,15 @@ package operations // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + stderrors "errors" "fmt" "io" "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" - strfmt "github.com/go-openapi/strfmt" - - models "github.com/firecracker-microvm/firecracker-go-sdk/client/models" + "github.com/firecracker-microvm/firecracker-go-sdk/client/models" ) // PutMmdsReader is a Reader for the PutMmds structure. @@ -35,7 +36,7 @@ type PutMmdsReader struct { } // ReadResponse reads a server response into the received o. -func (o *PutMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { +func (o *PutMmdsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { switch response.Code() { case 204: result := NewPutMmdsNoContent() @@ -66,15 +67,50 @@ func NewPutMmdsNoContent() *PutMmdsNoContent { return &PutMmdsNoContent{} } -/*PutMmdsNoContent handles this case with default header values. +/* +PutMmdsNoContent describes a response with status code 204, with default header values. MMDS data store created/updated. */ type PutMmdsNoContent struct { } +// IsSuccess returns true when this put mmds no content response has a 2xx status code +func (o *PutMmdsNoContent) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put mmds no content response has a 3xx status code +func (o *PutMmdsNoContent) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put mmds no content response has a 4xx status code +func (o *PutMmdsNoContent) IsClientError() bool { + return false +} + +// IsServerError returns true when this put mmds no content response has a 5xx status code +func (o *PutMmdsNoContent) IsServerError() bool { + return false +} + +// IsCode returns true when this put mmds no content response a status code equal to that given +func (o *PutMmdsNoContent) IsCode(code int) bool { + return code == 204 +} + +// Code gets the status code for the put mmds no content response +func (o *PutMmdsNoContent) Code() int { + return 204 +} + func (o *PutMmdsNoContent) Error() string { - return fmt.Sprintf("[PUT /mmds][%d] putMmdsNoContent ", 204) + return fmt.Sprintf("[PUT /mmds][%d] putMmdsNoContent", 204) +} + +func (o *PutMmdsNoContent) String() string { + return fmt.Sprintf("[PUT /mmds][%d] putMmdsNoContent", 204) } func (o *PutMmdsNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -87,7 +123,8 @@ func NewPutMmdsBadRequest() *PutMmdsBadRequest { return &PutMmdsBadRequest{} } -/*PutMmdsBadRequest handles this case with default header values. +/* +PutMmdsBadRequest describes a response with status code 400, with default header values. MMDS data store cannot be created due to bad input. */ @@ -95,8 +132,44 @@ type PutMmdsBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this put mmds bad request response has a 2xx status code +func (o *PutMmdsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this put mmds bad request response has a 3xx status code +func (o *PutMmdsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put mmds bad request response has a 4xx status code +func (o *PutMmdsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this put mmds bad request response has a 5xx status code +func (o *PutMmdsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this put mmds bad request response a status code equal to that given +func (o *PutMmdsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the put mmds bad request response +func (o *PutMmdsBadRequest) Code() int { + return 400 +} + func (o *PutMmdsBadRequest) Error() string { - return fmt.Sprintf("[PUT /mmds][%d] putMmdsBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds][%d] putMmdsBadRequest %s", 400, payload) +} + +func (o *PutMmdsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds][%d] putMmdsBadRequest %s", 400, payload) } func (o *PutMmdsBadRequest) GetPayload() *models.Error { @@ -108,7 +181,7 @@ func (o *PutMmdsBadRequest) readResponse(response runtime.ClientResponse, consum o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } @@ -122,7 +195,8 @@ func NewPutMmdsDefault(code int) *PutMmdsDefault { } } -/*PutMmdsDefault handles this case with default header values. +/* +PutMmdsDefault describes a response with status code -1, with default header values. Internal server error */ @@ -132,13 +206,44 @@ type PutMmdsDefault struct { Payload *models.Error } +// IsSuccess returns true when this put mmds default response has a 2xx status code +func (o *PutMmdsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this put mmds default response has a 3xx status code +func (o *PutMmdsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this put mmds default response has a 4xx status code +func (o *PutMmdsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this put mmds default response has a 5xx status code +func (o *PutMmdsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this put mmds default response a status code equal to that given +func (o *PutMmdsDefault) IsCode(code int) bool { + return o._statusCode == code +} + // Code gets the status code for the put mmds default response func (o *PutMmdsDefault) Code() int { return o._statusCode } func (o *PutMmdsDefault) Error() string { - return fmt.Sprintf("[PUT /mmds][%d] putMmds default %+v", o._statusCode, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds][%d] putMmds default %s", o._statusCode, payload) +} + +func (o *PutMmdsDefault) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /mmds][%d] putMmds default %s", o._statusCode, payload) } func (o *PutMmdsDefault) GetPayload() *models.Error { @@ -150,7 +255,7 @@ func (o *PutMmdsDefault) readResponse(response runtime.ClientResponse, consumer o.Payload = new(models.Error) // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + if err := consumer.Consume(response.Body(), o.Payload); err != nil && !stderrors.Is(err, io.EOF) { return err } diff --git a/machine_test.go b/machine_test.go index 6b330d30..9c893d6e 100644 --- a/machine_test.go +++ b/machine_test.go @@ -573,7 +573,7 @@ func TestStartVMMOnce(t *testing.T) { }, } if cpu_temp, err := internal.SupportCPUTemplate(); cpu_temp && err == nil { - cfg.MachineCfg.CPUTemplate = models.CPUTemplate(models.CPUTemplateT2) + cfg.MachineCfg.CPUTemplate = models.NewCPUTemplate(models.CPUTemplateT2) } ctx := context.Background() cmd := VMCommandBuilder{}. diff --git a/swagger.go b/swagger.go index 72da092b..6835dfa9 100644 --- a/swagger.go +++ b/swagger.go @@ -16,8 +16,8 @@ // --skip-validation is used in the command-lines below to remove the network dependency that the swagger generator has // in attempting to validate that the email address specified in the yaml file is valid. -//go:generate docker run --add-host github.com:127.1.1.1 --rm --net=none -v $PWD:/work -w /work quay.io/goswagger/swagger:v0.20.1 generate model -f ./client/swagger.yaml -T ./templates --model-package=client/models --client-package=client --copyright-file=COPYRIGHT_HEADER --skip-validation -//go:generate docker run --add-host github.com:127.1.1.1 --rm --net=none -v $PWD:/work -w /work quay.io/goswagger/swagger:v0.20.1 generate client -f ./client/swagger.yaml -T ./templates --model-package=client/models --client-package=client --copyright-file=COPYRIGHT_HEADER --skip-validation -//go:generate docker run --add-host github.com:127.1.1.1 --rm --net=none -v $PWD:/work -w /work quay.io/goswagger/swagger:v0.20.1 generate client -f ./client/swagger.yaml -C ./go_swagger_layout.yaml -T ./templates --model-package=client/models --client-package=fctesting --copyright-file=COPYRIGHT_HEADER --skip-validation +//go:generate sh -c "docker run --add-host github.com:127.1.1.1 --rm -v $PWD:/work -w /work --entrypoint sh quay.io/goswagger/swagger:v0.33.1 -c 'apk add --no-cache go >/dev/null 2>&1 && swagger generate model -f ./client/swagger.yaml -T ./templates --model-package=client/models --copyright-file=COPYRIGHT_HEADER --skip-validation'" +//go:generate sh -c "docker run --add-host github.com:127.1.1.1 --rm -v $PWD:/work -w /work --entrypoint sh quay.io/goswagger/swagger:v0.33.1 -c 'apk add --no-cache go >/dev/null 2>&1 && swagger generate client -f ./client/swagger.yaml -T ./templates --model-package=client/models -c client --copyright-file=COPYRIGHT_HEADER --skip-validation -A Firecracker'" +//go:generate sh -c "docker run --add-host github.com:127.1.1.1 --rm -v $PWD:/work -w /work --entrypoint sh quay.io/goswagger/swagger:v0.33.1 -c 'apk add --no-cache go >/dev/null 2>&1 && swagger generate client -f ./client/swagger.yaml -C ./go_swagger_layout.yaml -T ./templates --model-package=client/models -c fctesting --copyright-file=COPYRIGHT_HEADER --skip-validation -A Firecracker'" package firecracker