bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/models/metrics.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 "strconv" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Metrics Metrics 18 // 19 // swagger:model Metrics 20 type Metrics struct { 21 22 // the local version of synsec/apil 23 // Required: true 24 ApilVersion *string `json:"apil_version"` 25 26 // bouncers 27 // Required: true 28 Bouncers []*MetricsSoftInfo `json:"bouncers"` 29 30 // machines 31 // Required: true 32 Machines []*MetricsSoftInfo `json:"machines"` 33 } 34 35 // Validate validates this metrics 36 func (m *Metrics) Validate(formats strfmt.Registry) error { 37 var res []error 38 39 if err := m.validateApilVersion(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if err := m.validateBouncers(formats); err != nil { 44 res = append(res, err) 45 } 46 47 if err := m.validateMachines(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if len(res) > 0 { 52 return errors.CompositeValidationError(res...) 53 } 54 return nil 55 } 56 57 func (m *Metrics) validateApilVersion(formats strfmt.Registry) error { 58 59 if err := validate.Required("apil_version", "body", m.ApilVersion); err != nil { 60 return err 61 } 62 63 return nil 64 } 65 66 func (m *Metrics) validateBouncers(formats strfmt.Registry) error { 67 68 if err := validate.Required("bouncers", "body", m.Bouncers); err != nil { 69 return err 70 } 71 72 for i := 0; i < len(m.Bouncers); i++ { 73 if swag.IsZero(m.Bouncers[i]) { // not required 74 continue 75 } 76 77 if m.Bouncers[i] != nil { 78 if err := m.Bouncers[i].Validate(formats); err != nil { 79 if ve, ok := err.(*errors.Validation); ok { 80 return ve.ValidateName("bouncers" + "." + strconv.Itoa(i)) 81 } 82 return err 83 } 84 } 85 86 } 87 88 return nil 89 } 90 91 func (m *Metrics) validateMachines(formats strfmt.Registry) error { 92 93 if err := validate.Required("machines", "body", m.Machines); err != nil { 94 return err 95 } 96 97 for i := 0; i < len(m.Machines); i++ { 98 if swag.IsZero(m.Machines[i]) { // not required 99 continue 100 } 101 102 if m.Machines[i] != nil { 103 if err := m.Machines[i].Validate(formats); err != nil { 104 if ve, ok := err.(*errors.Validation); ok { 105 return ve.ValidateName("machines" + "." + strconv.Itoa(i)) 106 } 107 return err 108 } 109 } 110 111 } 112 113 return nil 114 } 115 116 // MarshalBinary interface implementation 117 func (m *Metrics) MarshalBinary() ([]byte, error) { 118 if m == nil { 119 return nil, nil 120 } 121 return swag.WriteJSON(m) 122 } 123 124 // UnmarshalBinary interface implementation 125 func (m *Metrics) UnmarshalBinary(b []byte) error { 126 var res Metrics 127 if err := swag.ReadJSON(b, &res); err != nil { 128 return err 129 } 130 *m = res 131 return nil 132 }