github.com/kubearmor/cilium@v1.6.12/api/v1/models/endpoint_policy.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 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 ) 14 15 // EndpointPolicy Policy information of an endpoint 16 // swagger:model EndpointPolicy 17 type EndpointPolicy struct { 18 19 // List of identities to which this endpoint is allowed to communicate 20 // 21 AllowedEgressIdentities []int64 `json:"allowed-egress-identities"` 22 23 // List of identities allowed to communicate to this endpoint 24 // 25 AllowedIngressIdentities []int64 `json:"allowed-ingress-identities"` 26 27 // Build number of calculated policy in use 28 Build int64 `json:"build,omitempty"` 29 30 // cidr policy 31 CidrPolicy *CIDRPolicy `json:"cidr-policy,omitempty"` 32 33 // Own identity of endpoint 34 ID int64 `json:"id,omitempty"` 35 36 // l4 37 L4 *L4Policy `json:"l4,omitempty"` 38 39 // Whether policy enforcement is enabled (ingress, egress, both or none) 40 PolicyEnabled EndpointPolicyEnabled `json:"policy-enabled,omitempty"` 41 42 // The agent-local policy revision 43 PolicyRevision int64 `json:"policy-revision,omitempty"` 44 } 45 46 // Validate validates this endpoint policy 47 func (m *EndpointPolicy) Validate(formats strfmt.Registry) error { 48 var res []error 49 50 if err := m.validateCidrPolicy(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateL4(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if err := m.validatePolicyEnabled(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if len(res) > 0 { 63 return errors.CompositeValidationError(res...) 64 } 65 return nil 66 } 67 68 func (m *EndpointPolicy) validateCidrPolicy(formats strfmt.Registry) error { 69 70 if swag.IsZero(m.CidrPolicy) { // not required 71 return nil 72 } 73 74 if m.CidrPolicy != nil { 75 if err := m.CidrPolicy.Validate(formats); err != nil { 76 if ve, ok := err.(*errors.Validation); ok { 77 return ve.ValidateName("cidr-policy") 78 } 79 return err 80 } 81 } 82 83 return nil 84 } 85 86 func (m *EndpointPolicy) validateL4(formats strfmt.Registry) error { 87 88 if swag.IsZero(m.L4) { // not required 89 return nil 90 } 91 92 if m.L4 != nil { 93 if err := m.L4.Validate(formats); err != nil { 94 if ve, ok := err.(*errors.Validation); ok { 95 return ve.ValidateName("l4") 96 } 97 return err 98 } 99 } 100 101 return nil 102 } 103 104 func (m *EndpointPolicy) validatePolicyEnabled(formats strfmt.Registry) error { 105 106 if swag.IsZero(m.PolicyEnabled) { // not required 107 return nil 108 } 109 110 if err := m.PolicyEnabled.Validate(formats); err != nil { 111 if ve, ok := err.(*errors.Validation); ok { 112 return ve.ValidateName("policy-enabled") 113 } 114 return err 115 } 116 117 return nil 118 } 119 120 // MarshalBinary interface implementation 121 func (m *EndpointPolicy) MarshalBinary() ([]byte, error) { 122 if m == nil { 123 return nil, nil 124 } 125 return swag.WriteJSON(m) 126 } 127 128 // UnmarshalBinary interface implementation 129 func (m *EndpointPolicy) UnmarshalBinary(b []byte) error { 130 var res EndpointPolicy 131 if err := swag.ReadJSON(b, &res); err != nil { 132 return err 133 } 134 *m = res 135 return nil 136 }