/
secret.gen.go
370 lines (293 loc) · 16 KB
/
secret.gen.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// Package secret provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.
package secret
import (
"fmt"
"net/http"
"github.com/labstack/echo/v4"
"github.com/oapi-codegen/runtime"
externalRef0 "github.com/stephenzsy/small-kms/backend/base"
)
const (
BearerAuthScopes = "BearerAuth.Scopes"
)
// Defines values for SecretGenerateMode.
const (
SecretGenerateModeManual SecretGenerateMode = "manual"
SecretGenerateModeServerGeneratedRandom SecretGenerateMode = "random-server"
)
// Defines values for SecretRandomCharacterClass.
const (
SecretRandomCharClassBase64RawURL SecretRandomCharacterClass = "base64-raw-url"
)
// Secret defines model for Secret.
type Secret = secretComposed
// SecretFields defines model for SecretFields.
type SecretFields struct {
ContentType string `json:"contentType,omitempty"`
Sid string `json:"sid,omitempty"`
Value string `json:"value,omitempty"`
}
// SecretGenerateMode defines model for SecretGenerateMode.
type SecretGenerateMode string
// SecretPolicy defines model for SecretPolicy.
type SecretPolicy = secretPolicyComposed
// SecretPolicyFields defines model for SecretPolicyFields.
type SecretPolicyFields struct {
ExpiryTime *externalRef0.Period `json:"expiryTime,omitempty"`
Mode SecretGenerateMode `json:"mode"`
RandomCharacterClass *SecretRandomCharacterClass `json:"randomCharacterClass,omitempty"`
// RandomLength Length of encoded random secret, in bytes
RandomLength *int `json:"randomLength,omitempty"`
}
// SecretPolicyParameters defines model for SecretPolicyParameters.
type SecretPolicyParameters struct {
DisplayName string `json:"displayName,omitempty"`
ExpiryTime *externalRef0.Period `json:"expiryTime,omitempty"`
Mode SecretGenerateMode `json:"mode"`
RandomCharacterClass *SecretRandomCharacterClass `json:"randomCharacterClass,omitempty"`
RandomLength *int `json:"randomLength,omitempty"`
}
// SecretPolicyRef defines model for SecretPolicyRef.
type SecretPolicyRef = secretPolicyRefComposed
// SecretPolicyRefFields defines model for SecretPolicyRefFields.
type SecretPolicyRefFields struct {
DisplayName string `json:"displayName"`
}
// SecretRandomCharacterClass defines model for SecretRandomCharacterClass.
type SecretRandomCharacterClass string
// SecretRef defines model for SecretRef.
type SecretRef = secretRefComposed
// SecretRefFields defines model for SecretRefFields.
type SecretRefFields struct {
Exp *externalRef0.NumericDate `json:"exp,omitempty"`
Iat externalRef0.NumericDate `json:"iat"`
}
// SecretPolicyResponse defines model for SecretPolicyResponse.
type SecretPolicyResponse = SecretPolicy
// ListSecretsParams defines parameters for ListSecrets.
type ListSecretsParams struct {
// PolicyId Policy ID
PolicyId *string `form:"policyId,omitempty" json:"policyId,omitempty"`
}
// GetSecretParams defines parameters for GetSecret.
type GetSecretParams struct {
WithValue *bool `form:"withValue,omitempty" json:"withValue,omitempty"`
}
// PutSecretPolicyJSONRequestBody defines body for PutSecretPolicy for application/json ContentType.
type PutSecretPolicyJSONRequestBody = SecretPolicyParameters
// ServerInterface represents all server handlers.
type ServerInterface interface {
// List secret policies
// (GET /v1/{namespaceKind}/{namespaceId}/secret-policies)
ListSecretPolicies(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter) error
// Get key spec
// (GET /v1/{namespaceKind}/{namespaceId}/secret-policies/{resourceId})
GetSecretPolicy(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter, resourceId externalRef0.ResourceIdParameter) error
// Put key spec
// (PUT /v1/{namespaceKind}/{namespaceId}/secret-policies/{resourceId})
PutSecretPolicy(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter, resourceId externalRef0.ResourceIdParameter) error
// Generate secret
// (POST /v1/{namespaceKind}/{namespaceId}/secret-policies/{resourceId}/generate)
GenerateSecret(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter, resourceId externalRef0.ResourceIdParameter) error
// List secrets
// (GET /v1/{namespaceKind}/{namespaceId}/secrets)
ListSecrets(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter, params ListSecretsParams) error
// GetSecret
// (GET /v1/{namespaceKind}/{namespaceId}/secrets/{resourceId})
GetSecret(ctx echo.Context, namespaceKind externalRef0.NamespaceKindParameter, namespaceId externalRef0.NamespaceIdParameter, resourceId externalRef0.ResourceIdParameter, params GetSecretParams) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// ListSecretPolicies converts echo context to params.
func (w *ServerInterfaceWrapper) ListSecretPolicies(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.ListSecretPolicies(ctx, namespaceKind, namespaceId)
return err
}
// GetSecretPolicy converts echo context to params.
func (w *ServerInterfaceWrapper) GetSecretPolicy(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
// ------------- Path parameter "resourceId" -------------
var resourceId externalRef0.ResourceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "resourceId", runtime.ParamLocationPath, ctx.Param("resourceId"), &resourceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resourceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetSecretPolicy(ctx, namespaceKind, namespaceId, resourceId)
return err
}
// PutSecretPolicy converts echo context to params.
func (w *ServerInterfaceWrapper) PutSecretPolicy(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
// ------------- Path parameter "resourceId" -------------
var resourceId externalRef0.ResourceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "resourceId", runtime.ParamLocationPath, ctx.Param("resourceId"), &resourceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resourceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PutSecretPolicy(ctx, namespaceKind, namespaceId, resourceId)
return err
}
// GenerateSecret converts echo context to params.
func (w *ServerInterfaceWrapper) GenerateSecret(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
// ------------- Path parameter "resourceId" -------------
var resourceId externalRef0.ResourceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "resourceId", runtime.ParamLocationPath, ctx.Param("resourceId"), &resourceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resourceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GenerateSecret(ctx, namespaceKind, namespaceId, resourceId)
return err
}
// ListSecrets converts echo context to params.
func (w *ServerInterfaceWrapper) ListSecrets(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params ListSecretsParams
// ------------- Optional query parameter "policyId" -------------
err = runtime.BindQueryParameter("form", true, false, "policyId", ctx.QueryParams(), ¶ms.PolicyId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter policyId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.ListSecrets(ctx, namespaceKind, namespaceId, params)
return err
}
// GetSecret converts echo context to params.
func (w *ServerInterfaceWrapper) GetSecret(ctx echo.Context) error {
var err error
// ------------- Path parameter "namespaceKind" -------------
var namespaceKind externalRef0.NamespaceKindParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceKind", runtime.ParamLocationPath, ctx.Param("namespaceKind"), &namespaceKind)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceKind: %s", err))
}
// ------------- Path parameter "namespaceId" -------------
var namespaceId externalRef0.NamespaceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "namespaceId", runtime.ParamLocationPath, ctx.Param("namespaceId"), &namespaceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter namespaceId: %s", err))
}
// ------------- Path parameter "resourceId" -------------
var resourceId externalRef0.ResourceIdParameter
err = runtime.BindStyledParameterWithLocation("simple", false, "resourceId", runtime.ParamLocationPath, ctx.Param("resourceId"), &resourceId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter resourceId: %s", err))
}
ctx.Set(BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetSecretParams
// ------------- Optional query parameter "withValue" -------------
err = runtime.BindQueryParameter("form", true, false, "withValue", ctx.QueryParams(), ¶ms.WithValue)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter withValue: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetSecret(ctx, namespaceKind, namespaceId, resourceId, params)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.GET(baseURL+"/v1/:namespaceKind/:namespaceId/secret-policies", wrapper.ListSecretPolicies)
router.GET(baseURL+"/v1/:namespaceKind/:namespaceId/secret-policies/:resourceId", wrapper.GetSecretPolicy)
router.PUT(baseURL+"/v1/:namespaceKind/:namespaceId/secret-policies/:resourceId", wrapper.PutSecretPolicy)
router.POST(baseURL+"/v1/:namespaceKind/:namespaceId/secret-policies/:resourceId/generate", wrapper.GenerateSecret)
router.GET(baseURL+"/v1/:namespaceKind/:namespaceId/secrets", wrapper.ListSecrets)
router.GET(baseURL+"/v1/:namespaceKind/:namespaceId/secrets/:resourceId", wrapper.GetSecret)
}