github.com/kubearmor/cilium@v1.6.12/api/v1/models/endpoint_status_change.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  // EndpointStatusChange Indication of a change of status
    19  // swagger:model EndpointStatusChange
    20  type EndpointStatusChange struct {
    21  
    22  	// Code indicate type of status change
    23  	// Enum: [ok failed]
    24  	Code string `json:"code,omitempty"`
    25  
    26  	// Status message
    27  	Message string `json:"message,omitempty"`
    28  
    29  	// state
    30  	State EndpointState `json:"state,omitempty"`
    31  
    32  	// Timestamp when status change occurred
    33  	Timestamp string `json:"timestamp,omitempty"`
    34  }
    35  
    36  // Validate validates this endpoint status change
    37  func (m *EndpointStatusChange) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateCode(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if err := m.validateState(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if len(res) > 0 {
    49  		return errors.CompositeValidationError(res...)
    50  	}
    51  	return nil
    52  }
    53  
    54  var endpointStatusChangeTypeCodePropEnum []interface{}
    55  
    56  func init() {
    57  	var res []string
    58  	if err := json.Unmarshal([]byte(`["ok","failed"]`), &res); err != nil {
    59  		panic(err)
    60  	}
    61  	for _, v := range res {
    62  		endpointStatusChangeTypeCodePropEnum = append(endpointStatusChangeTypeCodePropEnum, v)
    63  	}
    64  }
    65  
    66  const (
    67  
    68  	// EndpointStatusChangeCodeOk captures enum value "ok"
    69  	EndpointStatusChangeCodeOk string = "ok"
    70  
    71  	// EndpointStatusChangeCodeFailed captures enum value "failed"
    72  	EndpointStatusChangeCodeFailed string = "failed"
    73  )
    74  
    75  // prop value enum
    76  func (m *EndpointStatusChange) validateCodeEnum(path, location string, value string) error {
    77  	if err := validate.Enum(path, location, value, endpointStatusChangeTypeCodePropEnum); err != nil {
    78  		return err
    79  	}
    80  	return nil
    81  }
    82  
    83  func (m *EndpointStatusChange) validateCode(formats strfmt.Registry) error {
    84  
    85  	if swag.IsZero(m.Code) { // not required
    86  		return nil
    87  	}
    88  
    89  	// value enum
    90  	if err := m.validateCodeEnum("code", "body", m.Code); err != nil {
    91  		return err
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  func (m *EndpointStatusChange) validateState(formats strfmt.Registry) error {
    98  
    99  	if swag.IsZero(m.State) { // not required
   100  		return nil
   101  	}
   102  
   103  	if err := m.State.Validate(formats); err != nil {
   104  		if ve, ok := err.(*errors.Validation); ok {
   105  			return ve.ValidateName("state")
   106  		}
   107  		return err
   108  	}
   109  
   110  	return nil
   111  }
   112  
   113  // MarshalBinary interface implementation
   114  func (m *EndpointStatusChange) MarshalBinary() ([]byte, error) {
   115  	if m == nil {
   116  		return nil, nil
   117  	}
   118  	return swag.WriteJSON(m)
   119  }
   120  
   121  // UnmarshalBinary interface implementation
   122  func (m *EndpointStatusChange) UnmarshalBinary(b []byte) error {
   123  	var res EndpointStatusChange
   124  	if err := swag.ReadJSON(b, &res); err != nil {
   125  		return err
   126  	}
   127  	*m = res
   128  	return nil
   129  }