-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathiam_client.go
More file actions
1238 lines (1122 loc) · 54.9 KB
/
iam_client.go
File metadata and controls
1238 lines (1122 loc) · 54.9 KB
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
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package admin
import (
"context"
"fmt"
"log/slog"
"math"
"net/url"
"time"
adminpb "cloud.google.com/go/iam/admin/apiv1/adminpb"
iampb "cloud.google.com/go/iam/apiv1/iampb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
gtransport "google.golang.org/api/transport/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/proto"
)
var newIamClientHook clientHook
// IamCallOptions contains the retry settings for each method of IamClient.
type IamCallOptions struct {
ListServiceAccounts []gax.CallOption
GetServiceAccount []gax.CallOption
CreateServiceAccount []gax.CallOption
UpdateServiceAccount []gax.CallOption
PatchServiceAccount []gax.CallOption
DeleteServiceAccount []gax.CallOption
UndeleteServiceAccount []gax.CallOption
EnableServiceAccount []gax.CallOption
DisableServiceAccount []gax.CallOption
ListServiceAccountKeys []gax.CallOption
GetServiceAccountKey []gax.CallOption
CreateServiceAccountKey []gax.CallOption
UploadServiceAccountKey []gax.CallOption
DeleteServiceAccountKey []gax.CallOption
DisableServiceAccountKey []gax.CallOption
EnableServiceAccountKey []gax.CallOption
SignBlob []gax.CallOption
SignJwt []gax.CallOption
GetIamPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
QueryGrantableRoles []gax.CallOption
ListRoles []gax.CallOption
GetRole []gax.CallOption
CreateRole []gax.CallOption
UpdateRole []gax.CallOption
DeleteRole []gax.CallOption
UndeleteRole []gax.CallOption
QueryTestablePermissions []gax.CallOption
QueryAuditableServices []gax.CallOption
LintPolicy []gax.CallOption
}
func defaultIamGRPCClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("iam.googleapis.com:443"),
internaloption.WithDefaultEndpointTemplate("iam.UNIVERSE_DOMAIN:443"),
internaloption.WithDefaultMTLSEndpoint("iam.mtls.googleapis.com:443"),
internaloption.WithDefaultUniverseDomain("googleapis.com"),
internaloption.WithDefaultAudience("https://iam.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
internaloption.EnableNewAuthLibrary(),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
}
}
func defaultIamCallOptions() *IamCallOptions {
return &IamCallOptions{
ListServiceAccounts: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetServiceAccount: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
CreateServiceAccount: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
UpdateServiceAccount: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
PatchServiceAccount: []gax.CallOption{},
DeleteServiceAccount: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
UndeleteServiceAccount: []gax.CallOption{},
EnableServiceAccount: []gax.CallOption{},
DisableServiceAccount: []gax.CallOption{},
ListServiceAccountKeys: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
GetServiceAccountKey: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
CreateServiceAccountKey: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
UploadServiceAccountKey: []gax.CallOption{},
DeleteServiceAccountKey: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unavailable,
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})
}),
},
DisableServiceAccountKey: []gax.CallOption{},
EnableServiceAccountKey: []gax.CallOption{},
SignBlob: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
SignJwt: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
GetIamPolicy: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
SetIamPolicy: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
TestIamPermissions: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
QueryGrantableRoles: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
ListRoles: []gax.CallOption{},
GetRole: []gax.CallOption{},
CreateRole: []gax.CallOption{},
UpdateRole: []gax.CallOption{},
DeleteRole: []gax.CallOption{},
UndeleteRole: []gax.CallOption{},
QueryTestablePermissions: []gax.CallOption{},
QueryAuditableServices: []gax.CallOption{},
LintPolicy: []gax.CallOption{},
}
}
// internalIamClient is an interface that defines the methods available from Identity and Access Management (IAM) API.
type internalIamClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
ListServiceAccounts(context.Context, *adminpb.ListServiceAccountsRequest, ...gax.CallOption) *ServiceAccountIterator
GetServiceAccount(context.Context, *adminpb.GetServiceAccountRequest, ...gax.CallOption) (*adminpb.ServiceAccount, error)
CreateServiceAccount(context.Context, *adminpb.CreateServiceAccountRequest, ...gax.CallOption) (*adminpb.ServiceAccount, error)
UpdateServiceAccount(context.Context, *adminpb.ServiceAccount, ...gax.CallOption) (*adminpb.ServiceAccount, error)
PatchServiceAccount(context.Context, *adminpb.PatchServiceAccountRequest, ...gax.CallOption) (*adminpb.ServiceAccount, error)
DeleteServiceAccount(context.Context, *adminpb.DeleteServiceAccountRequest, ...gax.CallOption) error
UndeleteServiceAccount(context.Context, *adminpb.UndeleteServiceAccountRequest, ...gax.CallOption) (*adminpb.UndeleteServiceAccountResponse, error)
EnableServiceAccount(context.Context, *adminpb.EnableServiceAccountRequest, ...gax.CallOption) error
DisableServiceAccount(context.Context, *adminpb.DisableServiceAccountRequest, ...gax.CallOption) error
ListServiceAccountKeys(context.Context, *adminpb.ListServiceAccountKeysRequest, ...gax.CallOption) (*adminpb.ListServiceAccountKeysResponse, error)
GetServiceAccountKey(context.Context, *adminpb.GetServiceAccountKeyRequest, ...gax.CallOption) (*adminpb.ServiceAccountKey, error)
CreateServiceAccountKey(context.Context, *adminpb.CreateServiceAccountKeyRequest, ...gax.CallOption) (*adminpb.ServiceAccountKey, error)
UploadServiceAccountKey(context.Context, *adminpb.UploadServiceAccountKeyRequest, ...gax.CallOption) (*adminpb.ServiceAccountKey, error)
DeleteServiceAccountKey(context.Context, *adminpb.DeleteServiceAccountKeyRequest, ...gax.CallOption) error
DisableServiceAccountKey(context.Context, *adminpb.DisableServiceAccountKeyRequest, ...gax.CallOption) error
EnableServiceAccountKey(context.Context, *adminpb.EnableServiceAccountKeyRequest, ...gax.CallOption) error
SignBlob(context.Context, *adminpb.SignBlobRequest, ...gax.CallOption) (*adminpb.SignBlobResponse, error)
SignJwt(context.Context, *adminpb.SignJwtRequest, ...gax.CallOption) (*adminpb.SignJwtResponse, error)
getIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
setIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
QueryGrantableRoles(context.Context, *adminpb.QueryGrantableRolesRequest, ...gax.CallOption) (*adminpb.QueryGrantableRolesResponse, error)
QueryGrantableRolesIter(context.Context, *adminpb.QueryGrantableRolesRequest, ...gax.CallOption) *RoleIterator
ListRoles(context.Context, *adminpb.ListRolesRequest, ...gax.CallOption) (*adminpb.ListRolesResponse, error)
ListRolesIter(context.Context, *adminpb.ListRolesRequest, ...gax.CallOption) *RoleIterator
GetRole(context.Context, *adminpb.GetRoleRequest, ...gax.CallOption) (*adminpb.Role, error)
CreateRole(context.Context, *adminpb.CreateRoleRequest, ...gax.CallOption) (*adminpb.Role, error)
UpdateRole(context.Context, *adminpb.UpdateRoleRequest, ...gax.CallOption) (*adminpb.Role, error)
DeleteRole(context.Context, *adminpb.DeleteRoleRequest, ...gax.CallOption) (*adminpb.Role, error)
UndeleteRole(context.Context, *adminpb.UndeleteRoleRequest, ...gax.CallOption) (*adminpb.Role, error)
QueryTestablePermissions(context.Context, *adminpb.QueryTestablePermissionsRequest, ...gax.CallOption) (*adminpb.QueryTestablePermissionsResponse, error)
QueryTestablePermissionsIter(context.Context, *adminpb.QueryTestablePermissionsRequest, ...gax.CallOption) *PermissionIterator
QueryAuditableServices(context.Context, *adminpb.QueryAuditableServicesRequest, ...gax.CallOption) (*adminpb.QueryAuditableServicesResponse, error)
LintPolicy(context.Context, *adminpb.LintPolicyRequest, ...gax.CallOption) (*adminpb.LintPolicyResponse, error)
}
// IamClient is a client for interacting with Identity and Access Management (IAM) API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Creates and manages Identity and Access Management (IAM) resources.
//
// You can use this service to work with all of the following resources:
//
// Service accounts, which identify an application or a virtual machine
// (VM) instance rather than a person
//
// Service account keys, which service accounts use to authenticate with
// Google APIs
//
// IAM policies for service accounts, which specify the roles that a
// principal has for the service account
//
// IAM custom roles, which help you limit the number of permissions that
// you grant to principals
//
// In addition, you can use this service to complete the following tasks, among
// others:
//
// Test whether a service account can use specific permissions
//
// Check which roles you can grant for a specific resource
//
// Lint, or validate, condition expressions in an IAM policy
//
// When you read data from the IAM API, each read is eventually consistent. In
// other words, if you write data with the IAM API, then immediately read that
// data, the read operation might return an older version of the data. To deal
// with this behavior, your application can retry the request with truncated
// exponential backoff.
//
// In contrast, writing data to the IAM API is sequentially consistent. In other
// words, write operations are always processed in the order in which they were
// received.
type IamClient struct {
// The internal transport-dependent client.
internalClient internalIamClient
// The call options for this service.
CallOptions *IamCallOptions
}
// Wrapper methods routed to the internal client.
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *IamClient) Close() error {
return c.internalClient.Close()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *IamClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *IamClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// ListServiceAccounts lists every ServiceAccount that belongs to a specific project.
func (c *IamClient) ListServiceAccounts(ctx context.Context, req *adminpb.ListServiceAccountsRequest, opts ...gax.CallOption) *ServiceAccountIterator {
return c.internalClient.ListServiceAccounts(ctx, req, opts...)
}
// GetServiceAccount gets a ServiceAccount.
func (c *IamClient) GetServiceAccount(ctx context.Context, req *adminpb.GetServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
return c.internalClient.GetServiceAccount(ctx, req, opts...)
}
// CreateServiceAccount creates a ServiceAccount.
func (c *IamClient) CreateServiceAccount(ctx context.Context, req *adminpb.CreateServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
return c.internalClient.CreateServiceAccount(ctx, req, opts...)
}
// UpdateServiceAccount Note: We are in the process of deprecating this method. Use
// PatchServiceAccount instead.
//
// Updates a ServiceAccount.
//
// You can update only the display_name field.
func (c *IamClient) UpdateServiceAccount(ctx context.Context, req *adminpb.ServiceAccount, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
return c.internalClient.UpdateServiceAccount(ctx, req, opts...)
}
// PatchServiceAccount patches a ServiceAccount.
func (c *IamClient) PatchServiceAccount(ctx context.Context, req *adminpb.PatchServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
return c.internalClient.PatchServiceAccount(ctx, req, opts...)
}
// DeleteServiceAccount deletes a ServiceAccount.
//
// Warning: After you delete a service account, you might not be able to
// undelete it. If you know that you need to re-enable the service account in
// the future, use DisableServiceAccount instead.
//
// If you delete a service account, IAM permanently removes the service
// account 30 days later. Google Cloud cannot recover the service account
// after it is permanently removed, even if you file a support request.
//
// To help avoid unplanned outages, we recommend that you disable the service
// account before you delete it. Use DisableServiceAccount to disable the
// service account, then wait at least 24 hours and watch for unintended
// consequences. If there are no unintended consequences, you can delete the
// service account.
func (c *IamClient) DeleteServiceAccount(ctx context.Context, req *adminpb.DeleteServiceAccountRequest, opts ...gax.CallOption) error {
return c.internalClient.DeleteServiceAccount(ctx, req, opts...)
}
// UndeleteServiceAccount restores a deleted ServiceAccount.
//
// Important: It is not always possible to restore a deleted service
// account. Use this method only as a last resort.
//
// After you delete a service account, IAM permanently removes the service
// account 30 days later. There is no way to restore a deleted service account
// that has been permanently removed.
func (c *IamClient) UndeleteServiceAccount(ctx context.Context, req *adminpb.UndeleteServiceAccountRequest, opts ...gax.CallOption) (*adminpb.UndeleteServiceAccountResponse, error) {
return c.internalClient.UndeleteServiceAccount(ctx, req, opts...)
}
// EnableServiceAccount enables a ServiceAccount that was disabled by
// DisableServiceAccount.
//
// If the service account is already enabled, then this method has no effect.
//
// If the service account was disabled by other means—for example, if Google
// disabled the service account because it was compromised—you cannot use this
// method to enable the service account.
func (c *IamClient) EnableServiceAccount(ctx context.Context, req *adminpb.EnableServiceAccountRequest, opts ...gax.CallOption) error {
return c.internalClient.EnableServiceAccount(ctx, req, opts...)
}
// DisableServiceAccount disables a ServiceAccount immediately.
//
// If an application uses the service account to authenticate, that
// application can no longer call Google APIs or access Google Cloud
// resources. Existing access tokens for the service account are rejected, and
// requests for new access tokens will fail.
//
// To re-enable the service account, use EnableServiceAccount. After you
// re-enable the service account, its existing access tokens will be accepted,
// and you can request new access tokens.
//
// To help avoid unplanned outages, we recommend that you disable the service
// account before you delete it. Use this method to disable the service
// account, then wait at least 24 hours and watch for unintended consequences.
// If there are no unintended consequences, you can delete the service account
// with DeleteServiceAccount.
func (c *IamClient) DisableServiceAccount(ctx context.Context, req *adminpb.DisableServiceAccountRequest, opts ...gax.CallOption) error {
return c.internalClient.DisableServiceAccount(ctx, req, opts...)
}
// ListServiceAccountKeys lists every ServiceAccountKey for a service account.
func (c *IamClient) ListServiceAccountKeys(ctx context.Context, req *adminpb.ListServiceAccountKeysRequest, opts ...gax.CallOption) (*adminpb.ListServiceAccountKeysResponse, error) {
return c.internalClient.ListServiceAccountKeys(ctx, req, opts...)
}
// GetServiceAccountKey gets a ServiceAccountKey.
func (c *IamClient) GetServiceAccountKey(ctx context.Context, req *adminpb.GetServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
return c.internalClient.GetServiceAccountKey(ctx, req, opts...)
}
// CreateServiceAccountKey creates a ServiceAccountKey.
func (c *IamClient) CreateServiceAccountKey(ctx context.Context, req *adminpb.CreateServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
return c.internalClient.CreateServiceAccountKey(ctx, req, opts...)
}
// UploadServiceAccountKey uploads the public key portion of a key pair that you manage, and
// associates the public key with a ServiceAccount.
//
// After you upload the public key, you can use the private key from the key
// pair as a service account key.
func (c *IamClient) UploadServiceAccountKey(ctx context.Context, req *adminpb.UploadServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
return c.internalClient.UploadServiceAccountKey(ctx, req, opts...)
}
// DeleteServiceAccountKey deletes a ServiceAccountKey. Deleting a service account key does not
// revoke short-lived credentials that have been issued based on the service
// account key.
func (c *IamClient) DeleteServiceAccountKey(ctx context.Context, req *adminpb.DeleteServiceAccountKeyRequest, opts ...gax.CallOption) error {
return c.internalClient.DeleteServiceAccountKey(ctx, req, opts...)
}
// DisableServiceAccountKey disable a ServiceAccountKey. A disabled service account key can be
// re-enabled with EnableServiceAccountKey.
func (c *IamClient) DisableServiceAccountKey(ctx context.Context, req *adminpb.DisableServiceAccountKeyRequest, opts ...gax.CallOption) error {
return c.internalClient.DisableServiceAccountKey(ctx, req, opts...)
}
// EnableServiceAccountKey enable a ServiceAccountKey.
func (c *IamClient) EnableServiceAccountKey(ctx context.Context, req *adminpb.EnableServiceAccountKeyRequest, opts ...gax.CallOption) error {
return c.internalClient.EnableServiceAccountKey(ctx, req, opts...)
}
// SignBlob Note: This method is deprecated. Use the
// signBlob (at https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signBlob)
// method in the IAM Service Account Credentials API instead. If you currently
// use this method, see the migration
// guide (at https://cloud.google.com/iam/help/credentials/migrate-api) for
// instructions.
//
// Signs a blob using the system-managed private key for a ServiceAccount.
//
// Deprecated: SignBlob may be removed in a future version.
func (c *IamClient) SignBlob(ctx context.Context, req *adminpb.SignBlobRequest, opts ...gax.CallOption) (*adminpb.SignBlobResponse, error) {
return c.internalClient.SignBlob(ctx, req, opts...)
}
// SignJwt Note: This method is deprecated. Use the
// signJwt (at https://cloud.google.com/iam/help/rest-credentials/v1/projects.serviceAccounts/signJwt)
// method in the IAM Service Account Credentials API instead. If you currently
// use this method, see the migration
// guide (at https://cloud.google.com/iam/help/credentials/migrate-api) for
// instructions.
//
// Signs a JSON Web Token (JWT) using the system-managed private key for a
// ServiceAccount.
//
// Deprecated: SignJwt may be removed in a future version.
func (c *IamClient) SignJwt(ctx context.Context, req *adminpb.SignJwtRequest, opts ...gax.CallOption) (*adminpb.SignJwtResponse, error) {
return c.internalClient.SignJwt(ctx, req, opts...)
}
// GetIamPolicy gets the IAM policy that is attached to a ServiceAccount. This IAM
// policy specifies which principals have access to the service account.
//
// This method does not tell you whether the service account has been granted
// any roles on other resources. To check whether a service account has role
// grants on a resource, use the getIamPolicy method for that resource. For
// example, to view the role grants for a project, call the Resource Manager
// API’s
// projects.getIamPolicy (at https://cloud.google.com/resource-manager/reference/rest/v1/projects/getIamPolicy)
// method.
func (c *IamClient) getIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.getIamPolicy(ctx, req, opts...)
}
// SetIamPolicy sets the IAM policy that is attached to a ServiceAccount.
//
// Use this method to grant or revoke access to the service account. For
// example, you could grant a principal the ability to impersonate the service
// account.
//
// This method does not enable the service account to access other resources.
// To grant roles to a service account on a resource, follow these steps:
//
// Call the resource’s getIamPolicy method to get its current IAM policy.
//
// Edit the policy so that it binds the service account to an IAM role for
// the resource.
//
// Call the resource’s setIamPolicy method to update its IAM policy.
//
// For detailed instructions, see
// Manage access to project, folders, and
// organizations (at https://cloud.google.com/iam/help/service-accounts/granting-access-to-service-accounts)
// or Manage access to other
// resources (at https://cloud.google.com/iam/help/access/manage-other-resources).
func (c *IamClient) setIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.setIamPolicy(ctx, req, opts...)
}
// TestIamPermissions tests whether the caller has the specified permissions on a
// ServiceAccount.
func (c *IamClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// QueryGrantableRoles lists roles that can be granted on a Google Cloud resource. A role is
// grantable if the IAM policy for the resource can contain bindings to the
// role.
func (c *IamClient) QueryGrantableRolesIter(ctx context.Context, req *adminpb.QueryGrantableRolesRequest, opts ...gax.CallOption) *RoleIterator {
return c.internalClient.QueryGrantableRolesIter(ctx, req, opts...)
}
// ListRoles lists every predefined Role that IAM supports, or every custom role
// that is defined for an organization or project.
func (c *IamClient) ListRolesIter(ctx context.Context, req *adminpb.ListRolesRequest, opts ...gax.CallOption) *RoleIterator {
return c.internalClient.ListRolesIter(ctx, req, opts...)
}
// GetRole gets the definition of a Role.
func (c *IamClient) GetRole(ctx context.Context, req *adminpb.GetRoleRequest, opts ...gax.CallOption) (*adminpb.Role, error) {
return c.internalClient.GetRole(ctx, req, opts...)
}
// CreateRole creates a new custom Role.
func (c *IamClient) CreateRole(ctx context.Context, req *adminpb.CreateRoleRequest, opts ...gax.CallOption) (*adminpb.Role, error) {
return c.internalClient.CreateRole(ctx, req, opts...)
}
// UpdateRole updates the definition of a custom Role.
func (c *IamClient) UpdateRole(ctx context.Context, req *adminpb.UpdateRoleRequest, opts ...gax.CallOption) (*adminpb.Role, error) {
return c.internalClient.UpdateRole(ctx, req, opts...)
}
// DeleteRole deletes a custom Role.
//
// When you delete a custom role, the following changes occur immediately:
//
// You cannot bind a principal to the custom role in an IAM
// Policy.
//
// Existing bindings to the custom role are not changed, but they have no
// effect.
//
// By default, the response from ListRoles does not include the custom
// role.
//
// You have 7 days to undelete the custom role. After 7 days, the following
// changes occur:
//
// The custom role is permanently deleted and cannot be recovered.
//
// If an IAM policy contains a binding to the custom role, the binding is
// permanently removed.
func (c *IamClient) DeleteRole(ctx context.Context, req *adminpb.DeleteRoleRequest, opts ...gax.CallOption) (*adminpb.Role, error) {
return c.internalClient.DeleteRole(ctx, req, opts...)
}
// UndeleteRole undeletes a custom Role.
func (c *IamClient) UndeleteRole(ctx context.Context, req *adminpb.UndeleteRoleRequest, opts ...gax.CallOption) (*adminpb.Role, error) {
return c.internalClient.UndeleteRole(ctx, req, opts...)
}
// QueryTestablePermissions lists every permission that you can test on a resource. A permission is
// testable if you can check whether a principal has that permission on the
// resource.
func (c *IamClient) QueryTestablePermissionsIter(ctx context.Context, req *adminpb.QueryTestablePermissionsRequest, opts ...gax.CallOption) *PermissionIterator {
return c.internalClient.QueryTestablePermissionsIter(ctx, req, opts...)
}
// QueryAuditableServices returns a list of services that allow you to opt into audit logs that are
// not generated by default.
//
// To learn more about audit logs, see the Logging
// documentation (at https://cloud.google.com/logging/docs/audit).
func (c *IamClient) QueryAuditableServices(ctx context.Context, req *adminpb.QueryAuditableServicesRequest, opts ...gax.CallOption) (*adminpb.QueryAuditableServicesResponse, error) {
return c.internalClient.QueryAuditableServices(ctx, req, opts...)
}
// LintPolicy lints, or validates, an IAM policy. Currently checks the
// google.iam.v1.Binding.condition field, which contains a condition
// expression for a role binding.
//
// Successful calls to this method always return an HTTP 200 OK status code,
// even if the linter detects an issue in the IAM policy.
func (c *IamClient) LintPolicy(ctx context.Context, req *adminpb.LintPolicyRequest, opts ...gax.CallOption) (*adminpb.LintPolicyResponse, error) {
return c.internalClient.LintPolicy(ctx, req, opts...)
}
// iamGRPCClient is a client for interacting with Identity and Access Management (IAM) API over gRPC transport.
//
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type iamGRPCClient struct {
// Connection pool of gRPC connections to the service.
connPool gtransport.ConnPool
// Points back to the CallOptions field of the containing IamClient
CallOptions **IamCallOptions
// The gRPC API client.
iamClient adminpb.IAMClient
// The x-goog-* metadata to be sent with each request.
xGoogHeaders []string
logger *slog.Logger
}
// NewIamClient creates a new iam client based on gRPC.
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Creates and manages Identity and Access Management (IAM) resources.
//
// You can use this service to work with all of the following resources:
//
// Service accounts, which identify an application or a virtual machine
// (VM) instance rather than a person
//
// Service account keys, which service accounts use to authenticate with
// Google APIs
//
// IAM policies for service accounts, which specify the roles that a
// principal has for the service account
//
// IAM custom roles, which help you limit the number of permissions that
// you grant to principals
//
// In addition, you can use this service to complete the following tasks, among
// others:
//
// Test whether a service account can use specific permissions
//
// Check which roles you can grant for a specific resource
//
// Lint, or validate, condition expressions in an IAM policy
//
// When you read data from the IAM API, each read is eventually consistent. In
// other words, if you write data with the IAM API, then immediately read that
// data, the read operation might return an older version of the data. To deal
// with this behavior, your application can retry the request with truncated
// exponential backoff.
//
// In contrast, writing data to the IAM API is sequentially consistent. In other
// words, write operations are always processed in the order in which they were
// received.
func NewIamClient(ctx context.Context, opts ...option.ClientOption) (*IamClient, error) {
clientOpts := defaultIamGRPCClientOptions()
if newIamClientHook != nil {
hookOpts, err := newIamClientHook(ctx, clientHookParams{})
if err != nil {
return nil, err
}
clientOpts = append(clientOpts, hookOpts...)
}
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
if err != nil {
return nil, err
}
client := IamClient{CallOptions: defaultIamCallOptions()}
c := &iamGRPCClient{
connPool: connPool,
iamClient: adminpb.NewIAMClient(connPool),
CallOptions: &client.CallOptions,
logger: internaloption.GetLogger(opts),
}
c.setGoogleClientInfo()
client.internalClient = c
return &client, nil
}
// Connection returns a connection to the API service.
//
// Deprecated: Connections are now pooled so this method does not always
// return the same resource.
func (c *iamGRPCClient) Connection() *grpc.ClientConn {
return c.connPool.Conn()
}
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *iamGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogHeaders = []string{
"x-goog-api-client", gax.XGoogHeader(kv...),
}
}
// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *iamGRPCClient) Close() error {
return c.connPool.Close()
}
func (c *iamGRPCClient) ListServiceAccounts(ctx context.Context, req *adminpb.ListServiceAccountsRequest, opts ...gax.CallOption) *ServiceAccountIterator {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).ListServiceAccounts[0:len((*c.CallOptions).ListServiceAccounts):len((*c.CallOptions).ListServiceAccounts)], opts...)
it := &ServiceAccountIterator{}
req = proto.Clone(req).(*adminpb.ListServiceAccountsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.ServiceAccount, string, error) {
resp := &adminpb.ListServiceAccountsResponse{}
if pageToken != "" {
req.PageToken = pageToken
}
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else if pageSize != 0 {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.ListServiceAccounts, req, settings.GRPC, c.logger, "ListServiceAccounts")
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetAccounts(), resp.GetNextPageToken(), nil
}
fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
if err != nil {
return "", err
}
it.items = append(it.items, items...)
return nextPageToken, nil
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
it.pageInfo.MaxSize = int(req.GetPageSize())
it.pageInfo.Token = req.GetPageToken()
return it
}
func (c *iamGRPCClient) GetServiceAccount(ctx context.Context, req *adminpb.GetServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetServiceAccount[0:len((*c.CallOptions).GetServiceAccount):len((*c.CallOptions).GetServiceAccount)], opts...)
var resp *adminpb.ServiceAccount
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.GetServiceAccount, req, settings.GRPC, c.logger, "GetServiceAccount")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) CreateServiceAccount(ctx context.Context, req *adminpb.CreateServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).CreateServiceAccount[0:len((*c.CallOptions).CreateServiceAccount):len((*c.CallOptions).CreateServiceAccount)], opts...)
var resp *adminpb.ServiceAccount
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.CreateServiceAccount, req, settings.GRPC, c.logger, "CreateServiceAccount")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) UpdateServiceAccount(ctx context.Context, req *adminpb.ServiceAccount, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).UpdateServiceAccount[0:len((*c.CallOptions).UpdateServiceAccount):len((*c.CallOptions).UpdateServiceAccount)], opts...)
var resp *adminpb.ServiceAccount
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.UpdateServiceAccount, req, settings.GRPC, c.logger, "UpdateServiceAccount")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) PatchServiceAccount(ctx context.Context, req *adminpb.PatchServiceAccountRequest, opts ...gax.CallOption) (*adminpb.ServiceAccount, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service_account.name", url.QueryEscape(req.GetServiceAccount().GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).PatchServiceAccount[0:len((*c.CallOptions).PatchServiceAccount):len((*c.CallOptions).PatchServiceAccount)], opts...)
var resp *adminpb.ServiceAccount
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.PatchServiceAccount, req, settings.GRPC, c.logger, "PatchServiceAccount")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) DeleteServiceAccount(ctx context.Context, req *adminpb.DeleteServiceAccountRequest, opts ...gax.CallOption) error {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).DeleteServiceAccount[0:len((*c.CallOptions).DeleteServiceAccount):len((*c.CallOptions).DeleteServiceAccount)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = executeRPC(ctx, c.iamClient.DeleteServiceAccount, req, settings.GRPC, c.logger, "DeleteServiceAccount")
return err
}, opts...)
return err
}
func (c *iamGRPCClient) UndeleteServiceAccount(ctx context.Context, req *adminpb.UndeleteServiceAccountRequest, opts ...gax.CallOption) (*adminpb.UndeleteServiceAccountResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).UndeleteServiceAccount[0:len((*c.CallOptions).UndeleteServiceAccount):len((*c.CallOptions).UndeleteServiceAccount)], opts...)
var resp *adminpb.UndeleteServiceAccountResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.UndeleteServiceAccount, req, settings.GRPC, c.logger, "UndeleteServiceAccount")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) EnableServiceAccount(ctx context.Context, req *adminpb.EnableServiceAccountRequest, opts ...gax.CallOption) error {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).EnableServiceAccount[0:len((*c.CallOptions).EnableServiceAccount):len((*c.CallOptions).EnableServiceAccount)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = executeRPC(ctx, c.iamClient.EnableServiceAccount, req, settings.GRPC, c.logger, "EnableServiceAccount")
return err
}, opts...)
return err
}
func (c *iamGRPCClient) DisableServiceAccount(ctx context.Context, req *adminpb.DisableServiceAccountRequest, opts ...gax.CallOption) error {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).DisableServiceAccount[0:len((*c.CallOptions).DisableServiceAccount):len((*c.CallOptions).DisableServiceAccount)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = executeRPC(ctx, c.iamClient.DisableServiceAccount, req, settings.GRPC, c.logger, "DisableServiceAccount")
return err
}, opts...)
return err
}
func (c *iamGRPCClient) ListServiceAccountKeys(ctx context.Context, req *adminpb.ListServiceAccountKeysRequest, opts ...gax.CallOption) (*adminpb.ListServiceAccountKeysResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).ListServiceAccountKeys[0:len((*c.CallOptions).ListServiceAccountKeys):len((*c.CallOptions).ListServiceAccountKeys)], opts...)
var resp *adminpb.ListServiceAccountKeysResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.ListServiceAccountKeys, req, settings.GRPC, c.logger, "ListServiceAccountKeys")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) GetServiceAccountKey(ctx context.Context, req *adminpb.GetServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetServiceAccountKey[0:len((*c.CallOptions).GetServiceAccountKey):len((*c.CallOptions).GetServiceAccountKey)], opts...)
var resp *adminpb.ServiceAccountKey
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.GetServiceAccountKey, req, settings.GRPC, c.logger, "GetServiceAccountKey")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) CreateServiceAccountKey(ctx context.Context, req *adminpb.CreateServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).CreateServiceAccountKey[0:len((*c.CallOptions).CreateServiceAccountKey):len((*c.CallOptions).CreateServiceAccountKey)], opts...)
var resp *adminpb.ServiceAccountKey
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.CreateServiceAccountKey, req, settings.GRPC, c.logger, "CreateServiceAccountKey")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) UploadServiceAccountKey(ctx context.Context, req *adminpb.UploadServiceAccountKeyRequest, opts ...gax.CallOption) (*adminpb.ServiceAccountKey, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).UploadServiceAccountKey[0:len((*c.CallOptions).UploadServiceAccountKey):len((*c.CallOptions).UploadServiceAccountKey)], opts...)
var resp *adminpb.ServiceAccountKey
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = executeRPC(ctx, c.iamClient.UploadServiceAccountKey, req, settings.GRPC, c.logger, "UploadServiceAccountKey")
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *iamGRPCClient) DeleteServiceAccountKey(ctx context.Context, req *adminpb.DeleteServiceAccountKeyRequest, opts ...gax.CallOption) error {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).DeleteServiceAccountKey[0:len((*c.CallOptions).DeleteServiceAccountKey):len((*c.CallOptions).DeleteServiceAccountKey)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = executeRPC(ctx, c.iamClient.DeleteServiceAccountKey, req, settings.GRPC, c.logger, "DeleteServiceAccountKey")
return err
}, opts...)
return err
}