/
kubernetes_credentials.go
216 lines (170 loc) · 7.1 KB
/
kubernetes_credentials.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// Code generated by go-swagger; DO NOT EDIT.
package dynatrace
// 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"
"github.com/go-openapi/errors"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// KubernetesCredentials Configuration for specific Kubernetes credentials.
// swagger:model KubernetesCredentials
type KubernetesCredentials struct {
// The monitoring is enabled (`true`) or disabled (`false`) for given credentials configuration.
//
// If not set on creation, the `true` value is used.
//
// If the field is omitted during an update, the old value is used.
Active bool `json:"active,omitempty"`
// The service account bearer token for the Kubernetes API server.
//
// Submit your token on creation or update of the configuration. For security reasons, GET requests return this field as `null`.
//
// If the field is omitted during an update, the old value is used.
AuthToken string `json:"authToken,omitempty"`
// The status of the configured endpoint.
//
// ASSIGNED: The credentials are assigned to an ActiveGate which is responsible for processing.
// UNASSIGNED: The credentials are not yet assigned to an ActiveGate so there is currently no processing.
// DISABLED: The credentials have been disabled by the user.
// FASTCHECK_AUTH_ERROR: The credentials are invalid.
// FASTCHECK_TLS_ERROR: The endpoint TLS certificate is invalid.
// FASTCHECK_NO_RESPONSE: The endpoint did not return a result until the timeout was reached.
// FASTCHECK_INVALID_ENDPOINT: The endpoint URL was invalid.
// FASTCHECK_AUTH_LOCKED: The credentials seem to be locked.
// UNKNOWN: An unknown error occured.
//
// Read Only: true
// Enum: [ASSIGNED DISABLED FASTCHECK_AUTH_ERROR FASTCHECK_AUTH_LOCKED FASTCHECK_INVALID_ENDPOINT FASTCHECK_NO_RESPONSE FASTCHECK_TLS_ERROR UNASSIGNED UNKNOWN]
EndpointStatus string `json:"endpointStatus,omitempty"`
// The detailed status info of the configured endpoint.
// Read Only: true
EndpointStatusInfo string `json:"endpointStatusInfo,omitempty"`
// The URL of the Kubernetes API server.
//
// It must be unique within a Dynatrace environment.
//
// The URL must valid according to RFC 2396. Leading or trailing whitespaces are not allowed.
EndpointURL string `json:"endpointUrl,omitempty"`
// The ID of the given credentials configuration.
// Read Only: true
ID string `json:"id,omitempty"`
// The name of the Kubernetes credentials configuration.
//
// Allowed characters are letters, numbers, whitespaces, and the following characters: `.+-_`. Leading or trailing whitespace is not allowed.
// Required: true
// Min Length: 1
// Pattern: ^([a-zA-Z0-9_ +-.]*)$
Label *string `json:"label"`
// Metadata of the given credentials configuration which is useful for debugging.
// Read Only: true
Metadata *ConfigurationMetadata `json:"metadata,omitempty"`
}
// Validate validates this kubernetes credentials
func (m *KubernetesCredentials) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndpointStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabel(formats); err != nil {
res = append(res, err)
}
if err := m.validateMetadata(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var kubernetesCredentialsTypeEndpointStatusPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["ASSIGNED","DISABLED","FASTCHECK_AUTH_ERROR","FASTCHECK_AUTH_LOCKED","FASTCHECK_INVALID_ENDPOINT","FASTCHECK_NO_RESPONSE","FASTCHECK_TLS_ERROR","UNASSIGNED","UNKNOWN"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
kubernetesCredentialsTypeEndpointStatusPropEnum = append(kubernetesCredentialsTypeEndpointStatusPropEnum, v)
}
}
const (
// KubernetesCredentialsEndpointStatusASSIGNED captures enum value "ASSIGNED"
KubernetesCredentialsEndpointStatusASSIGNED string = "ASSIGNED"
// KubernetesCredentialsEndpointStatusDISABLED captures enum value "DISABLED"
KubernetesCredentialsEndpointStatusDISABLED string = "DISABLED"
// KubernetesCredentialsEndpointStatusFASTCHECKAUTHERROR captures enum value "FASTCHECK_AUTH_ERROR"
KubernetesCredentialsEndpointStatusFASTCHECKAUTHERROR string = "FASTCHECK_AUTH_ERROR"
// KubernetesCredentialsEndpointStatusFASTCHECKAUTHLOCKED captures enum value "FASTCHECK_AUTH_LOCKED"
KubernetesCredentialsEndpointStatusFASTCHECKAUTHLOCKED string = "FASTCHECK_AUTH_LOCKED"
// KubernetesCredentialsEndpointStatusFASTCHECKINVALIDENDPOINT captures enum value "FASTCHECK_INVALID_ENDPOINT"
KubernetesCredentialsEndpointStatusFASTCHECKINVALIDENDPOINT string = "FASTCHECK_INVALID_ENDPOINT"
// KubernetesCredentialsEndpointStatusFASTCHECKNORESPONSE captures enum value "FASTCHECK_NO_RESPONSE"
KubernetesCredentialsEndpointStatusFASTCHECKNORESPONSE string = "FASTCHECK_NO_RESPONSE"
// KubernetesCredentialsEndpointStatusFASTCHECKTLSERROR captures enum value "FASTCHECK_TLS_ERROR"
KubernetesCredentialsEndpointStatusFASTCHECKTLSERROR string = "FASTCHECK_TLS_ERROR"
// KubernetesCredentialsEndpointStatusUNASSIGNED captures enum value "UNASSIGNED"
KubernetesCredentialsEndpointStatusUNASSIGNED string = "UNASSIGNED"
// KubernetesCredentialsEndpointStatusUNKNOWN captures enum value "UNKNOWN"
KubernetesCredentialsEndpointStatusUNKNOWN string = "UNKNOWN"
)
// prop value enum
func (m *KubernetesCredentials) validateEndpointStatusEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, kubernetesCredentialsTypeEndpointStatusPropEnum); err != nil {
return err
}
return nil
}
func (m *KubernetesCredentials) validateEndpointStatus(formats strfmt.Registry) error {
if swag.IsZero(m.EndpointStatus) { // not required
return nil
}
// value enum
if err := m.validateEndpointStatusEnum("endpointStatus", "body", m.EndpointStatus); err != nil {
return err
}
return nil
}
func (m *KubernetesCredentials) validateLabel(formats strfmt.Registry) error {
if err := validate.Required("label", "body", m.Label); err != nil {
return err
}
if err := validate.MinLength("label", "body", string(*m.Label), 1); err != nil {
return err
}
if err := validate.Pattern("label", "body", string(*m.Label), `^([a-zA-Z0-9_ +-.]*)$`); err != nil {
return err
}
return nil
}
func (m *KubernetesCredentials) validateMetadata(formats strfmt.Registry) error {
if swag.IsZero(m.Metadata) { // not required
return nil
}
if m.Metadata != nil {
if err := m.Metadata.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("metadata")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *KubernetesCredentials) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *KubernetesCredentials) UnmarshalBinary(b []byte) error {
var res KubernetesCredentials
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}