github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/instance_action_info.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  	"encoding/json"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // InstanceActionInfo Variant wrapper containing the real action.
    19  // swagger:model InstanceActionInfo
    20  type InstanceActionInfo struct {
    21  
    22  	// Enumeration indicating what type of action is contained in the payload
    23  	// Required: true
    24  	// Enum: [FlushMetrics InstanceStart SendCtrlAltDel]
    25  	ActionType *string `json:"action_type"`
    26  }
    27  
    28  // Validate validates this instance action info
    29  func (m *InstanceActionInfo) Validate(formats strfmt.Registry) error {
    30  	var res []error
    31  
    32  	if err := m.validateActionType(formats); err != nil {
    33  		res = append(res, err)
    34  	}
    35  
    36  	if len(res) > 0 {
    37  		return errors.CompositeValidationError(res...)
    38  	}
    39  	return nil
    40  }
    41  
    42  var instanceActionInfoTypeActionTypePropEnum []interface{}
    43  
    44  func init() {
    45  	var res []string
    46  	if err := json.Unmarshal([]byte(`["FlushMetrics","InstanceStart","SendCtrlAltDel"]`), &res); err != nil {
    47  		panic(err)
    48  	}
    49  	for _, v := range res {
    50  		instanceActionInfoTypeActionTypePropEnum = append(instanceActionInfoTypeActionTypePropEnum, v)
    51  	}
    52  }
    53  
    54  const (
    55  
    56  	// InstanceActionInfoActionTypeFlushMetrics captures enum value "FlushMetrics"
    57  	InstanceActionInfoActionTypeFlushMetrics string = "FlushMetrics"
    58  
    59  	// InstanceActionInfoActionTypeInstanceStart captures enum value "InstanceStart"
    60  	InstanceActionInfoActionTypeInstanceStart string = "InstanceStart"
    61  
    62  	// InstanceActionInfoActionTypeSendCtrlAltDel captures enum value "SendCtrlAltDel"
    63  	InstanceActionInfoActionTypeSendCtrlAltDel string = "SendCtrlAltDel"
    64  )
    65  
    66  // prop value enum
    67  func (m *InstanceActionInfo) validateActionTypeEnum(path, location string, value string) error {
    68  	if err := validate.Enum(path, location, value, instanceActionInfoTypeActionTypePropEnum); err != nil {
    69  		return err
    70  	}
    71  	return nil
    72  }
    73  
    74  func (m *InstanceActionInfo) validateActionType(formats strfmt.Registry) error {
    75  
    76  	if err := validate.Required("action_type", "body", m.ActionType); err != nil {
    77  		return err
    78  	}
    79  
    80  	// value enum
    81  	if err := m.validateActionTypeEnum("action_type", "body", *m.ActionType); err != nil {
    82  		return err
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  // MarshalBinary interface implementation
    89  func (m *InstanceActionInfo) MarshalBinary() ([]byte, error) {
    90  	if m == nil {
    91  		return nil, nil
    92  	}
    93  	return swag.WriteJSON(m)
    94  }
    95  
    96  // UnmarshalBinary interface implementation
    97  func (m *InstanceActionInfo) UnmarshalBinary(b []byte) error {
    98  	var res InstanceActionInfo
    99  	if err := swag.ReadJSON(b, &res); err != nil {
   100  		return err
   101  	}
   102  	*m = res
   103  	return nil
   104  }