This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
security_rule_request.go
123 lines (91 loc) · 3.07 KB
/
security_rule_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
// Code generated by go-swagger; DO NOT EDIT.
package models_cloudbreak
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SecurityRuleRequest security rule request
// swagger:model SecurityRuleRequest
type SecurityRuleRequest struct {
// flag for making the rule modifiable
Modifiable *bool `json:"modifiable,omitempty"`
// comma separated list of accessible ports
// Required: true
// Pattern: ^[1-9][0-9]{0,4}(-[1-9][0-9]{0,4}){0,1}(,[1-9][0-9]{0,4}(-[1-9][0-9]{0,4}){0,1})*$
Ports *string `json:"ports"`
// protocol of the rule
// Required: true
Protocol *string `json:"protocol"`
// definition of allowed subnet in CIDR format
// Required: true
// Pattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Subnet *string `json:"subnet"`
}
/* polymorph SecurityRuleRequest modifiable false */
/* polymorph SecurityRuleRequest ports false */
/* polymorph SecurityRuleRequest protocol false */
/* polymorph SecurityRuleRequest subnet false */
// Validate validates this security rule request
func (m *SecurityRuleRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validatePorts(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateProtocol(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateSubnet(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SecurityRuleRequest) validatePorts(formats strfmt.Registry) error {
if err := validate.Required("ports", "body", m.Ports); err != nil {
return err
}
if err := validate.Pattern("ports", "body", string(*m.Ports), `^[1-9][0-9]{0,4}(-[1-9][0-9]{0,4}){0,1}(,[1-9][0-9]{0,4}(-[1-9][0-9]{0,4}){0,1})*$`); err != nil {
return err
}
return nil
}
func (m *SecurityRuleRequest) validateProtocol(formats strfmt.Registry) error {
if err := validate.Required("protocol", "body", m.Protocol); err != nil {
return err
}
return nil
}
func (m *SecurityRuleRequest) validateSubnet(formats strfmt.Registry) error {
if err := validate.Required("subnet", "body", m.Subnet); err != nil {
return err
}
if err := validate.Pattern("subnet", "body", string(*m.Subnet), `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$`); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *SecurityRuleRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SecurityRuleRequest) UnmarshalBinary(b []byte) error {
var res SecurityRuleRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}