github.com/cilium/cilium@v1.16.2/api/v1/models/status.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package models 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "context" 13 "encoding/json" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 "github.com/go-openapi/validate" 19 ) 20 21 // Status Status of an individual component 22 // 23 // swagger:model Status 24 type Status struct { 25 26 // Human readable status/error/warning message 27 Msg string `json:"msg,omitempty"` 28 29 // State the component is in 30 // Enum: [Ok Warning Failure Disabled] 31 State string `json:"state,omitempty"` 32 } 33 34 // Validate validates this status 35 func (m *Status) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateState(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if len(res) > 0 { 43 return errors.CompositeValidationError(res...) 44 } 45 return nil 46 } 47 48 var statusTypeStatePropEnum []interface{} 49 50 func init() { 51 var res []string 52 if err := json.Unmarshal([]byte(`["Ok","Warning","Failure","Disabled"]`), &res); err != nil { 53 panic(err) 54 } 55 for _, v := range res { 56 statusTypeStatePropEnum = append(statusTypeStatePropEnum, v) 57 } 58 } 59 60 const ( 61 62 // StatusStateOk captures enum value "Ok" 63 StatusStateOk string = "Ok" 64 65 // StatusStateWarning captures enum value "Warning" 66 StatusStateWarning string = "Warning" 67 68 // StatusStateFailure captures enum value "Failure" 69 StatusStateFailure string = "Failure" 70 71 // StatusStateDisabled captures enum value "Disabled" 72 StatusStateDisabled string = "Disabled" 73 ) 74 75 // prop value enum 76 func (m *Status) validateStateEnum(path, location string, value string) error { 77 if err := validate.EnumCase(path, location, value, statusTypeStatePropEnum, true); err != nil { 78 return err 79 } 80 return nil 81 } 82 83 func (m *Status) validateState(formats strfmt.Registry) error { 84 if swag.IsZero(m.State) { // not required 85 return nil 86 } 87 88 // value enum 89 if err := m.validateStateEnum("state", "body", m.State); err != nil { 90 return err 91 } 92 93 return nil 94 } 95 96 // ContextValidate validates this status based on context it is used 97 func (m *Status) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 98 return nil 99 } 100 101 // MarshalBinary interface implementation 102 func (m *Status) MarshalBinary() ([]byte, error) { 103 if m == nil { 104 return nil, nil 105 } 106 return swag.WriteJSON(m) 107 } 108 109 // UnmarshalBinary interface implementation 110 func (m *Status) UnmarshalBinary(b []byte) error { 111 var res Status 112 if err := swag.ReadJSON(b, &res); err != nil { 113 return err 114 } 115 *m = res 116 return nil 117 }