/
flow_match_swaggergen.go
188 lines (145 loc) · 4.55 KB
/
flow_match_swaggergen.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
/*
* Copyright 2020 The Magma Authors.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Code generated by go-swagger; DO NOT EDIT.
package types
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// FlowMatch flow match
// swagger:model flow_match
type FlowMatch struct {
// direction
// Enum: [UPLINK DOWNLINK]
Direction string `json:"direction,omitempty"`
// ip proto
// Enum: [IPPROTO_IP IPPROTO_TCP IPPROTO_UDP IPPROTO_ICMP]
IPProto *string `json:"ip_proto,omitempty"`
// ipv4 dst
IPV4Dst string `json:"ipv4_dst,omitempty" magma_alt_name:"Ipv4Dst"`
// ipv4 src
IPV4Src string `json:"ipv4_src,omitempty" magma_alt_name:"Ipv4Src"`
// tcp dst
TCPDst uint32 `json:"tcp_dst,omitempty" magma_alt_name:"TcpDst"`
// tcp src
TCPSrc uint32 `json:"tcp_src,omitempty" magma_alt_name:"TcpSrc"`
// udp dst
UDPDst uint32 `json:"udp_dst,omitempty" magma_alt_name:"UdpDst"`
// udp src
UDPSrc uint32 `json:"udp_src,omitempty" magma_alt_name:"UdpSrc"`
}
// Validate validates this flow match
func (m *FlowMatch) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDirection(formats); err != nil {
res = append(res, err)
}
if err := m.validateIPProto(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var flowMatchTypeDirectionPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["UPLINK","DOWNLINK"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
flowMatchTypeDirectionPropEnum = append(flowMatchTypeDirectionPropEnum, v)
}
}
const (
// FlowMatchDirectionUPLINK captures enum value "UPLINK"
FlowMatchDirectionUPLINK string = "UPLINK"
// FlowMatchDirectionDOWNLINK captures enum value "DOWNLINK"
FlowMatchDirectionDOWNLINK string = "DOWNLINK"
)
// prop value enum
func (m *FlowMatch) validateDirectionEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, flowMatchTypeDirectionPropEnum); err != nil {
return err
}
return nil
}
func (m *FlowMatch) validateDirection(formats strfmt.Registry) error {
if swag.IsZero(m.Direction) { // not required
return nil
}
// value enum
if err := m.validateDirectionEnum("direction", "body", m.Direction); err != nil {
return err
}
return nil
}
var flowMatchTypeIPProtoPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["IPPROTO_IP","IPPROTO_TCP","IPPROTO_UDP","IPPROTO_ICMP"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
flowMatchTypeIPProtoPropEnum = append(flowMatchTypeIPProtoPropEnum, v)
}
}
const (
// FlowMatchIPProtoIPPROTOIP captures enum value "IPPROTO_IP"
FlowMatchIPProtoIPPROTOIP string = "IPPROTO_IP"
// FlowMatchIPProtoIPPROTOTCP captures enum value "IPPROTO_TCP"
FlowMatchIPProtoIPPROTOTCP string = "IPPROTO_TCP"
// FlowMatchIPProtoIPPROTOUDP captures enum value "IPPROTO_UDP"
FlowMatchIPProtoIPPROTOUDP string = "IPPROTO_UDP"
// FlowMatchIPProtoIPPROTOICMP captures enum value "IPPROTO_ICMP"
FlowMatchIPProtoIPPROTOICMP string = "IPPROTO_ICMP"
)
// prop value enum
func (m *FlowMatch) validateIPProtoEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, flowMatchTypeIPProtoPropEnum); err != nil {
return err
}
return nil
}
func (m *FlowMatch) validateIPProto(formats strfmt.Registry) error {
if swag.IsZero(m.IPProto) { // not required
return nil
}
// value enum
if err := m.validateIPProtoEnum("ip_proto", "body", *m.IPProto); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *FlowMatch) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *FlowMatch) UnmarshalBinary(b []byte) error {
var res FlowMatch
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}