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
/
proxy_config_request.go
188 lines (139 loc) · 4.53 KB
/
proxy_config_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
// 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"
)
// ProxyConfigRequest proxy config request
// swagger:model ProxyConfigRequest
type ProxyConfigRequest struct {
// description of the resource
Description string `json:"description,omitempty"`
// Name of the proxy configuration resource
// Required: true
// Max Length: 100
// Min Length: 4
// Pattern: (^[a-z][-a-z0-9]*[a-z0-9]$)
Name *string `json:"name"`
// Password to use for basic authentication
Password string `json:"password,omitempty"`
// determines the protocol (http or https)
// Required: true
// Pattern: ^http(s)?$
Protocol *string `json:"protocol"`
// host or IP address of proxy server
// Required: true
// Max Length: 255
// Min Length: 1
// Pattern: (^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$)
ServerHost *string `json:"serverHost"`
// port of proxy server (typically: 3128 or 8080)
// Required: true
// Maximum: 65535
// Minimum: 1
ServerPort *int32 `json:"serverPort"`
// Username to use for basic authentication
UserName string `json:"userName,omitempty"`
}
/* polymorph ProxyConfigRequest description false */
/* polymorph ProxyConfigRequest name false */
/* polymorph ProxyConfigRequest password false */
/* polymorph ProxyConfigRequest protocol false */
/* polymorph ProxyConfigRequest serverHost false */
/* polymorph ProxyConfigRequest serverPort false */
/* polymorph ProxyConfigRequest userName false */
// Validate validates this proxy config request
func (m *ProxyConfigRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateName(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateProtocol(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateServerHost(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateServerPort(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *ProxyConfigRequest) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
if err := validate.MinLength("name", "body", string(*m.Name), 4); err != nil {
return err
}
if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil {
return err
}
if err := validate.Pattern("name", "body", string(*m.Name), `(^[a-z][-a-z0-9]*[a-z0-9]$)`); err != nil {
return err
}
return nil
}
func (m *ProxyConfigRequest) validateProtocol(formats strfmt.Registry) error {
if err := validate.Required("protocol", "body", m.Protocol); err != nil {
return err
}
if err := validate.Pattern("protocol", "body", string(*m.Protocol), `^http(s)?$`); err != nil {
return err
}
return nil
}
func (m *ProxyConfigRequest) validateServerHost(formats strfmt.Registry) error {
if err := validate.Required("serverHost", "body", m.ServerHost); err != nil {
return err
}
if err := validate.MinLength("serverHost", "body", string(*m.ServerHost), 1); err != nil {
return err
}
if err := validate.MaxLength("serverHost", "body", string(*m.ServerHost), 255); err != nil {
return err
}
if err := validate.Pattern("serverHost", "body", string(*m.ServerHost), `(^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$)`); err != nil {
return err
}
return nil
}
func (m *ProxyConfigRequest) validateServerPort(formats strfmt.Registry) error {
if err := validate.Required("serverPort", "body", m.ServerPort); err != nil {
return err
}
if err := validate.MinimumInt("serverPort", "body", int64(*m.ServerPort), 1, false); err != nil {
return err
}
if err := validate.MaximumInt("serverPort", "body", int64(*m.ServerPort), 65535, false); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *ProxyConfigRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *ProxyConfigRequest) UnmarshalBinary(b []byte) error {
var res ProxyConfigRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}