-
Notifications
You must be signed in to change notification settings - Fork 8
/
accounts.go
2522 lines (2062 loc) · 85.7 KB
/
accounts.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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package serviceaccounts provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/do87/stackit-client-generator version v0.0.2 DO NOT EDIT.
package serviceaccounts
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/pkg/errors"
contracts "github.com/SchwarzIT/community-stackit-go-client/pkg/contracts"
"github.com/SchwarzIT/community-stackit-go-client/pkg/helpers/runtime"
openapiTypes "github.com/SchwarzIT/community-stackit-go-client/pkg/helpers/types"
"github.com/SchwarzIT/community-stackit-go-client/pkg/validate"
)
const (
AuthorizationScopes = "Authorization.Scopes"
)
// Defines values for ServiceAccountKeyListResponseKeyAlgorithm.
const (
SERVICE_ACCOUNT_KEY_LIST_RESPONSE_KEY_ALGORITHM_RSA_2048 ServiceAccountKeyListResponseKeyAlgorithm = "RSA_2048"
)
// Defines values for ServiceAccountKeyListResponseKeyOrigin.
const (
SERVICE_ACCOUNT_KEY_LIST_RESPONSE_KEY_ORIGIN_GENERATED ServiceAccountKeyListResponseKeyOrigin = "GENERATED"
SERVICE_ACCOUNT_KEY_LIST_RESPONSE_KEY_ORIGIN_USER_PROVIDED ServiceAccountKeyListResponseKeyOrigin = "USER_PROVIDED"
)
// Defines values for ServiceAccountKeyListResponseKeyType.
const (
SERVICE_ACCOUNT_KEY_LIST_RESPONSE_KEY_TYPE_SYSTEM_MANAGED ServiceAccountKeyListResponseKeyType = "SYSTEM_MANAGED"
SERVICE_ACCOUNT_KEY_LIST_RESPONSE_KEY_TYPE_USER_MANAGED ServiceAccountKeyListResponseKeyType = "USER_MANAGED"
)
// Defines values for ServiceAccountKeyPatchResponseKeyAlgorithm.
const (
SERVICE_ACCOUNT_KEY_PATCH_RESPONSE_KEY_ALGORITHM_RSA_2048 ServiceAccountKeyPatchResponseKeyAlgorithm = "RSA_2048"
)
// Defines values for ServiceAccountKeyPatchResponseKeyOrigin.
const (
SERVICE_ACCOUNT_KEY_PATCH_RESPONSE_KEY_ORIGIN_GENERATED ServiceAccountKeyPatchResponseKeyOrigin = "GENERATED"
SERVICE_ACCOUNT_KEY_PATCH_RESPONSE_KEY_ORIGIN_USER_PROVIDED ServiceAccountKeyPatchResponseKeyOrigin = "USER_PROVIDED"
)
// Defines values for ServiceAccountKeyPatchResponseKeyType.
const (
SERVICE_ACCOUNT_KEY_PATCH_RESPONSE_KEY_TYPE_SYSTEM_MANAGED ServiceAccountKeyPatchResponseKeyType = "SYSTEM_MANAGED"
SERVICE_ACCOUNT_KEY_PATCH_RESPONSE_KEY_TYPE_USER_MANAGED ServiceAccountKeyPatchResponseKeyType = "USER_MANAGED"
)
// Defines values for ServiceAccountKeyPrivateResponseKeyAlgorithm.
const (
SERVICE_ACCOUNT_KEY_PRIVATE_RESPONSE_KEY_ALGORITHM_RSA_2048 ServiceAccountKeyPrivateResponseKeyAlgorithm = "RSA_2048"
)
// Defines values for ServiceAccountKeyPrivateResponseKeyOrigin.
const (
SERVICE_ACCOUNT_KEY_PRIVATE_RESPONSE_KEY_ORIGIN_GENERATED ServiceAccountKeyPrivateResponseKeyOrigin = "GENERATED"
SERVICE_ACCOUNT_KEY_PRIVATE_RESPONSE_KEY_ORIGIN_USER_PROVIDED ServiceAccountKeyPrivateResponseKeyOrigin = "USER_PROVIDED"
)
// Defines values for ServiceAccountKeyPrivateResponseKeyType.
const (
SERVICE_ACCOUNT_KEY_PRIVATE_RESPONSE_KEY_TYPE_SYSTEM_MANAGED ServiceAccountKeyPrivateResponseKeyType = "SYSTEM_MANAGED"
SERVICE_ACCOUNT_KEY_PRIVATE_RESPONSE_KEY_TYPE_USER_MANAGED ServiceAccountKeyPrivateResponseKeyType = "USER_MANAGED"
)
// Defines values for ServiceAccountKeyResponseWithKeyKeyAlgorithm.
const (
SERVICE_ACCOUNT_KEY_RESPONSE_WITH_KEY_KEY_ALGORITHM_RSA_2048 ServiceAccountKeyResponseWithKeyKeyAlgorithm = "RSA_2048"
)
// Defines values for ServiceAccountKeyResponseWithKeyKeyOrigin.
const (
SERVICE_ACCOUNT_KEY_RESPONSE_WITH_KEY_KEY_ORIGIN_GENERATED ServiceAccountKeyResponseWithKeyKeyOrigin = "GENERATED"
SERVICE_ACCOUNT_KEY_RESPONSE_WITH_KEY_KEY_ORIGIN_USER_PROVIDED ServiceAccountKeyResponseWithKeyKeyOrigin = "USER_PROVIDED"
)
// Defines values for ServiceAccountKeyResponseWithKeyKeyType.
const (
SERVICE_ACCOUNT_KEY_RESPONSE_WITH_KEY_KEY_TYPE_SYSTEM_MANAGED ServiceAccountKeyResponseWithKeyKeyType = "SYSTEM_MANAGED"
SERVICE_ACCOUNT_KEY_RESPONSE_WITH_KEY_KEY_TYPE_USER_MANAGED ServiceAccountKeyResponseWithKeyKeyType = "USER_MANAGED"
)
// Defines values for TokenRequestBodyGrantType.
const (
REFRESH_TOKEN TokenRequestBodyGrantType = "refresh_token"
URN_IETF_PARAMS_OAUTH_GRANT_TYPE_JWT_BEARER TokenRequestBodyGrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"
)
// Defines values for TokenResponseBodyTokenType.
const (
BEARER TokenResponseBodyTokenType = "Bearer"
)
// Defines values for GeKeyParamsFormat.
const (
X509_PEM GeKeyParamsFormat = "X509_PEM"
)
// AccessTokenMetadataV2 Does not contain the actual token.
type AccessTokenMetadataV2 struct {
// Active If true, access token can be used for authorized API calls, if false, the token is not usable anymore.
Active bool `json:"active"`
// CreatedAt Creation time of the access token.
CreatedAt time.Time `json:"createdAt"`
// Id Unique ID of the access token. Also used as JTI field.
ID openapiTypes.UUID `json:"id"`
// ValidUntil Approximate expiration time of the access token. Check the JWT for actual validity date.
ValidUntil time.Time `json:"validUntil"`
}
// AccessTokenV2 Contains token metadata and actual token.
type AccessTokenV2 struct {
// Active Newly created access tokens are valid, and can be revoked if needed.
Active bool `json:"active"`
// CreatedAt Creation time of the access token.
CreatedAt time.Time `json:"createdAt"`
// Id Unique ID of the access token. Also used as JTI field.
ID openapiTypes.UUID `json:"id"`
// Token The access token in JWT format. Use this with `Bearer` prefix for API calls. Store it, as it is not recoverable later.
Token string `json:"token"`
// ValidUntil Approximate expiration time of the access token. Check the JWT for actual validity date.
ValidUntil time.Time `json:"validUntil"`
}
// AuthError defines model for AuthError.
type AuthError struct {
Error struct {
Code int `json:"code"`
Message string `json:"message"`
Status string `json:"status"`
} `json:"error"`
}
// CreateAccessTokenRequestBody defines model for CreateAccessTokenRequestBody.
type CreateAccessTokenRequestBody struct {
// TtlDays The duration in days for how long the new Access Token should be valid.
TtlDays int `json:"ttlDays"`
}
// CreateServiceAccountRequestBodyV2 defines model for CreateServiceAccountRequestBodyV2.
type CreateServiceAccountRequestBodyV2 struct {
// Name The requested name of the service account. The service will generate a unique email from this name.
Name string `json:"name"`
}
// Error Contains error information.
type Error struct {
Error string `json:"error"`
Message string `json:"message"`
Path string `json:"path"`
Status int `json:"status"`
TimeStamp time.Time `json:"timeStamp"`
}
// GetAccessTokensResponseBodyV2 defines model for GetAccessTokensResponseBodyV2.
type GetAccessTokensResponseBodyV2 struct {
Items *[]AccessTokenMetadataV2 `json:"items,omitempty"`
}
// GetJWKResponseBody defines model for GetJWKResponseBody.
type GetJWKResponseBody struct {
Keys []JsonWebKey `json:"keys"`
}
// GetServiceAccountsKeysResponseBody defines model for GetServiceAccountsKeysResponseBody.
type GetServiceAccountsKeysResponseBody struct {
Items []ServiceAccountKeyListResponse `json:"items"`
}
// GetServiceAccountsResponseBodyV2 defines model for GetServiceAccountsResponseBodyV2.
type GetServiceAccountsResponseBodyV2 struct {
Items []ServiceAccountV2 `json:"items"`
}
// JsonWebKey JSON Web Key according to https://datatracker.ietf.org/doc/html/rfc7517#section-4
type JsonWebKey struct {
Alg *string `json:"alg,omitempty"`
E string `json:"e"`
Kid *string `json:"kid,omitempty"`
Ks *string `json:"ks,omitempty"`
N string `json:"n"`
Ops *string `json:"ops,omitempty"`
Use *string `json:"use,omitempty"`
X5c *string `json:"x5c,omitempty"`
X5t *string `json:"x5t,omitempty"`
X5t256 *string `json:"x5t256,omitempty"`
X5u *string `json:"x5u,omitempty"`
}
// ServiceAccountKeyListResponse defines model for ServiceAccountKeyListResponse.
type ServiceAccountKeyListResponse struct {
Active bool `json:"active"`
// CreatedAt Creation time of the key
CreatedAt time.Time `json:"createdAt"`
// Id Unique ID of the key.
ID openapiTypes.UUID `json:"id"`
KeyAlgorithm ServiceAccountKeyListResponseKeyAlgorithm `json:"keyAlgorithm"`
KeyOrigin ServiceAccountKeyListResponseKeyOrigin `json:"keyOrigin"`
KeyType ServiceAccountKeyListResponseKeyType `json:"keyType"`
// ValidUntil If specified, the timestamp until the key is active. May be null
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountKeyListResponseKeyAlgorithm defines model for ServiceAccountKeyListResponse.KeyAlgorithm.
type ServiceAccountKeyListResponseKeyAlgorithm string
// ServiceAccountKeyListResponseKeyOrigin defines model for ServiceAccountKeyListResponse.KeyOrigin.
type ServiceAccountKeyListResponseKeyOrigin string
// ServiceAccountKeyListResponseKeyType defines model for ServiceAccountKeyListResponse.KeyType.
type ServiceAccountKeyListResponseKeyType string
// ServiceAccountKeyPatchResponse defines model for ServiceAccountKeyPatchResponse.
type ServiceAccountKeyPatchResponse struct {
Active bool `json:"active"`
// CreatedAt Creation time of the key
CreatedAt time.Time `json:"createdAt"`
// Id Unique ID of the key.
ID openapiTypes.UUID `json:"id"`
KeyAlgorithm ServiceAccountKeyPatchResponseKeyAlgorithm `json:"keyAlgorithm"`
KeyOrigin ServiceAccountKeyPatchResponseKeyOrigin `json:"keyOrigin"`
KeyType ServiceAccountKeyPatchResponseKeyType `json:"keyType"`
// ValidUntil If specified, the timestamp until the key is active. May be null
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountKeyPatchResponseKeyAlgorithm defines model for ServiceAccountKeyPatchResponse.KeyAlgorithm.
type ServiceAccountKeyPatchResponseKeyAlgorithm string
// ServiceAccountKeyPatchResponseKeyOrigin defines model for ServiceAccountKeyPatchResponse.KeyOrigin.
type ServiceAccountKeyPatchResponseKeyOrigin string
// ServiceAccountKeyPatchResponseKeyType defines model for ServiceAccountKeyPatchResponse.KeyType.
type ServiceAccountKeyPatchResponseKeyType string
// ServiceAccountKeyPrivateResponse defines model for ServiceAccountKeyPrivateResponse.
type ServiceAccountKeyPrivateResponse struct {
Active bool `json:"active"`
// CreatedAt Creation time of the key
CreatedAt time.Time `json:"createdAt"`
Credentials struct {
// Aud Audience - service account API URL
Aud string `json:"aud"`
// Iss Service account email
Iss openapiTypes.Email `json:"iss"`
// Kid Key id to use
Kid string `json:"kid"`
// PrivateKey Private key. Only present, if the service account API was generating the key. Not recoverable later.
PrivateKey *string `json:"privateKey,omitempty"`
// Sub Service account id
Sub openapiTypes.UUID `json:"sub"`
} `json:"credentials"`
// Id Unique ID of the key.
ID openapiTypes.UUID `json:"id"`
KeyAlgorithm ServiceAccountKeyPrivateResponseKeyAlgorithm `json:"keyAlgorithm"`
KeyOrigin ServiceAccountKeyPrivateResponseKeyOrigin `json:"keyOrigin"`
KeyType ServiceAccountKeyPrivateResponseKeyType `json:"keyType"`
// PublicKey Public key, that was provider, or was generated by the service account API
PublicKey string `json:"publicKey"`
// ValidUntil If specified, the timestamp until the key is active. May be null
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountKeyPrivateResponseKeyAlgorithm defines model for ServiceAccountKeyPrivateResponse.KeyAlgorithm.
type ServiceAccountKeyPrivateResponseKeyAlgorithm string
// ServiceAccountKeyPrivateResponseKeyOrigin defines model for ServiceAccountKeyPrivateResponse.KeyOrigin.
type ServiceAccountKeyPrivateResponseKeyOrigin string
// ServiceAccountKeyPrivateResponseKeyType defines model for ServiceAccountKeyPrivateResponse.KeyType.
type ServiceAccountKeyPrivateResponseKeyType string
// ServiceAccountKeyRequest defines model for ServiceAccountKeyRequest.
type ServiceAccountKeyRequest struct {
// PublicKey Optional, public key part of the user generated RSA key-pair wrapped in a [X.509 v3 certificate](https://www.rfc-editor.org/rfc/rfc5280)
PublicKey *string `json:"publicKey,omitempty"`
// ValidUntil Optional, date of key expiration. When omitted, key is valid until deleted
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountKeyResponseWithKey defines model for ServiceAccountKeyResponseWithKey.
type ServiceAccountKeyResponseWithKey struct {
Active bool `json:"active"`
// CreatedAt Creation time of the key
CreatedAt time.Time `json:"createdAt"`
Credentials struct {
// Aud Audience - service account API URL
Aud string `json:"aud"`
// Iss Service account email
Iss openapiTypes.Email `json:"iss"`
// Kid Key id to use
Kid string `json:"kid"`
// Sub Service account id
Sub openapiTypes.UUID `json:"sub"`
} `json:"credentials"`
// Id Unique ID of the key.
ID openapiTypes.UUID `json:"id"`
KeyAlgorithm ServiceAccountKeyResponseWithKeyKeyAlgorithm `json:"keyAlgorithm"`
KeyOrigin ServiceAccountKeyResponseWithKeyKeyOrigin `json:"keyOrigin"`
KeyType ServiceAccountKeyResponseWithKeyKeyType `json:"keyType"`
// PublicKey Public key, in the requested format
PublicKey *string `json:"publicKey,omitempty"`
// ValidUntil If specified, the timestamp until the key is active. May be null
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountKeyResponseWithKeyKeyAlgorithm defines model for ServiceAccountKeyResponseWithKey.KeyAlgorithm.
type ServiceAccountKeyResponseWithKeyKeyAlgorithm string
// ServiceAccountKeyResponseWithKeyKeyOrigin defines model for ServiceAccountKeyResponseWithKey.KeyOrigin.
type ServiceAccountKeyResponseWithKeyKeyOrigin string
// ServiceAccountKeyResponseWithKeyKeyType defines model for ServiceAccountKeyResponseWithKey.KeyType.
type ServiceAccountKeyResponseWithKeyKeyType string
// ServiceAccountKeyUpdateRequest defines model for ServiceAccountKeyUpdateRequest.
type ServiceAccountKeyUpdateRequest struct {
// Active Active keys are valid, while inactive keys are temporarily deactivated.
Active *bool `json:"active,omitempty"`
// ValidUntil Optional, date of key expiration. When omitted, key is valid until deleted
ValidUntil *time.Time `json:"validUntil,omitempty"`
}
// ServiceAccountV2 defines model for ServiceAccountV2.
type ServiceAccountV2 struct {
// Email Unique identifier of the service account in format of an email address generated by the service containing the prefix provided by the user during creation.
Email openapiTypes.Email `json:"email"`
// Id Unique ID of the service account. It is also used in the 'sub' field of the service accounts access tokens.
ID openapiTypes.UUID `json:"id"`
// ProjectId ID of the related project
ProjectID string `json:"projectId"`
}
// TokenRequestBody defines model for TokenRequestBody.
type TokenRequestBody struct {
// Assertion The self signed JWT. Must be given when grant_type is urn:ietf:params:oauth:grant-type:jwt-bearer
Assertion *string `json:"assertion,omitempty"`
// GrantType Always use URL encoded values. E.g. urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer
GrantType TokenRequestBodyGrantType `json:"grant_type"`
// RefreshToken Refresh token provided by a previous call with a self signed token. Must be given when grant_type is refresh_token
RefreshToken *string `json:"refresh_token,omitempty"`
}
// TokenRequestBodyGrantType Always use URL encoded values. E.g. urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer
type TokenRequestBodyGrantType string
// TokenResponseBody defines model for TokenResponseBody.
type TokenResponseBody struct {
// AccessToken The short lived token that can be used for API access
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
// RefreshToken Refresh token that can be used to request a new access token when it expires (and before refresh token expires). Tokens are rotated.
RefreshToken string `json:"refresh_token"`
// Scope scope field of the self signed token
Scope string `json:"scope"`
TokenType TokenResponseBodyTokenType `json:"token_type"`
}
// TokenResponseBodyTokenType defines model for TokenResponseBody.TokenType.
type TokenResponseBodyTokenType string
// GeKeyParams defines parameters for GeKey.
type GeKeyParams struct {
// Format Requested format for the public key
Format *GeKeyParamsFormat `form:"format,omitempty" json:"format,omitempty"`
}
// GeKeyParamsFormat defines parameters for GeKey.
type GeKeyParamsFormat string
// CreateTokenFormdataRequestBody defines body for CreateToken for application/x-www-form-urlencoded ContentType.
type CreateTokenFormdataRequestBody = TokenRequestBody
// CreateJSONRequestBody defines body for Create for application/json ContentType.
type CreateJSONRequestBody = CreateServiceAccountRequestBodyV2
// CreateAccessTokensJSONRequestBody defines body for CreateAccessTokens for application/json ContentType.
type CreateAccessTokensJSONRequestBody = CreateAccessTokenRequestBody
// CreateKeysJSONRequestBody defines body for CreateKeys for application/json ContentType.
type CreateKeysJSONRequestBody = ServiceAccountKeyRequest
// UpdateKeysJSONRequestBody defines body for UpdateKeys for application/json ContentType.
type UpdateKeysJSONRequestBody = ServiceAccountKeyUpdateRequest
// RequestEditorFn is the function signature for the RequestEditor callback function
type RequestEditorFn func(ctx context.Context, req *http.Request) error
// Client which conforms to the OpenAPI3 specification for this service.
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client contracts.BaseClientInterface
}
// NewRawClient Creates a new Client, with reasonable defaults
func NewRawClient(server string, httpClient contracts.BaseClientInterface) *Client {
// create a client with sane default values
client := Client{
Server: server,
Client: httpClient,
}
return &client
}
// The interface specification for the client above.
type rawClientInterface interface {
// CreateToken request with any body
CreateTokenRawWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
CreateTokenWithFormdataBodyRaw(ctx context.Context, body CreateTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// Get request
GetRaw(ctx context.Context, projectId string, reqEditors ...RequestEditorFn) (*http.Response, error)
// Create request with any body
CreateRawWithBody(ctx context.Context, projectId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
CreateRaw(ctx context.Context, projectId string, body CreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// Delete request
DeleteRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetAccessTokens request
GetAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error)
// CreateAccessTokens request with any body
CreateAccessTokensRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
CreateAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, body CreateAccessTokensJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// DeleteAccessTokens request
DeleteAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, accessTokenId openapiTypes.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetKeys request
GetKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error)
// CreateKeys request with any body
CreateKeysRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
CreateKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, body CreateKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// DeleteKeys request
DeleteKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
// GeKey request
GeKeyRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, params *GeKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// UpdateKeys request with any body
UpdateKeysRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
UpdateKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, body UpdateKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetServiceAccountJwks request
GetServiceAccountJwksRaw(ctx context.Context, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error)
}
func (c *Client) CreateTokenRawWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateTokenRequestWithBody(ctx, c.Server, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateTokenWithFormdataBodyRaw(ctx context.Context, body CreateTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateTokenRequestWithFormdataBody(ctx, c.Server, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) GetRaw(ctx context.Context, projectId string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetRequest(ctx, c.Server, projectId)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateRawWithBody(ctx context.Context, projectId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateRequestWithBody(ctx, c.Server, projectId, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateRaw(ctx context.Context, projectId string, body CreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateRequest(ctx, c.Server, projectId, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) DeleteRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewDeleteRequest(ctx, c.Server, projectId, serviceAccountEmail)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) GetAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetAccessTokensRequest(ctx, c.Server, projectId, serviceAccountEmail)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateAccessTokensRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateAccessTokensRequestWithBody(ctx, c.Server, projectId, serviceAccountEmail, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, body CreateAccessTokensJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateAccessTokensRequest(ctx, c.Server, projectId, serviceAccountEmail, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) DeleteAccessTokensRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, accessTokenId openapiTypes.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewDeleteAccessTokensRequest(ctx, c.Server, projectId, serviceAccountEmail, accessTokenId)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) GetKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetKeysRequest(ctx, c.Server, projectId, serviceAccountEmail)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateKeysRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateKeysRequestWithBody(ctx, c.Server, projectId, serviceAccountEmail, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) CreateKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, body CreateKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateKeysRequest(ctx, c.Server, projectId, serviceAccountEmail, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) DeleteKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewDeleteKeysRequest(ctx, c.Server, projectId, serviceAccountEmail, keyId)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) GeKeyRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, params *GeKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGeKeyRequest(ctx, c.Server, projectId, serviceAccountEmail, keyId, params)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateKeysRawWithBody(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateKeysRequestWithBody(ctx, c.Server, projectId, serviceAccountEmail, keyId, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateKeysRaw(ctx context.Context, projectId string, serviceAccountEmail openapiTypes.Email, keyId openapiTypes.UUID, body UpdateKeysJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateKeysRequest(ctx, c.Server, projectId, serviceAccountEmail, keyId, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) GetServiceAccountJwksRaw(ctx context.Context, serviceAccountEmail openapiTypes.Email, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetServiceAccountJwksRequest(ctx, c.Server, serviceAccountEmail)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
// NewCreateTokenRequestWithFormdataBody calls the generic CreateToken builder with application/x-www-form-urlencoded body
func NewCreateTokenRequestWithFormdataBody(ctx context.Context, server string, body CreateTokenFormdataRequestBody) (*http.Request, error) {
var bodyReader io.Reader
bodyStr, err := runtime.MarshalForm(body, nil)
if err != nil {
return nil, err
}
bodyReader = strings.NewReader(bodyStr.Encode())
return NewCreateTokenRequestWithBody(ctx, server, "application/x-www-form-urlencoded", bodyReader)
}
// NewCreateTokenRequestWithBody generates requests for CreateToken with any type of body
func NewCreateTokenRequestWithBody(ctx context.Context, server string, contentType string, body io.Reader) (*http.Request, error) {
var err error
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/token")
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", queryURL.String(), body)
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", contentType)
return req, nil
}
// NewGetRequest generates requests for Get
func NewGetRequest(ctx context.Context, server string, projectId string) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v2/projects/%s/service-accounts", pathParam0)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "GET", queryURL.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// NewCreateRequest calls the generic Create builder with application/json body
func NewCreateRequest(ctx context.Context, server string, projectId string, body CreateJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(buf)
return NewCreateRequestWithBody(ctx, server, projectId, "application/json", bodyReader)
}
// NewCreateRequestWithBody generates requests for Create with any type of body
func NewCreateRequestWithBody(ctx context.Context, server string, projectId string, contentType string, body io.Reader) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v2/projects/%s/service-accounts", pathParam0)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", queryURL.String(), body)
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", contentType)
return req, nil
}
// NewDeleteRequest generates requests for Delete
func NewDeleteRequest(ctx context.Context, server string, projectId string, serviceAccountEmail openapiTypes.Email) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
var pathParam1 string
pathParam1, err = runtime.StyleParamWithLocation("simple", false, "serviceAccountEmail", runtime.ParamLocationPath, serviceAccountEmail)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v2/projects/%s/service-accounts/%s", pathParam0, pathParam1)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "DELETE", queryURL.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// NewGetAccessTokensRequest generates requests for GetAccessTokens
func NewGetAccessTokensRequest(ctx context.Context, server string, projectId string, serviceAccountEmail openapiTypes.Email) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
var pathParam1 string
pathParam1, err = runtime.StyleParamWithLocation("simple", false, "serviceAccountEmail", runtime.ParamLocationPath, serviceAccountEmail)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v2/projects/%s/service-accounts/%s/access-tokens", pathParam0, pathParam1)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "GET", queryURL.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// NewCreateAccessTokensRequest calls the generic CreateAccessTokens builder with application/json body
func NewCreateAccessTokensRequest(ctx context.Context, server string, projectId string, serviceAccountEmail openapiTypes.Email, body CreateAccessTokensJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(buf)
return NewCreateAccessTokensRequestWithBody(ctx, server, projectId, serviceAccountEmail, "application/json", bodyReader)
}
// NewCreateAccessTokensRequestWithBody generates requests for CreateAccessTokens with any type of body
func NewCreateAccessTokensRequestWithBody(ctx context.Context, server string, projectId string, serviceAccountEmail openapiTypes.Email, contentType string, body io.Reader) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
var pathParam1 string
pathParam1, err = runtime.StyleParamWithLocation("simple", false, "serviceAccountEmail", runtime.ParamLocationPath, serviceAccountEmail)
if err != nil {
return nil, err
}
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/v2/projects/%s/service-accounts/%s/access-tokens", pathParam0, pathParam1)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", queryURL.String(), body)
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", contentType)
return req, nil
}
// NewDeleteAccessTokensRequest generates requests for DeleteAccessTokens
func NewDeleteAccessTokensRequest(ctx context.Context, server string, projectId string, serviceAccountEmail openapiTypes.Email, accessTokenId openapiTypes.UUID) (*http.Request, error) {
var err error
var pathParam0 string
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectId", runtime.ParamLocationPath, projectId)
if err != nil {
return nil, err
}
var pathParam1 string
pathParam1, err = runtime.StyleParamWithLocation("simple", false, "serviceAccountEmail", runtime.ParamLocationPath, serviceAccountEmail)