/
endpoint_change_request.go
189 lines (142 loc) · 4.36 KB
/
endpoint_change_request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Code generated by go-swagger; DO NOT EDIT.
// Copyright Authors of Cilium
// SPDX-License-Identifier: Apache-2.0
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// EndpointChangeRequest Structure which contains the mutable elements of an Endpoint.
//
//
// swagger:model EndpointChangeRequest
type EndpointChangeRequest struct {
// addressing
Addressing *AddressPair `json:"addressing,omitempty"`
// ID assigned by container runtime
ContainerID string `json:"container-id,omitempty"`
// Name assigned to container
ContainerName string `json:"container-name,omitempty"`
// datapath configuration
DatapathConfiguration *EndpointDatapathConfiguration `json:"datapath-configuration,omitempty"`
// ID of datapath tail call map
DatapathMapID int64 `json:"datapath-map-id,omitempty"`
// Docker endpoint ID
DockerEndpointID string `json:"docker-endpoint-id,omitempty"`
// Docker network ID
DockerNetworkID string `json:"docker-network-id,omitempty"`
// MAC address
HostMac string `json:"host-mac,omitempty"`
// Local endpoint ID
ID int64 `json:"id,omitempty"`
// Index of network device
InterfaceIndex int64 `json:"interface-index,omitempty"`
// Name of network device
InterfaceName string `json:"interface-name,omitempty"`
// Kubernetes namespace name
K8sNamespace string `json:"k8s-namespace,omitempty"`
// Kubernetes pod name
K8sPodName string `json:"k8s-pod-name,omitempty"`
// Labels describing the identity
Labels Labels `json:"labels,omitempty"`
// MAC address
Mac string `json:"mac,omitempty"`
// Process ID of the workload belonging to this endpoint
Pid int64 `json:"pid,omitempty"`
// Whether policy enforcement is enabled or not
PolicyEnabled bool `json:"policy-enabled,omitempty"`
// Current state of endpoint
// Required: true
State EndpointState `json:"state"`
// Whether to build an endpoint synchronously
//
SyncBuildEndpoint bool `json:"sync-build-endpoint,omitempty"`
}
// Validate validates this endpoint change request
func (m *EndpointChangeRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateDatapathConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *EndpointChangeRequest) validateAddressing(formats strfmt.Registry) error {
if swag.IsZero(m.Addressing) { // not required
return nil
}
if m.Addressing != nil {
if err := m.Addressing.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("addressing")
}
return err
}
}
return nil
}
func (m *EndpointChangeRequest) validateDatapathConfiguration(formats strfmt.Registry) error {
if swag.IsZero(m.DatapathConfiguration) { // not required
return nil
}
if m.DatapathConfiguration != nil {
if err := m.DatapathConfiguration.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("datapath-configuration")
}
return err
}
}
return nil
}
func (m *EndpointChangeRequest) validateLabels(formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
}
if err := m.Labels.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
}
return err
}
return nil
}
func (m *EndpointChangeRequest) validateState(formats strfmt.Registry) error {
if err := m.State.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("state")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *EndpointChangeRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *EndpointChangeRequest) UnmarshalBinary(b []byte) error {
var res EndpointChangeRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}