/
v1-gen.go
578 lines (506 loc) · 15.5 KB
/
v1-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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
// Package adminschema provides access to the Dex Admin API.
//
// See http://github.com/coreos/dex
//
// Usage example:
//
// import "google.golang.org/api/adminschema/v1"
// ...
// adminschemaService, err := adminschema.New(oauthHttpClient)
package adminschema
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
"google.golang.org/api/googleapi"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
const apiId = "dex:v1"
const apiName = "adminschema"
const apiVersion = "v1"
const basePath = "$ENDPOINT/api/v1/"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Admin = NewAdminService(s)
s.Client = NewClientService(s)
s.Connectors = NewConnectorsService(s)
s.State = NewStateService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
Admin *AdminService
Client *ClientService
Connectors *ConnectorsService
State *StateService
}
func NewAdminService(s *Service) *AdminService {
rs := &AdminService{s: s}
return rs
}
type AdminService struct {
s *Service
}
func NewClientService(s *Service) *ClientService {
rs := &ClientService{s: s}
return rs
}
type ClientService struct {
s *Service
}
func NewConnectorsService(s *Service) *ConnectorsService {
rs := &ConnectorsService{s: s}
return rs
}
type ConnectorsService struct {
s *Service
}
func NewStateService(s *Service) *StateService {
rs := &StateService{s: s}
return rs
}
type StateService struct {
s *Service
}
type Admin struct {
Email string `json:"email,omitempty"`
Id string `json:"id,omitempty"`
Password string `json:"password,omitempty"`
}
type Client struct {
// ClientName: OPTIONAL for normal cliens. Name of the Client to be
// presented to the End-User. If desired, representation of this Claim
// in different languages and scripts is represented as described in
// Section 2.1 ( Metadata Languages and Scripts ). REQUIRED for public
// clients
ClientName string `json:"clientName,omitempty"`
// ClientURI: OPTIONAL. URL of the home page of the Client. The value of
// this field MUST point to a valid Web page. If present, the server
// SHOULD display this URL to the End-User in a followable fashion. If
// desired, representation of this Claim in different languages and
// scripts is represented as described in Section 2.1 ( Metadata
// Languages and Scripts ) .
ClientURI string `json:"clientURI,omitempty"`
// Id: The client ID. If specified in a client create request, it will
// be used as the ID. Otherwise, the server will choose the ID.
Id string `json:"id,omitempty"`
IsAdmin bool `json:"isAdmin,omitempty"`
// LogoURI: OPTIONAL. URL that references a logo for the Client
// application. If present, the server SHOULD display this image to the
// End-User during approval. The value of this field MUST point to a
// valid image file. If desired, representation of this Claim in
// different languages and scripts is represented as described in
// Section 2.1 ( Metadata Languages and Scripts ) .
LogoURI string `json:"logoURI,omitempty"`
// Public: OPTIONAL. Determines if the client is public. Public clients
// have certain restrictions: They cannot use their credentials to
// obtain a client JWT. Their redirects URLs cannot be specified: they
// are always http://localhost:$PORT or urn:ietf:wg:oauth:2.0:oob.
Public bool `json:"public,omitempty"`
// RedirectURIs: REQUIRED for normal clients. Array of Redirection URI
// values used by the Client. One of these registered Redirection URI
// values MUST exactly match the redirect_uri parameter value used in
// each Authorization Request, with the matching performed as described
// in Section 6.2.1 of [RFC3986] ( Berners-Lee, T., Fielding, R., and L.
// Masinter, “Uniform Resource Identifier (URI): Generic Syntax,”
// January 2005. ) (Simple String Comparison). DISALLOWED for public
// clients.
RedirectURIs []string `json:"redirectURIs,omitempty"`
// Secret: The client secret. If specified in a client create request,
// it will be used as the secret. Otherwise, the server will choose the
// secret. Must be a base64 URLEncoded string.
Secret string `json:"secret,omitempty"`
// TrustedPeers: Array of ClientIDs of clients that are allowed to mint
// ID tokens for the client being created.
TrustedPeers []string `json:"trustedPeers,omitempty"`
}
type ClientCreateRequest struct {
Client *Client `json:"client,omitempty"`
}
type ClientCreateResponse struct {
Client *Client `json:"client,omitempty"`
}
type Connector interface{}
type ConnectorsGetResponse struct {
Connectors []interface{} `json:"connectors,omitempty"`
}
type ConnectorsSetRequest struct {
Connectors []interface{} `json:"connectors,omitempty"`
}
type State struct {
AdminUserCreated bool `json:"AdminUserCreated,omitempty"`
}
// method id "dex.admin.Admin.Create":
type AdminCreateCall struct {
s *Service
admin *Admin
opt_ map[string]interface{}
}
// Create: Create a new admin user.
func (r *AdminService) Create(admin *Admin) *AdminCreateCall {
c := &AdminCreateCall{s: r.s, opt_: make(map[string]interface{})}
c.admin = admin
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *AdminCreateCall) Fields(s ...googleapi.Field) *AdminCreateCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *AdminCreateCall) Do() (*Admin, error) {
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.admin)
if err != nil {
return nil, err
}
ctype := "application/json"
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "admin")
urls += "?" + params.Encode()
req, _ := http.NewRequest("POST", urls, body)
googleapi.SetOpaque(req.URL)
req.Header.Set("Content-Type", ctype)
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *Admin
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Create a new admin user.",
// "httpMethod": "POST",
// "id": "dex.admin.Admin.Create",
// "path": "admin",
// "request": {
// "$ref": "Admin"
// },
// "response": {
// "$ref": "Admin"
// }
// }
}
// method id "dex.admin.Admin.Get":
type AdminGetCall struct {
s *Service
id string
opt_ map[string]interface{}
}
// Get: Retrieve information about an admin user.
func (r *AdminService) Get(id string) *AdminGetCall {
c := &AdminGetCall{s: r.s, opt_: make(map[string]interface{})}
c.id = id
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *AdminGetCall) Fields(s ...googleapi.Field) *AdminGetCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *AdminGetCall) Do() (*Admin, error) {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "admin/{id}")
urls += "?" + params.Encode()
req, _ := http.NewRequest("GET", urls, body)
googleapi.Expand(req.URL, map[string]string{
"id": c.id,
})
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *Admin
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Retrieve information about an admin user.",
// "httpMethod": "GET",
// "id": "dex.admin.Admin.Get",
// "parameterOrder": [
// "id"
// ],
// "parameters": {
// "id": {
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "admin/{id}",
// "response": {
// "$ref": "Admin"
// }
// }
}
// method id "dex.admin.Client.Create":
type ClientCreateCall struct {
s *Service
clientcreaterequest *ClientCreateRequest
opt_ map[string]interface{}
}
// Create: Register an OpenID Connect client.
func (r *ClientService) Create(clientcreaterequest *ClientCreateRequest) *ClientCreateCall {
c := &ClientCreateCall{s: r.s, opt_: make(map[string]interface{})}
c.clientcreaterequest = clientcreaterequest
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *ClientCreateCall) Fields(s ...googleapi.Field) *ClientCreateCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *ClientCreateCall) Do() (*ClientCreateResponse, error) {
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.clientcreaterequest)
if err != nil {
return nil, err
}
ctype := "application/json"
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "client")
urls += "?" + params.Encode()
req, _ := http.NewRequest("POST", urls, body)
googleapi.SetOpaque(req.URL)
req.Header.Set("Content-Type", ctype)
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *ClientCreateResponse
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Register an OpenID Connect client.",
// "httpMethod": "POST",
// "id": "dex.admin.Client.Create",
// "path": "client",
// "request": {
// "$ref": "ClientCreateRequest"
// },
// "response": {
// "$ref": "ClientCreateResponse"
// }
// }
}
// method id "dex.admin.Connector.Get":
type ConnectorsGetCall struct {
s *Service
opt_ map[string]interface{}
}
// Get: Return a list of the connectors for the dex system.
func (r *ConnectorsService) Get() *ConnectorsGetCall {
c := &ConnectorsGetCall{s: r.s, opt_: make(map[string]interface{})}
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *ConnectorsGetCall) Fields(s ...googleapi.Field) *ConnectorsGetCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *ConnectorsGetCall) Do() (*ConnectorsGetResponse, error) {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "connectors")
urls += "?" + params.Encode()
req, _ := http.NewRequest("GET", urls, body)
googleapi.SetOpaque(req.URL)
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *ConnectorsGetResponse
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Return a list of the connectors for the dex system.",
// "httpMethod": "GET",
// "id": "dex.admin.Connector.Get",
// "path": "connectors",
// "response": {
// "$ref": "ConnectorsGetResponse"
// }
// }
}
// method id "dex.admin.Connector.Set":
type ConnectorsSetCall struct {
s *Service
connectorssetrequest *ConnectorsSetRequest
opt_ map[string]interface{}
}
// Set: Set the list of connectors for the dex system, overwriting all
// previous connectors. A 200 status code indicates the action was
// successful.
func (r *ConnectorsService) Set(connectorssetrequest *ConnectorsSetRequest) *ConnectorsSetCall {
c := &ConnectorsSetCall{s: r.s, opt_: make(map[string]interface{})}
c.connectorssetrequest = connectorssetrequest
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *ConnectorsSetCall) Fields(s ...googleapi.Field) *ConnectorsSetCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *ConnectorsSetCall) Do() error {
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.connectorssetrequest)
if err != nil {
return err
}
ctype := "application/json"
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "connectors")
urls += "?" + params.Encode()
req, _ := http.NewRequest("PUT", urls, body)
googleapi.SetOpaque(req.URL)
req.Header.Set("Content-Type", ctype)
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Set the list of connectors for the dex system, overwriting all previous connectors. A 200 status code indicates the action was successful.",
// "httpMethod": "PUT",
// "id": "dex.admin.Connector.Set",
// "path": "connectors",
// "request": {
// "$ref": "ConnectorsSetRequest"
// }
// }
}
// method id "dex.admin.State.Get":
type StateGetCall struct {
s *Service
opt_ map[string]interface{}
}
// Get: Get the state of the Dex DB
func (r *StateService) Get() *StateGetCall {
c := &StateGetCall{s: r.s, opt_: make(map[string]interface{})}
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *StateGetCall) Fields(s ...googleapi.Field) *StateGetCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *StateGetCall) Do() (*State, error) {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "state")
urls += "?" + params.Encode()
req, _ := http.NewRequest("GET", urls, body)
googleapi.SetOpaque(req.URL)
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *State
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Get the state of the Dex DB",
// "httpMethod": "GET",
// "id": "dex.admin.State.Get",
// "path": "state",
// "response": {
// "$ref": "State"
// }
// }
}