github.com/kubearmor/cilium@v1.6.12/api/v1/models/status.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  // Status Status of an individual component
    19  // swagger:model Status
    20  type Status struct {
    21  
    22  	// Human readable status/error/warning message
    23  	Msg string `json:"msg,omitempty"`
    24  
    25  	// State the component is in
    26  	// Enum: [Ok Warning Failure Disabled]
    27  	State string `json:"state,omitempty"`
    28  }
    29  
    30  // Validate validates this status
    31  func (m *Status) Validate(formats strfmt.Registry) error {
    32  	var res []error
    33  
    34  	if err := m.validateState(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if len(res) > 0 {
    39  		return errors.CompositeValidationError(res...)
    40  	}
    41  	return nil
    42  }
    43  
    44  var statusTypeStatePropEnum []interface{}
    45  
    46  func init() {
    47  	var res []string
    48  	if err := json.Unmarshal([]byte(`["Ok","Warning","Failure","Disabled"]`), &res); err != nil {
    49  		panic(err)
    50  	}
    51  	for _, v := range res {
    52  		statusTypeStatePropEnum = append(statusTypeStatePropEnum, v)
    53  	}
    54  }
    55  
    56  const (
    57  
    58  	// StatusStateOk captures enum value "Ok"
    59  	StatusStateOk string = "Ok"
    60  
    61  	// StatusStateWarning captures enum value "Warning"
    62  	StatusStateWarning string = "Warning"
    63  
    64  	// StatusStateFailure captures enum value "Failure"
    65  	StatusStateFailure string = "Failure"
    66  
    67  	// StatusStateDisabled captures enum value "Disabled"
    68  	StatusStateDisabled string = "Disabled"
    69  )
    70  
    71  // prop value enum
    72  func (m *Status) validateStateEnum(path, location string, value string) error {
    73  	if err := validate.Enum(path, location, value, statusTypeStatePropEnum); err != nil {
    74  		return err
    75  	}
    76  	return nil
    77  }
    78  
    79  func (m *Status) validateState(formats strfmt.Registry) error {
    80  
    81  	if swag.IsZero(m.State) { // not required
    82  		return nil
    83  	}
    84  
    85  	// value enum
    86  	if err := m.validateStateEnum("state", "body", m.State); err != nil {
    87  		return err
    88  	}
    89  
    90  	return nil
    91  }
    92  
    93  // MarshalBinary interface implementation
    94  func (m *Status) MarshalBinary() ([]byte, error) {
    95  	if m == nil {
    96  		return nil, nil
    97  	}
    98  	return swag.WriteJSON(m)
    99  }
   100  
   101  // UnmarshalBinary interface implementation
   102  func (m *Status) UnmarshalBinary(b []byte) error {
   103  	var res Status
   104  	if err := swag.ReadJSON(b, &res); err != nil {
   105  		return err
   106  	}
   107  	*m = res
   108  	return nil
   109  }