github.com/cilium/cilium@v1.16.2/api/v1/models/identity_endpoints.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 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/strfmt" 16 "github.com/go-openapi/swag" 17 ) 18 19 // IdentityEndpoints Security identities owned by endpoints on the local node 20 // 21 // swagger:model IdentityEndpoints 22 type IdentityEndpoints struct { 23 24 // Security identity 25 Identity *Identity `json:"identity,omitempty"` 26 27 // number of endpoints consuming this identity locally (should always be > 0) 28 RefCount int64 `json:"refCount,omitempty"` 29 } 30 31 // Validate validates this identity endpoints 32 func (m *IdentityEndpoints) Validate(formats strfmt.Registry) error { 33 var res []error 34 35 if err := m.validateIdentity(formats); err != nil { 36 res = append(res, err) 37 } 38 39 if len(res) > 0 { 40 return errors.CompositeValidationError(res...) 41 } 42 return nil 43 } 44 45 func (m *IdentityEndpoints) validateIdentity(formats strfmt.Registry) error { 46 if swag.IsZero(m.Identity) { // not required 47 return nil 48 } 49 50 if m.Identity != nil { 51 if err := m.Identity.Validate(formats); err != nil { 52 if ve, ok := err.(*errors.Validation); ok { 53 return ve.ValidateName("identity") 54 } else if ce, ok := err.(*errors.CompositeError); ok { 55 return ce.ValidateName("identity") 56 } 57 return err 58 } 59 } 60 61 return nil 62 } 63 64 // ContextValidate validate this identity endpoints based on the context it is used 65 func (m *IdentityEndpoints) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 66 var res []error 67 68 if err := m.contextValidateIdentity(ctx, formats); err != nil { 69 res = append(res, err) 70 } 71 72 if len(res) > 0 { 73 return errors.CompositeValidationError(res...) 74 } 75 return nil 76 } 77 78 func (m *IdentityEndpoints) contextValidateIdentity(ctx context.Context, formats strfmt.Registry) error { 79 80 if m.Identity != nil { 81 82 if swag.IsZero(m.Identity) { // not required 83 return nil 84 } 85 86 if err := m.Identity.ContextValidate(ctx, formats); err != nil { 87 if ve, ok := err.(*errors.Validation); ok { 88 return ve.ValidateName("identity") 89 } else if ce, ok := err.(*errors.CompositeError); ok { 90 return ce.ValidateName("identity") 91 } 92 return err 93 } 94 } 95 96 return nil 97 } 98 99 // MarshalBinary interface implementation 100 func (m *IdentityEndpoints) MarshalBinary() ([]byte, error) { 101 if m == nil { 102 return nil, nil 103 } 104 return swag.WriteJSON(m) 105 } 106 107 // UnmarshalBinary interface implementation 108 func (m *IdentityEndpoints) UnmarshalBinary(b []byte) error { 109 var res IdentityEndpoints 110 if err := swag.ReadJSON(b, &res); err != nil { 111 return err 112 } 113 *m = res 114 return nil 115 }