1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package resourcemanager
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "io"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 iampb "cloud.google.com/go/iam/apiv1/iampb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb"
34 gax "github.com/googleapis/gax-go/v2"
35 "google.golang.org/api/googleapi"
36 "google.golang.org/api/iterator"
37 "google.golang.org/api/option"
38 "google.golang.org/api/option/internaloption"
39 gtransport "google.golang.org/api/transport/grpc"
40 httptransport "google.golang.org/api/transport/http"
41 "google.golang.org/grpc"
42 "google.golang.org/grpc/codes"
43 "google.golang.org/protobuf/encoding/protojson"
44 "google.golang.org/protobuf/proto"
45 )
46
47 var newTagKeysClientHook clientHook
48
49
50 type TagKeysCallOptions struct {
51 ListTagKeys []gax.CallOption
52 GetTagKey []gax.CallOption
53 GetNamespacedTagKey []gax.CallOption
54 CreateTagKey []gax.CallOption
55 UpdateTagKey []gax.CallOption
56 DeleteTagKey []gax.CallOption
57 GetIamPolicy []gax.CallOption
58 SetIamPolicy []gax.CallOption
59 TestIamPermissions []gax.CallOption
60 GetOperation []gax.CallOption
61 }
62
63 func defaultTagKeysGRPCClientOptions() []option.ClientOption {
64 return []option.ClientOption{
65 internaloption.WithDefaultEndpoint("cloudresourcemanager.googleapis.com:443"),
66 internaloption.WithDefaultEndpointTemplate("cloudresourcemanager.UNIVERSE_DOMAIN:443"),
67 internaloption.WithDefaultMTLSEndpoint("cloudresourcemanager.mtls.googleapis.com:443"),
68 internaloption.WithDefaultUniverseDomain("googleapis.com"),
69 internaloption.WithDefaultAudience("https://cloudresourcemanager.googleapis.com/"),
70 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
71 internaloption.EnableJwtWithScope(),
72 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
73 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
74 }
75 }
76
77 func defaultTagKeysCallOptions() *TagKeysCallOptions {
78 return &TagKeysCallOptions{
79 ListTagKeys: []gax.CallOption{
80 gax.WithTimeout(60000 * time.Millisecond),
81 gax.WithRetry(func() gax.Retryer {
82 return gax.OnCodes([]codes.Code{
83 codes.Unavailable,
84 }, gax.Backoff{
85 Initial: 100 * time.Millisecond,
86 Max: 60000 * time.Millisecond,
87 Multiplier: 1.30,
88 })
89 }),
90 },
91 GetTagKey: []gax.CallOption{
92 gax.WithTimeout(60000 * time.Millisecond),
93 gax.WithRetry(func() gax.Retryer {
94 return gax.OnCodes([]codes.Code{
95 codes.Unavailable,
96 }, gax.Backoff{
97 Initial: 100 * time.Millisecond,
98 Max: 60000 * time.Millisecond,
99 Multiplier: 1.30,
100 })
101 }),
102 },
103 GetNamespacedTagKey: []gax.CallOption{},
104 CreateTagKey: []gax.CallOption{
105 gax.WithTimeout(60000 * time.Millisecond),
106 },
107 UpdateTagKey: []gax.CallOption{
108 gax.WithTimeout(60000 * time.Millisecond),
109 },
110 DeleteTagKey: []gax.CallOption{
111 gax.WithTimeout(60000 * time.Millisecond),
112 },
113 GetIamPolicy: []gax.CallOption{
114 gax.WithTimeout(60000 * time.Millisecond),
115 gax.WithRetry(func() gax.Retryer {
116 return gax.OnCodes([]codes.Code{
117 codes.Unavailable,
118 }, gax.Backoff{
119 Initial: 100 * time.Millisecond,
120 Max: 60000 * time.Millisecond,
121 Multiplier: 1.30,
122 })
123 }),
124 },
125 SetIamPolicy: []gax.CallOption{
126 gax.WithTimeout(60000 * time.Millisecond),
127 },
128 TestIamPermissions: []gax.CallOption{},
129 GetOperation: []gax.CallOption{},
130 }
131 }
132
133 func defaultTagKeysRESTCallOptions() *TagKeysCallOptions {
134 return &TagKeysCallOptions{
135 ListTagKeys: []gax.CallOption{
136 gax.WithTimeout(60000 * time.Millisecond),
137 gax.WithRetry(func() gax.Retryer {
138 return gax.OnHTTPCodes(gax.Backoff{
139 Initial: 100 * time.Millisecond,
140 Max: 60000 * time.Millisecond,
141 Multiplier: 1.30,
142 },
143 http.StatusServiceUnavailable)
144 }),
145 },
146 GetTagKey: []gax.CallOption{
147 gax.WithTimeout(60000 * time.Millisecond),
148 gax.WithRetry(func() gax.Retryer {
149 return gax.OnHTTPCodes(gax.Backoff{
150 Initial: 100 * time.Millisecond,
151 Max: 60000 * time.Millisecond,
152 Multiplier: 1.30,
153 },
154 http.StatusServiceUnavailable)
155 }),
156 },
157 GetNamespacedTagKey: []gax.CallOption{},
158 CreateTagKey: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 },
161 UpdateTagKey: []gax.CallOption{
162 gax.WithTimeout(60000 * time.Millisecond),
163 },
164 DeleteTagKey: []gax.CallOption{
165 gax.WithTimeout(60000 * time.Millisecond),
166 },
167 GetIamPolicy: []gax.CallOption{
168 gax.WithTimeout(60000 * time.Millisecond),
169 gax.WithRetry(func() gax.Retryer {
170 return gax.OnHTTPCodes(gax.Backoff{
171 Initial: 100 * time.Millisecond,
172 Max: 60000 * time.Millisecond,
173 Multiplier: 1.30,
174 },
175 http.StatusServiceUnavailable)
176 }),
177 },
178 SetIamPolicy: []gax.CallOption{
179 gax.WithTimeout(60000 * time.Millisecond),
180 },
181 TestIamPermissions: []gax.CallOption{},
182 GetOperation: []gax.CallOption{},
183 }
184 }
185
186
187 type internalTagKeysClient interface {
188 Close() error
189 setGoogleClientInfo(...string)
190 Connection() *grpc.ClientConn
191 ListTagKeys(context.Context, *resourcemanagerpb.ListTagKeysRequest, ...gax.CallOption) *TagKeyIterator
192 GetTagKey(context.Context, *resourcemanagerpb.GetTagKeyRequest, ...gax.CallOption) (*resourcemanagerpb.TagKey, error)
193 GetNamespacedTagKey(context.Context, *resourcemanagerpb.GetNamespacedTagKeyRequest, ...gax.CallOption) (*resourcemanagerpb.TagKey, error)
194 CreateTagKey(context.Context, *resourcemanagerpb.CreateTagKeyRequest, ...gax.CallOption) (*CreateTagKeyOperation, error)
195 CreateTagKeyOperation(name string) *CreateTagKeyOperation
196 UpdateTagKey(context.Context, *resourcemanagerpb.UpdateTagKeyRequest, ...gax.CallOption) (*UpdateTagKeyOperation, error)
197 UpdateTagKeyOperation(name string) *UpdateTagKeyOperation
198 DeleteTagKey(context.Context, *resourcemanagerpb.DeleteTagKeyRequest, ...gax.CallOption) (*DeleteTagKeyOperation, error)
199 DeleteTagKeyOperation(name string) *DeleteTagKeyOperation
200 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
201 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
202 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
203 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
204 }
205
206
207
208
209
210 type TagKeysClient struct {
211
212 internalClient internalTagKeysClient
213
214
215 CallOptions *TagKeysCallOptions
216
217
218
219
220 LROClient *lroauto.OperationsClient
221 }
222
223
224
225
226
227 func (c *TagKeysClient) Close() error {
228 return c.internalClient.Close()
229 }
230
231
232
233
234 func (c *TagKeysClient) setGoogleClientInfo(keyval ...string) {
235 c.internalClient.setGoogleClientInfo(keyval...)
236 }
237
238
239
240
241
242 func (c *TagKeysClient) Connection() *grpc.ClientConn {
243 return c.internalClient.Connection()
244 }
245
246
247 func (c *TagKeysClient) ListTagKeys(ctx context.Context, req *resourcemanagerpb.ListTagKeysRequest, opts ...gax.CallOption) *TagKeyIterator {
248 return c.internalClient.ListTagKeys(ctx, req, opts...)
249 }
250
251
252
253 func (c *TagKeysClient) GetTagKey(ctx context.Context, req *resourcemanagerpb.GetTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
254 return c.internalClient.GetTagKey(ctx, req, opts...)
255 }
256
257
258
259
260 func (c *TagKeysClient) GetNamespacedTagKey(ctx context.Context, req *resourcemanagerpb.GetNamespacedTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
261 return c.internalClient.GetNamespacedTagKey(ctx, req, opts...)
262 }
263
264
265
266
267
268 func (c *TagKeysClient) CreateTagKey(ctx context.Context, req *resourcemanagerpb.CreateTagKeyRequest, opts ...gax.CallOption) (*CreateTagKeyOperation, error) {
269 return c.internalClient.CreateTagKey(ctx, req, opts...)
270 }
271
272
273
274 func (c *TagKeysClient) CreateTagKeyOperation(name string) *CreateTagKeyOperation {
275 return c.internalClient.CreateTagKeyOperation(name)
276 }
277
278
279 func (c *TagKeysClient) UpdateTagKey(ctx context.Context, req *resourcemanagerpb.UpdateTagKeyRequest, opts ...gax.CallOption) (*UpdateTagKeyOperation, error) {
280 return c.internalClient.UpdateTagKey(ctx, req, opts...)
281 }
282
283
284
285 func (c *TagKeysClient) UpdateTagKeyOperation(name string) *UpdateTagKeyOperation {
286 return c.internalClient.UpdateTagKeyOperation(name)
287 }
288
289
290
291 func (c *TagKeysClient) DeleteTagKey(ctx context.Context, req *resourcemanagerpb.DeleteTagKeyRequest, opts ...gax.CallOption) (*DeleteTagKeyOperation, error) {
292 return c.internalClient.DeleteTagKey(ctx, req, opts...)
293 }
294
295
296
297 func (c *TagKeysClient) DeleteTagKeyOperation(name string) *DeleteTagKeyOperation {
298 return c.internalClient.DeleteTagKeyOperation(name)
299 }
300
301
302
303
304
305
306
307 func (c *TagKeysClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
308 return c.internalClient.GetIamPolicy(ctx, req, opts...)
309 }
310
311
312
313
314
315
316 func (c *TagKeysClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
317 return c.internalClient.SetIamPolicy(ctx, req, opts...)
318 }
319
320
321
322
323
324
325 func (c *TagKeysClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
326 return c.internalClient.TestIamPermissions(ctx, req, opts...)
327 }
328
329
330 func (c *TagKeysClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
331 return c.internalClient.GetOperation(ctx, req, opts...)
332 }
333
334
335
336
337 type tagKeysGRPCClient struct {
338
339 connPool gtransport.ConnPool
340
341
342 CallOptions **TagKeysCallOptions
343
344
345 tagKeysClient resourcemanagerpb.TagKeysClient
346
347
348
349
350 LROClient **lroauto.OperationsClient
351
352 operationsClient longrunningpb.OperationsClient
353
354
355 xGoogHeaders []string
356 }
357
358
359
360
361
362 func NewTagKeysClient(ctx context.Context, opts ...option.ClientOption) (*TagKeysClient, error) {
363 clientOpts := defaultTagKeysGRPCClientOptions()
364 if newTagKeysClientHook != nil {
365 hookOpts, err := newTagKeysClientHook(ctx, clientHookParams{})
366 if err != nil {
367 return nil, err
368 }
369 clientOpts = append(clientOpts, hookOpts...)
370 }
371
372 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
373 if err != nil {
374 return nil, err
375 }
376 client := TagKeysClient{CallOptions: defaultTagKeysCallOptions()}
377
378 c := &tagKeysGRPCClient{
379 connPool: connPool,
380 tagKeysClient: resourcemanagerpb.NewTagKeysClient(connPool),
381 CallOptions: &client.CallOptions,
382 operationsClient: longrunningpb.NewOperationsClient(connPool),
383 }
384 c.setGoogleClientInfo()
385
386 client.internalClient = c
387
388 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
389 if err != nil {
390
391
392
393
394
395
396 return nil, err
397 }
398 c.LROClient = &client.LROClient
399 return &client, nil
400 }
401
402
403
404
405
406 func (c *tagKeysGRPCClient) Connection() *grpc.ClientConn {
407 return c.connPool.Conn()
408 }
409
410
411
412
413 func (c *tagKeysGRPCClient) setGoogleClientInfo(keyval ...string) {
414 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
415 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
416 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
417 }
418
419
420
421 func (c *tagKeysGRPCClient) Close() error {
422 return c.connPool.Close()
423 }
424
425
426 type tagKeysRESTClient struct {
427
428 endpoint string
429
430
431 httpClient *http.Client
432
433
434
435
436 LROClient **lroauto.OperationsClient
437
438
439 xGoogHeaders []string
440
441
442 CallOptions **TagKeysCallOptions
443 }
444
445
446
447
448 func NewTagKeysRESTClient(ctx context.Context, opts ...option.ClientOption) (*TagKeysClient, error) {
449 clientOpts := append(defaultTagKeysRESTClientOptions(), opts...)
450 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
451 if err != nil {
452 return nil, err
453 }
454
455 callOpts := defaultTagKeysRESTCallOptions()
456 c := &tagKeysRESTClient{
457 endpoint: endpoint,
458 httpClient: httpClient,
459 CallOptions: &callOpts,
460 }
461 c.setGoogleClientInfo()
462
463 lroOpts := []option.ClientOption{
464 option.WithHTTPClient(httpClient),
465 option.WithEndpoint(endpoint),
466 }
467 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
468 if err != nil {
469 return nil, err
470 }
471 c.LROClient = &opClient
472
473 return &TagKeysClient{internalClient: c, CallOptions: callOpts}, nil
474 }
475
476 func defaultTagKeysRESTClientOptions() []option.ClientOption {
477 return []option.ClientOption{
478 internaloption.WithDefaultEndpoint("https://cloudresourcemanager.googleapis.com"),
479 internaloption.WithDefaultEndpointTemplate("https://cloudresourcemanager.UNIVERSE_DOMAIN"),
480 internaloption.WithDefaultMTLSEndpoint("https://cloudresourcemanager.mtls.googleapis.com"),
481 internaloption.WithDefaultUniverseDomain("googleapis.com"),
482 internaloption.WithDefaultAudience("https://cloudresourcemanager.googleapis.com/"),
483 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
484 }
485 }
486
487
488
489
490 func (c *tagKeysRESTClient) setGoogleClientInfo(keyval ...string) {
491 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
492 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
493 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
494 }
495
496
497
498 func (c *tagKeysRESTClient) Close() error {
499
500 c.httpClient = nil
501 return nil
502 }
503
504
505
506
507 func (c *tagKeysRESTClient) Connection() *grpc.ClientConn {
508 return nil
509 }
510 func (c *tagKeysGRPCClient) ListTagKeys(ctx context.Context, req *resourcemanagerpb.ListTagKeysRequest, opts ...gax.CallOption) *TagKeyIterator {
511 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
512 opts = append((*c.CallOptions).ListTagKeys[0:len((*c.CallOptions).ListTagKeys):len((*c.CallOptions).ListTagKeys)], opts...)
513 it := &TagKeyIterator{}
514 req = proto.Clone(req).(*resourcemanagerpb.ListTagKeysRequest)
515 it.InternalFetch = func(pageSize int, pageToken string) ([]*resourcemanagerpb.TagKey, string, error) {
516 resp := &resourcemanagerpb.ListTagKeysResponse{}
517 if pageToken != "" {
518 req.PageToken = pageToken
519 }
520 if pageSize > math.MaxInt32 {
521 req.PageSize = math.MaxInt32
522 } else if pageSize != 0 {
523 req.PageSize = int32(pageSize)
524 }
525 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
526 var err error
527 resp, err = c.tagKeysClient.ListTagKeys(ctx, req, settings.GRPC...)
528 return err
529 }, opts...)
530 if err != nil {
531 return nil, "", err
532 }
533
534 it.Response = resp
535 return resp.GetTagKeys(), resp.GetNextPageToken(), nil
536 }
537 fetch := func(pageSize int, pageToken string) (string, error) {
538 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
539 if err != nil {
540 return "", err
541 }
542 it.items = append(it.items, items...)
543 return nextPageToken, nil
544 }
545
546 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
547 it.pageInfo.MaxSize = int(req.GetPageSize())
548 it.pageInfo.Token = req.GetPageToken()
549
550 return it
551 }
552
553 func (c *tagKeysGRPCClient) GetTagKey(ctx context.Context, req *resourcemanagerpb.GetTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
554 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
555
556 hds = append(c.xGoogHeaders, hds...)
557 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
558 opts = append((*c.CallOptions).GetTagKey[0:len((*c.CallOptions).GetTagKey):len((*c.CallOptions).GetTagKey)], opts...)
559 var resp *resourcemanagerpb.TagKey
560 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
561 var err error
562 resp, err = c.tagKeysClient.GetTagKey(ctx, req, settings.GRPC...)
563 return err
564 }, opts...)
565 if err != nil {
566 return nil, err
567 }
568 return resp, nil
569 }
570
571 func (c *tagKeysGRPCClient) GetNamespacedTagKey(ctx context.Context, req *resourcemanagerpb.GetNamespacedTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
572 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
573 opts = append((*c.CallOptions).GetNamespacedTagKey[0:len((*c.CallOptions).GetNamespacedTagKey):len((*c.CallOptions).GetNamespacedTagKey)], opts...)
574 var resp *resourcemanagerpb.TagKey
575 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
576 var err error
577 resp, err = c.tagKeysClient.GetNamespacedTagKey(ctx, req, settings.GRPC...)
578 return err
579 }, opts...)
580 if err != nil {
581 return nil, err
582 }
583 return resp, nil
584 }
585
586 func (c *tagKeysGRPCClient) CreateTagKey(ctx context.Context, req *resourcemanagerpb.CreateTagKeyRequest, opts ...gax.CallOption) (*CreateTagKeyOperation, error) {
587 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
588 opts = append((*c.CallOptions).CreateTagKey[0:len((*c.CallOptions).CreateTagKey):len((*c.CallOptions).CreateTagKey)], opts...)
589 var resp *longrunningpb.Operation
590 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
591 var err error
592 resp, err = c.tagKeysClient.CreateTagKey(ctx, req, settings.GRPC...)
593 return err
594 }, opts...)
595 if err != nil {
596 return nil, err
597 }
598 return &CreateTagKeyOperation{
599 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
600 }, nil
601 }
602
603 func (c *tagKeysGRPCClient) UpdateTagKey(ctx context.Context, req *resourcemanagerpb.UpdateTagKeyRequest, opts ...gax.CallOption) (*UpdateTagKeyOperation, error) {
604 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tag_key.name", url.QueryEscape(req.GetTagKey().GetName()))}
605
606 hds = append(c.xGoogHeaders, hds...)
607 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
608 opts = append((*c.CallOptions).UpdateTagKey[0:len((*c.CallOptions).UpdateTagKey):len((*c.CallOptions).UpdateTagKey)], opts...)
609 var resp *longrunningpb.Operation
610 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
611 var err error
612 resp, err = c.tagKeysClient.UpdateTagKey(ctx, req, settings.GRPC...)
613 return err
614 }, opts...)
615 if err != nil {
616 return nil, err
617 }
618 return &UpdateTagKeyOperation{
619 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
620 }, nil
621 }
622
623 func (c *tagKeysGRPCClient) DeleteTagKey(ctx context.Context, req *resourcemanagerpb.DeleteTagKeyRequest, opts ...gax.CallOption) (*DeleteTagKeyOperation, error) {
624 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
625
626 hds = append(c.xGoogHeaders, hds...)
627 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
628 opts = append((*c.CallOptions).DeleteTagKey[0:len((*c.CallOptions).DeleteTagKey):len((*c.CallOptions).DeleteTagKey)], opts...)
629 var resp *longrunningpb.Operation
630 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
631 var err error
632 resp, err = c.tagKeysClient.DeleteTagKey(ctx, req, settings.GRPC...)
633 return err
634 }, opts...)
635 if err != nil {
636 return nil, err
637 }
638 return &DeleteTagKeyOperation{
639 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
640 }, nil
641 }
642
643 func (c *tagKeysGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
644 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
645
646 hds = append(c.xGoogHeaders, hds...)
647 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
648 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
649 var resp *iampb.Policy
650 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
651 var err error
652 resp, err = c.tagKeysClient.GetIamPolicy(ctx, req, settings.GRPC...)
653 return err
654 }, opts...)
655 if err != nil {
656 return nil, err
657 }
658 return resp, nil
659 }
660
661 func (c *tagKeysGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
662 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
663
664 hds = append(c.xGoogHeaders, hds...)
665 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
666 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
667 var resp *iampb.Policy
668 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
669 var err error
670 resp, err = c.tagKeysClient.SetIamPolicy(ctx, req, settings.GRPC...)
671 return err
672 }, opts...)
673 if err != nil {
674 return nil, err
675 }
676 return resp, nil
677 }
678
679 func (c *tagKeysGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
680 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
681
682 hds = append(c.xGoogHeaders, hds...)
683 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
684 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
685 var resp *iampb.TestIamPermissionsResponse
686 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
687 var err error
688 resp, err = c.tagKeysClient.TestIamPermissions(ctx, req, settings.GRPC...)
689 return err
690 }, opts...)
691 if err != nil {
692 return nil, err
693 }
694 return resp, nil
695 }
696
697 func (c *tagKeysGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
698 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
699
700 hds = append(c.xGoogHeaders, hds...)
701 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
702 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
703 var resp *longrunningpb.Operation
704 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
705 var err error
706 resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...)
707 return err
708 }, opts...)
709 if err != nil {
710 return nil, err
711 }
712 return resp, nil
713 }
714
715
716 func (c *tagKeysRESTClient) ListTagKeys(ctx context.Context, req *resourcemanagerpb.ListTagKeysRequest, opts ...gax.CallOption) *TagKeyIterator {
717 it := &TagKeyIterator{}
718 req = proto.Clone(req).(*resourcemanagerpb.ListTagKeysRequest)
719 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
720 it.InternalFetch = func(pageSize int, pageToken string) ([]*resourcemanagerpb.TagKey, string, error) {
721 resp := &resourcemanagerpb.ListTagKeysResponse{}
722 if pageToken != "" {
723 req.PageToken = pageToken
724 }
725 if pageSize > math.MaxInt32 {
726 req.PageSize = math.MaxInt32
727 } else if pageSize != 0 {
728 req.PageSize = int32(pageSize)
729 }
730 baseUrl, err := url.Parse(c.endpoint)
731 if err != nil {
732 return nil, "", err
733 }
734 baseUrl.Path += fmt.Sprintf("/v3/tagKeys")
735
736 params := url.Values{}
737 params.Add("$alt", "json;enum-encoding=int")
738 if req.GetPageSize() != 0 {
739 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
740 }
741 if req.GetPageToken() != "" {
742 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
743 }
744 params.Add("parent", fmt.Sprintf("%v", req.GetParent()))
745
746 baseUrl.RawQuery = params.Encode()
747
748
749 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
750 headers := gax.BuildHeaders(ctx, hds...)
751 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
752 if settings.Path != "" {
753 baseUrl.Path = settings.Path
754 }
755 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
756 if err != nil {
757 return err
758 }
759 httpReq.Header = headers
760
761 httpRsp, err := c.httpClient.Do(httpReq)
762 if err != nil {
763 return err
764 }
765 defer httpRsp.Body.Close()
766
767 if err = googleapi.CheckResponse(httpRsp); err != nil {
768 return err
769 }
770
771 buf, err := io.ReadAll(httpRsp.Body)
772 if err != nil {
773 return err
774 }
775
776 if err := unm.Unmarshal(buf, resp); err != nil {
777 return err
778 }
779
780 return nil
781 }, opts...)
782 if e != nil {
783 return nil, "", e
784 }
785 it.Response = resp
786 return resp.GetTagKeys(), resp.GetNextPageToken(), nil
787 }
788
789 fetch := func(pageSize int, pageToken string) (string, error) {
790 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
791 if err != nil {
792 return "", err
793 }
794 it.items = append(it.items, items...)
795 return nextPageToken, nil
796 }
797
798 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
799 it.pageInfo.MaxSize = int(req.GetPageSize())
800 it.pageInfo.Token = req.GetPageToken()
801
802 return it
803 }
804
805
806
807 func (c *tagKeysRESTClient) GetTagKey(ctx context.Context, req *resourcemanagerpb.GetTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
808 baseUrl, err := url.Parse(c.endpoint)
809 if err != nil {
810 return nil, err
811 }
812 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetName())
813
814 params := url.Values{}
815 params.Add("$alt", "json;enum-encoding=int")
816
817 baseUrl.RawQuery = params.Encode()
818
819
820 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
821
822 hds = append(c.xGoogHeaders, hds...)
823 hds = append(hds, "Content-Type", "application/json")
824 headers := gax.BuildHeaders(ctx, hds...)
825 opts = append((*c.CallOptions).GetTagKey[0:len((*c.CallOptions).GetTagKey):len((*c.CallOptions).GetTagKey)], opts...)
826 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
827 resp := &resourcemanagerpb.TagKey{}
828 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
829 if settings.Path != "" {
830 baseUrl.Path = settings.Path
831 }
832 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
833 if err != nil {
834 return err
835 }
836 httpReq = httpReq.WithContext(ctx)
837 httpReq.Header = headers
838
839 httpRsp, err := c.httpClient.Do(httpReq)
840 if err != nil {
841 return err
842 }
843 defer httpRsp.Body.Close()
844
845 if err = googleapi.CheckResponse(httpRsp); err != nil {
846 return err
847 }
848
849 buf, err := io.ReadAll(httpRsp.Body)
850 if err != nil {
851 return err
852 }
853
854 if err := unm.Unmarshal(buf, resp); err != nil {
855 return err
856 }
857
858 return nil
859 }, opts...)
860 if e != nil {
861 return nil, e
862 }
863 return resp, nil
864 }
865
866
867
868
869 func (c *tagKeysRESTClient) GetNamespacedTagKey(ctx context.Context, req *resourcemanagerpb.GetNamespacedTagKeyRequest, opts ...gax.CallOption) (*resourcemanagerpb.TagKey, error) {
870 baseUrl, err := url.Parse(c.endpoint)
871 if err != nil {
872 return nil, err
873 }
874 baseUrl.Path += fmt.Sprintf("/v3/tagKeys/namespaced")
875
876 params := url.Values{}
877 params.Add("$alt", "json;enum-encoding=int")
878 params.Add("name", fmt.Sprintf("%v", req.GetName()))
879
880 baseUrl.RawQuery = params.Encode()
881
882
883 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
884 headers := gax.BuildHeaders(ctx, hds...)
885 opts = append((*c.CallOptions).GetNamespacedTagKey[0:len((*c.CallOptions).GetNamespacedTagKey):len((*c.CallOptions).GetNamespacedTagKey)], opts...)
886 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
887 resp := &resourcemanagerpb.TagKey{}
888 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
889 if settings.Path != "" {
890 baseUrl.Path = settings.Path
891 }
892 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
893 if err != nil {
894 return err
895 }
896 httpReq = httpReq.WithContext(ctx)
897 httpReq.Header = headers
898
899 httpRsp, err := c.httpClient.Do(httpReq)
900 if err != nil {
901 return err
902 }
903 defer httpRsp.Body.Close()
904
905 if err = googleapi.CheckResponse(httpRsp); err != nil {
906 return err
907 }
908
909 buf, err := io.ReadAll(httpRsp.Body)
910 if err != nil {
911 return err
912 }
913
914 if err := unm.Unmarshal(buf, resp); err != nil {
915 return err
916 }
917
918 return nil
919 }, opts...)
920 if e != nil {
921 return nil, e
922 }
923 return resp, nil
924 }
925
926
927
928
929
930 func (c *tagKeysRESTClient) CreateTagKey(ctx context.Context, req *resourcemanagerpb.CreateTagKeyRequest, opts ...gax.CallOption) (*CreateTagKeyOperation, error) {
931 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
932 body := req.GetTagKey()
933 jsonReq, err := m.Marshal(body)
934 if err != nil {
935 return nil, err
936 }
937
938 baseUrl, err := url.Parse(c.endpoint)
939 if err != nil {
940 return nil, err
941 }
942 baseUrl.Path += fmt.Sprintf("/v3/tagKeys")
943
944 params := url.Values{}
945 params.Add("$alt", "json;enum-encoding=int")
946 if req.GetValidateOnly() {
947 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
948 }
949
950 baseUrl.RawQuery = params.Encode()
951
952
953 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
954 headers := gax.BuildHeaders(ctx, hds...)
955 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
956 resp := &longrunningpb.Operation{}
957 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
958 if settings.Path != "" {
959 baseUrl.Path = settings.Path
960 }
961 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
962 if err != nil {
963 return err
964 }
965 httpReq = httpReq.WithContext(ctx)
966 httpReq.Header = headers
967
968 httpRsp, err := c.httpClient.Do(httpReq)
969 if err != nil {
970 return err
971 }
972 defer httpRsp.Body.Close()
973
974 if err = googleapi.CheckResponse(httpRsp); err != nil {
975 return err
976 }
977
978 buf, err := io.ReadAll(httpRsp.Body)
979 if err != nil {
980 return err
981 }
982
983 if err := unm.Unmarshal(buf, resp); err != nil {
984 return err
985 }
986
987 return nil
988 }, opts...)
989 if e != nil {
990 return nil, e
991 }
992
993 override := fmt.Sprintf("/v3/%s", resp.GetName())
994 return &CreateTagKeyOperation{
995 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
996 pollPath: override,
997 }, nil
998 }
999
1000
1001 func (c *tagKeysRESTClient) UpdateTagKey(ctx context.Context, req *resourcemanagerpb.UpdateTagKeyRequest, opts ...gax.CallOption) (*UpdateTagKeyOperation, error) {
1002 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1003 body := req.GetTagKey()
1004 jsonReq, err := m.Marshal(body)
1005 if err != nil {
1006 return nil, err
1007 }
1008
1009 baseUrl, err := url.Parse(c.endpoint)
1010 if err != nil {
1011 return nil, err
1012 }
1013 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetTagKey().GetName())
1014
1015 params := url.Values{}
1016 params.Add("$alt", "json;enum-encoding=int")
1017 if req.GetUpdateMask() != nil {
1018 updateMask, err := protojson.Marshal(req.GetUpdateMask())
1019 if err != nil {
1020 return nil, err
1021 }
1022 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
1023 }
1024 if req.GetValidateOnly() {
1025 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
1026 }
1027
1028 baseUrl.RawQuery = params.Encode()
1029
1030
1031 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tag_key.name", url.QueryEscape(req.GetTagKey().GetName()))}
1032
1033 hds = append(c.xGoogHeaders, hds...)
1034 hds = append(hds, "Content-Type", "application/json")
1035 headers := gax.BuildHeaders(ctx, hds...)
1036 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1037 resp := &longrunningpb.Operation{}
1038 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1039 if settings.Path != "" {
1040 baseUrl.Path = settings.Path
1041 }
1042 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1043 if err != nil {
1044 return err
1045 }
1046 httpReq = httpReq.WithContext(ctx)
1047 httpReq.Header = headers
1048
1049 httpRsp, err := c.httpClient.Do(httpReq)
1050 if err != nil {
1051 return err
1052 }
1053 defer httpRsp.Body.Close()
1054
1055 if err = googleapi.CheckResponse(httpRsp); err != nil {
1056 return err
1057 }
1058
1059 buf, err := io.ReadAll(httpRsp.Body)
1060 if err != nil {
1061 return err
1062 }
1063
1064 if err := unm.Unmarshal(buf, resp); err != nil {
1065 return err
1066 }
1067
1068 return nil
1069 }, opts...)
1070 if e != nil {
1071 return nil, e
1072 }
1073
1074 override := fmt.Sprintf("/v3/%s", resp.GetName())
1075 return &UpdateTagKeyOperation{
1076 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1077 pollPath: override,
1078 }, nil
1079 }
1080
1081
1082
1083 func (c *tagKeysRESTClient) DeleteTagKey(ctx context.Context, req *resourcemanagerpb.DeleteTagKeyRequest, opts ...gax.CallOption) (*DeleteTagKeyOperation, error) {
1084 baseUrl, err := url.Parse(c.endpoint)
1085 if err != nil {
1086 return nil, err
1087 }
1088 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetName())
1089
1090 params := url.Values{}
1091 params.Add("$alt", "json;enum-encoding=int")
1092 if req.GetEtag() != "" {
1093 params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
1094 }
1095 if req.GetValidateOnly() {
1096 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
1097 }
1098
1099 baseUrl.RawQuery = params.Encode()
1100
1101
1102 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1103
1104 hds = append(c.xGoogHeaders, hds...)
1105 hds = append(hds, "Content-Type", "application/json")
1106 headers := gax.BuildHeaders(ctx, hds...)
1107 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1108 resp := &longrunningpb.Operation{}
1109 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1110 if settings.Path != "" {
1111 baseUrl.Path = settings.Path
1112 }
1113 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1114 if err != nil {
1115 return err
1116 }
1117 httpReq = httpReq.WithContext(ctx)
1118 httpReq.Header = headers
1119
1120 httpRsp, err := c.httpClient.Do(httpReq)
1121 if err != nil {
1122 return err
1123 }
1124 defer httpRsp.Body.Close()
1125
1126 if err = googleapi.CheckResponse(httpRsp); err != nil {
1127 return err
1128 }
1129
1130 buf, err := io.ReadAll(httpRsp.Body)
1131 if err != nil {
1132 return err
1133 }
1134
1135 if err := unm.Unmarshal(buf, resp); err != nil {
1136 return err
1137 }
1138
1139 return nil
1140 }, opts...)
1141 if e != nil {
1142 return nil, e
1143 }
1144
1145 override := fmt.Sprintf("/v3/%s", resp.GetName())
1146 return &DeleteTagKeyOperation{
1147 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1148 pollPath: override,
1149 }, nil
1150 }
1151
1152
1153
1154
1155
1156
1157
1158 func (c *tagKeysRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1159 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1160 jsonReq, err := m.Marshal(req)
1161 if err != nil {
1162 return nil, err
1163 }
1164
1165 baseUrl, err := url.Parse(c.endpoint)
1166 if err != nil {
1167 return nil, err
1168 }
1169 baseUrl.Path += fmt.Sprintf("/v3/%v:getIamPolicy", req.GetResource())
1170
1171 params := url.Values{}
1172 params.Add("$alt", "json;enum-encoding=int")
1173
1174 baseUrl.RawQuery = params.Encode()
1175
1176
1177 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1178
1179 hds = append(c.xGoogHeaders, hds...)
1180 hds = append(hds, "Content-Type", "application/json")
1181 headers := gax.BuildHeaders(ctx, hds...)
1182 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1183 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1184 resp := &iampb.Policy{}
1185 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1186 if settings.Path != "" {
1187 baseUrl.Path = settings.Path
1188 }
1189 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1190 if err != nil {
1191 return err
1192 }
1193 httpReq = httpReq.WithContext(ctx)
1194 httpReq.Header = headers
1195
1196 httpRsp, err := c.httpClient.Do(httpReq)
1197 if err != nil {
1198 return err
1199 }
1200 defer httpRsp.Body.Close()
1201
1202 if err = googleapi.CheckResponse(httpRsp); err != nil {
1203 return err
1204 }
1205
1206 buf, err := io.ReadAll(httpRsp.Body)
1207 if err != nil {
1208 return err
1209 }
1210
1211 if err := unm.Unmarshal(buf, resp); err != nil {
1212 return err
1213 }
1214
1215 return nil
1216 }, opts...)
1217 if e != nil {
1218 return nil, e
1219 }
1220 return resp, nil
1221 }
1222
1223
1224
1225
1226
1227
1228 func (c *tagKeysRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1229 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1230 jsonReq, err := m.Marshal(req)
1231 if err != nil {
1232 return nil, err
1233 }
1234
1235 baseUrl, err := url.Parse(c.endpoint)
1236 if err != nil {
1237 return nil, err
1238 }
1239 baseUrl.Path += fmt.Sprintf("/v3/%v:setIamPolicy", req.GetResource())
1240
1241 params := url.Values{}
1242 params.Add("$alt", "json;enum-encoding=int")
1243
1244 baseUrl.RawQuery = params.Encode()
1245
1246
1247 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1248
1249 hds = append(c.xGoogHeaders, hds...)
1250 hds = append(hds, "Content-Type", "application/json")
1251 headers := gax.BuildHeaders(ctx, hds...)
1252 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1253 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1254 resp := &iampb.Policy{}
1255 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1256 if settings.Path != "" {
1257 baseUrl.Path = settings.Path
1258 }
1259 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1260 if err != nil {
1261 return err
1262 }
1263 httpReq = httpReq.WithContext(ctx)
1264 httpReq.Header = headers
1265
1266 httpRsp, err := c.httpClient.Do(httpReq)
1267 if err != nil {
1268 return err
1269 }
1270 defer httpRsp.Body.Close()
1271
1272 if err = googleapi.CheckResponse(httpRsp); err != nil {
1273 return err
1274 }
1275
1276 buf, err := io.ReadAll(httpRsp.Body)
1277 if err != nil {
1278 return err
1279 }
1280
1281 if err := unm.Unmarshal(buf, resp); err != nil {
1282 return err
1283 }
1284
1285 return nil
1286 }, opts...)
1287 if e != nil {
1288 return nil, e
1289 }
1290 return resp, nil
1291 }
1292
1293
1294
1295
1296
1297
1298 func (c *tagKeysRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1299 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1300 jsonReq, err := m.Marshal(req)
1301 if err != nil {
1302 return nil, err
1303 }
1304
1305 baseUrl, err := url.Parse(c.endpoint)
1306 if err != nil {
1307 return nil, err
1308 }
1309 baseUrl.Path += fmt.Sprintf("/v3/%v:testIamPermissions", req.GetResource())
1310
1311 params := url.Values{}
1312 params.Add("$alt", "json;enum-encoding=int")
1313
1314 baseUrl.RawQuery = params.Encode()
1315
1316
1317 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1318
1319 hds = append(c.xGoogHeaders, hds...)
1320 hds = append(hds, "Content-Type", "application/json")
1321 headers := gax.BuildHeaders(ctx, hds...)
1322 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1323 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1324 resp := &iampb.TestIamPermissionsResponse{}
1325 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1326 if settings.Path != "" {
1327 baseUrl.Path = settings.Path
1328 }
1329 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1330 if err != nil {
1331 return err
1332 }
1333 httpReq = httpReq.WithContext(ctx)
1334 httpReq.Header = headers
1335
1336 httpRsp, err := c.httpClient.Do(httpReq)
1337 if err != nil {
1338 return err
1339 }
1340 defer httpRsp.Body.Close()
1341
1342 if err = googleapi.CheckResponse(httpRsp); err != nil {
1343 return err
1344 }
1345
1346 buf, err := io.ReadAll(httpRsp.Body)
1347 if err != nil {
1348 return err
1349 }
1350
1351 if err := unm.Unmarshal(buf, resp); err != nil {
1352 return err
1353 }
1354
1355 return nil
1356 }, opts...)
1357 if e != nil {
1358 return nil, e
1359 }
1360 return resp, nil
1361 }
1362
1363
1364 func (c *tagKeysRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1365 baseUrl, err := url.Parse(c.endpoint)
1366 if err != nil {
1367 return nil, err
1368 }
1369 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetName())
1370
1371 params := url.Values{}
1372 params.Add("$alt", "json;enum-encoding=int")
1373
1374 baseUrl.RawQuery = params.Encode()
1375
1376
1377 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1378
1379 hds = append(c.xGoogHeaders, hds...)
1380 hds = append(hds, "Content-Type", "application/json")
1381 headers := gax.BuildHeaders(ctx, hds...)
1382 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1383 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1384 resp := &longrunningpb.Operation{}
1385 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1386 if settings.Path != "" {
1387 baseUrl.Path = settings.Path
1388 }
1389 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1390 if err != nil {
1391 return err
1392 }
1393 httpReq = httpReq.WithContext(ctx)
1394 httpReq.Header = headers
1395
1396 httpRsp, err := c.httpClient.Do(httpReq)
1397 if err != nil {
1398 return err
1399 }
1400 defer httpRsp.Body.Close()
1401
1402 if err = googleapi.CheckResponse(httpRsp); err != nil {
1403 return err
1404 }
1405
1406 buf, err := io.ReadAll(httpRsp.Body)
1407 if err != nil {
1408 return err
1409 }
1410
1411 if err := unm.Unmarshal(buf, resp); err != nil {
1412 return err
1413 }
1414
1415 return nil
1416 }, opts...)
1417 if e != nil {
1418 return nil, e
1419 }
1420 return resp, nil
1421 }
1422
1423
1424
1425 func (c *tagKeysGRPCClient) CreateTagKeyOperation(name string) *CreateTagKeyOperation {
1426 return &CreateTagKeyOperation{
1427 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1428 }
1429 }
1430
1431
1432
1433 func (c *tagKeysRESTClient) CreateTagKeyOperation(name string) *CreateTagKeyOperation {
1434 override := fmt.Sprintf("/v3/%s", name)
1435 return &CreateTagKeyOperation{
1436 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1437 pollPath: override,
1438 }
1439 }
1440
1441
1442
1443 func (c *tagKeysGRPCClient) DeleteTagKeyOperation(name string) *DeleteTagKeyOperation {
1444 return &DeleteTagKeyOperation{
1445 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1446 }
1447 }
1448
1449
1450
1451 func (c *tagKeysRESTClient) DeleteTagKeyOperation(name string) *DeleteTagKeyOperation {
1452 override := fmt.Sprintf("/v3/%s", name)
1453 return &DeleteTagKeyOperation{
1454 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1455 pollPath: override,
1456 }
1457 }
1458
1459
1460
1461 func (c *tagKeysGRPCClient) UpdateTagKeyOperation(name string) *UpdateTagKeyOperation {
1462 return &UpdateTagKeyOperation{
1463 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1464 }
1465 }
1466
1467
1468
1469 func (c *tagKeysRESTClient) UpdateTagKeyOperation(name string) *UpdateTagKeyOperation {
1470 override := fmt.Sprintf("/v3/%s", name)
1471 return &UpdateTagKeyOperation{
1472 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1473 pollPath: override,
1474 }
1475 }
1476
View as plain text