github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/drive.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // Drive drive
    17  // swagger:model Drive
    18  type Drive struct {
    19  
    20  	// drive id
    21  	// Required: true
    22  	DriveID *string `json:"drive_id"`
    23  
    24  	// is read only
    25  	// Required: true
    26  	IsReadOnly *bool `json:"is_read_only"`
    27  
    28  	// is root device
    29  	// Required: true
    30  	IsRootDevice *bool `json:"is_root_device"`
    31  
    32  	// Represents the unique id of the boot partition of this device. It is optional and it will be taken into account only if the is_root_device field is true.
    33  	Partuuid string `json:"partuuid,omitempty"`
    34  
    35  	// Host level path for the guest drive
    36  	// Required: true
    37  	PathOnHost *string `json:"path_on_host"`
    38  
    39  	// rate limiter
    40  	RateLimiter *RateLimiter `json:"rate_limiter,omitempty"`
    41  }
    42  
    43  // Validate validates this drive
    44  func (m *Drive) Validate(formats strfmt.Registry) error {
    45  	var res []error
    46  
    47  	if err := m.validateDriveID(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validateIsReadOnly(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if err := m.validateIsRootDevice(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validatePathOnHost(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if err := m.validateRateLimiter(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if len(res) > 0 {
    68  		return errors.CompositeValidationError(res...)
    69  	}
    70  	return nil
    71  }
    72  
    73  func (m *Drive) validateDriveID(formats strfmt.Registry) error {
    74  
    75  	if err := validate.Required("drive_id", "body", m.DriveID); err != nil {
    76  		return err
    77  	}
    78  
    79  	return nil
    80  }
    81  
    82  func (m *Drive) validateIsReadOnly(formats strfmt.Registry) error {
    83  
    84  	if err := validate.Required("is_read_only", "body", m.IsReadOnly); err != nil {
    85  		return err
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  func (m *Drive) validateIsRootDevice(formats strfmt.Registry) error {
    92  
    93  	if err := validate.Required("is_root_device", "body", m.IsRootDevice); err != nil {
    94  		return err
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  func (m *Drive) validatePathOnHost(formats strfmt.Registry) error {
   101  
   102  	if err := validate.Required("path_on_host", "body", m.PathOnHost); err != nil {
   103  		return err
   104  	}
   105  
   106  	return nil
   107  }
   108  
   109  func (m *Drive) validateRateLimiter(formats strfmt.Registry) error {
   110  
   111  	if swag.IsZero(m.RateLimiter) { // not required
   112  		return nil
   113  	}
   114  
   115  	if m.RateLimiter != nil {
   116  		if err := m.RateLimiter.Validate(formats); err != nil {
   117  			if ve, ok := err.(*errors.Validation); ok {
   118  				return ve.ValidateName("rate_limiter")
   119  			}
   120  			return err
   121  		}
   122  	}
   123  
   124  	return nil
   125  }
   126  
   127  // MarshalBinary interface implementation
   128  func (m *Drive) MarshalBinary() ([]byte, error) {
   129  	if m == nil {
   130  		return nil, nil
   131  	}
   132  	return swag.WriteJSON(m)
   133  }
   134  
   135  // UnmarshalBinary interface implementation
   136  func (m *Drive) UnmarshalBinary(b []byte) error {
   137  	var res Drive
   138  	if err := swag.ReadJSON(b, &res); err != nil {
   139  		return err
   140  	}
   141  	*m = res
   142  	return nil
   143  }