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
28 "cloud.google.com/go/longrunning"
29 lroauto "cloud.google.com/go/longrunning/autogen"
30 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
31 resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb"
32 gax "github.com/googleapis/gax-go/v2"
33 "google.golang.org/api/googleapi"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 "google.golang.org/grpc"
40 "google.golang.org/protobuf/encoding/protojson"
41 "google.golang.org/protobuf/proto"
42 )
43
44 var newTagHoldsClientHook clientHook
45
46
47 type TagHoldsCallOptions struct {
48 CreateTagHold []gax.CallOption
49 DeleteTagHold []gax.CallOption
50 ListTagHolds []gax.CallOption
51 GetOperation []gax.CallOption
52 }
53
54 func defaultTagHoldsGRPCClientOptions() []option.ClientOption {
55 return []option.ClientOption{
56 internaloption.WithDefaultEndpoint("cloudresourcemanager.googleapis.com:443"),
57 internaloption.WithDefaultEndpointTemplate("cloudresourcemanager.UNIVERSE_DOMAIN:443"),
58 internaloption.WithDefaultMTLSEndpoint("cloudresourcemanager.mtls.googleapis.com:443"),
59 internaloption.WithDefaultUniverseDomain("googleapis.com"),
60 internaloption.WithDefaultAudience("https://cloudresourcemanager.googleapis.com/"),
61 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
62 internaloption.EnableJwtWithScope(),
63 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
64 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
65 }
66 }
67
68 func defaultTagHoldsCallOptions() *TagHoldsCallOptions {
69 return &TagHoldsCallOptions{
70 CreateTagHold: []gax.CallOption{},
71 DeleteTagHold: []gax.CallOption{},
72 ListTagHolds: []gax.CallOption{},
73 GetOperation: []gax.CallOption{},
74 }
75 }
76
77 func defaultTagHoldsRESTCallOptions() *TagHoldsCallOptions {
78 return &TagHoldsCallOptions{
79 CreateTagHold: []gax.CallOption{},
80 DeleteTagHold: []gax.CallOption{},
81 ListTagHolds: []gax.CallOption{},
82 GetOperation: []gax.CallOption{},
83 }
84 }
85
86
87 type internalTagHoldsClient interface {
88 Close() error
89 setGoogleClientInfo(...string)
90 Connection() *grpc.ClientConn
91 CreateTagHold(context.Context, *resourcemanagerpb.CreateTagHoldRequest, ...gax.CallOption) (*CreateTagHoldOperation, error)
92 CreateTagHoldOperation(name string) *CreateTagHoldOperation
93 DeleteTagHold(context.Context, *resourcemanagerpb.DeleteTagHoldRequest, ...gax.CallOption) (*DeleteTagHoldOperation, error)
94 DeleteTagHoldOperation(name string) *DeleteTagHoldOperation
95 ListTagHolds(context.Context, *resourcemanagerpb.ListTagHoldsRequest, ...gax.CallOption) *TagHoldIterator
96 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
97 }
98
99
100
101
102
103
104
105
106
107 type TagHoldsClient struct {
108
109 internalClient internalTagHoldsClient
110
111
112 CallOptions *TagHoldsCallOptions
113
114
115
116
117 LROClient *lroauto.OperationsClient
118 }
119
120
121
122
123
124 func (c *TagHoldsClient) Close() error {
125 return c.internalClient.Close()
126 }
127
128
129
130
131 func (c *TagHoldsClient) setGoogleClientInfo(keyval ...string) {
132 c.internalClient.setGoogleClientInfo(keyval...)
133 }
134
135
136
137
138
139 func (c *TagHoldsClient) Connection() *grpc.ClientConn {
140 return c.internalClient.Connection()
141 }
142
143
144
145 func (c *TagHoldsClient) CreateTagHold(ctx context.Context, req *resourcemanagerpb.CreateTagHoldRequest, opts ...gax.CallOption) (*CreateTagHoldOperation, error) {
146 return c.internalClient.CreateTagHold(ctx, req, opts...)
147 }
148
149
150
151 func (c *TagHoldsClient) CreateTagHoldOperation(name string) *CreateTagHoldOperation {
152 return c.internalClient.CreateTagHoldOperation(name)
153 }
154
155
156 func (c *TagHoldsClient) DeleteTagHold(ctx context.Context, req *resourcemanagerpb.DeleteTagHoldRequest, opts ...gax.CallOption) (*DeleteTagHoldOperation, error) {
157 return c.internalClient.DeleteTagHold(ctx, req, opts...)
158 }
159
160
161
162 func (c *TagHoldsClient) DeleteTagHoldOperation(name string) *DeleteTagHoldOperation {
163 return c.internalClient.DeleteTagHoldOperation(name)
164 }
165
166
167 func (c *TagHoldsClient) ListTagHolds(ctx context.Context, req *resourcemanagerpb.ListTagHoldsRequest, opts ...gax.CallOption) *TagHoldIterator {
168 return c.internalClient.ListTagHolds(ctx, req, opts...)
169 }
170
171
172 func (c *TagHoldsClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
173 return c.internalClient.GetOperation(ctx, req, opts...)
174 }
175
176
177
178
179 type tagHoldsGRPCClient struct {
180
181 connPool gtransport.ConnPool
182
183
184 CallOptions **TagHoldsCallOptions
185
186
187 tagHoldsClient resourcemanagerpb.TagHoldsClient
188
189
190
191
192 LROClient **lroauto.OperationsClient
193
194 operationsClient longrunningpb.OperationsClient
195
196
197 xGoogHeaders []string
198 }
199
200
201
202
203
204
205
206
207
208 func NewTagHoldsClient(ctx context.Context, opts ...option.ClientOption) (*TagHoldsClient, error) {
209 clientOpts := defaultTagHoldsGRPCClientOptions()
210 if newTagHoldsClientHook != nil {
211 hookOpts, err := newTagHoldsClientHook(ctx, clientHookParams{})
212 if err != nil {
213 return nil, err
214 }
215 clientOpts = append(clientOpts, hookOpts...)
216 }
217
218 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
219 if err != nil {
220 return nil, err
221 }
222 client := TagHoldsClient{CallOptions: defaultTagHoldsCallOptions()}
223
224 c := &tagHoldsGRPCClient{
225 connPool: connPool,
226 tagHoldsClient: resourcemanagerpb.NewTagHoldsClient(connPool),
227 CallOptions: &client.CallOptions,
228 operationsClient: longrunningpb.NewOperationsClient(connPool),
229 }
230 c.setGoogleClientInfo()
231
232 client.internalClient = c
233
234 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
235 if err != nil {
236
237
238
239
240
241
242 return nil, err
243 }
244 c.LROClient = &client.LROClient
245 return &client, nil
246 }
247
248
249
250
251
252 func (c *tagHoldsGRPCClient) Connection() *grpc.ClientConn {
253 return c.connPool.Conn()
254 }
255
256
257
258
259 func (c *tagHoldsGRPCClient) setGoogleClientInfo(keyval ...string) {
260 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
261 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
262 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
263 }
264
265
266
267 func (c *tagHoldsGRPCClient) Close() error {
268 return c.connPool.Close()
269 }
270
271
272 type tagHoldsRESTClient struct {
273
274 endpoint string
275
276
277 httpClient *http.Client
278
279
280
281
282 LROClient **lroauto.OperationsClient
283
284
285 xGoogHeaders []string
286
287
288 CallOptions **TagHoldsCallOptions
289 }
290
291
292
293
294
295
296
297
298 func NewTagHoldsRESTClient(ctx context.Context, opts ...option.ClientOption) (*TagHoldsClient, error) {
299 clientOpts := append(defaultTagHoldsRESTClientOptions(), opts...)
300 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
301 if err != nil {
302 return nil, err
303 }
304
305 callOpts := defaultTagHoldsRESTCallOptions()
306 c := &tagHoldsRESTClient{
307 endpoint: endpoint,
308 httpClient: httpClient,
309 CallOptions: &callOpts,
310 }
311 c.setGoogleClientInfo()
312
313 lroOpts := []option.ClientOption{
314 option.WithHTTPClient(httpClient),
315 option.WithEndpoint(endpoint),
316 }
317 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
318 if err != nil {
319 return nil, err
320 }
321 c.LROClient = &opClient
322
323 return &TagHoldsClient{internalClient: c, CallOptions: callOpts}, nil
324 }
325
326 func defaultTagHoldsRESTClientOptions() []option.ClientOption {
327 return []option.ClientOption{
328 internaloption.WithDefaultEndpoint("https://cloudresourcemanager.googleapis.com"),
329 internaloption.WithDefaultEndpointTemplate("https://cloudresourcemanager.UNIVERSE_DOMAIN"),
330 internaloption.WithDefaultMTLSEndpoint("https://cloudresourcemanager.mtls.googleapis.com"),
331 internaloption.WithDefaultUniverseDomain("googleapis.com"),
332 internaloption.WithDefaultAudience("https://cloudresourcemanager.googleapis.com/"),
333 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
334 }
335 }
336
337
338
339
340 func (c *tagHoldsRESTClient) setGoogleClientInfo(keyval ...string) {
341 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
342 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
343 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
344 }
345
346
347
348 func (c *tagHoldsRESTClient) Close() error {
349
350 c.httpClient = nil
351 return nil
352 }
353
354
355
356
357 func (c *tagHoldsRESTClient) Connection() *grpc.ClientConn {
358 return nil
359 }
360 func (c *tagHoldsGRPCClient) CreateTagHold(ctx context.Context, req *resourcemanagerpb.CreateTagHoldRequest, opts ...gax.CallOption) (*CreateTagHoldOperation, error) {
361 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
362
363 hds = append(c.xGoogHeaders, hds...)
364 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
365 opts = append((*c.CallOptions).CreateTagHold[0:len((*c.CallOptions).CreateTagHold):len((*c.CallOptions).CreateTagHold)], opts...)
366 var resp *longrunningpb.Operation
367 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
368 var err error
369 resp, err = c.tagHoldsClient.CreateTagHold(ctx, req, settings.GRPC...)
370 return err
371 }, opts...)
372 if err != nil {
373 return nil, err
374 }
375 return &CreateTagHoldOperation{
376 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
377 }, nil
378 }
379
380 func (c *tagHoldsGRPCClient) DeleteTagHold(ctx context.Context, req *resourcemanagerpb.DeleteTagHoldRequest, opts ...gax.CallOption) (*DeleteTagHoldOperation, error) {
381 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
382
383 hds = append(c.xGoogHeaders, hds...)
384 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
385 opts = append((*c.CallOptions).DeleteTagHold[0:len((*c.CallOptions).DeleteTagHold):len((*c.CallOptions).DeleteTagHold)], opts...)
386 var resp *longrunningpb.Operation
387 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
388 var err error
389 resp, err = c.tagHoldsClient.DeleteTagHold(ctx, req, settings.GRPC...)
390 return err
391 }, opts...)
392 if err != nil {
393 return nil, err
394 }
395 return &DeleteTagHoldOperation{
396 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
397 }, nil
398 }
399
400 func (c *tagHoldsGRPCClient) ListTagHolds(ctx context.Context, req *resourcemanagerpb.ListTagHoldsRequest, opts ...gax.CallOption) *TagHoldIterator {
401 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
402
403 hds = append(c.xGoogHeaders, hds...)
404 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
405 opts = append((*c.CallOptions).ListTagHolds[0:len((*c.CallOptions).ListTagHolds):len((*c.CallOptions).ListTagHolds)], opts...)
406 it := &TagHoldIterator{}
407 req = proto.Clone(req).(*resourcemanagerpb.ListTagHoldsRequest)
408 it.InternalFetch = func(pageSize int, pageToken string) ([]*resourcemanagerpb.TagHold, string, error) {
409 resp := &resourcemanagerpb.ListTagHoldsResponse{}
410 if pageToken != "" {
411 req.PageToken = pageToken
412 }
413 if pageSize > math.MaxInt32 {
414 req.PageSize = math.MaxInt32
415 } else if pageSize != 0 {
416 req.PageSize = int32(pageSize)
417 }
418 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
419 var err error
420 resp, err = c.tagHoldsClient.ListTagHolds(ctx, req, settings.GRPC...)
421 return err
422 }, opts...)
423 if err != nil {
424 return nil, "", err
425 }
426
427 it.Response = resp
428 return resp.GetTagHolds(), resp.GetNextPageToken(), nil
429 }
430 fetch := func(pageSize int, pageToken string) (string, error) {
431 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
432 if err != nil {
433 return "", err
434 }
435 it.items = append(it.items, items...)
436 return nextPageToken, nil
437 }
438
439 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
440 it.pageInfo.MaxSize = int(req.GetPageSize())
441 it.pageInfo.Token = req.GetPageToken()
442
443 return it
444 }
445
446 func (c *tagHoldsGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
447 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
448
449 hds = append(c.xGoogHeaders, hds...)
450 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
451 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
452 var resp *longrunningpb.Operation
453 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
454 var err error
455 resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...)
456 return err
457 }, opts...)
458 if err != nil {
459 return nil, err
460 }
461 return resp, nil
462 }
463
464
465
466 func (c *tagHoldsRESTClient) CreateTagHold(ctx context.Context, req *resourcemanagerpb.CreateTagHoldRequest, opts ...gax.CallOption) (*CreateTagHoldOperation, error) {
467 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
468 body := req.GetTagHold()
469 jsonReq, err := m.Marshal(body)
470 if err != nil {
471 return nil, err
472 }
473
474 baseUrl, err := url.Parse(c.endpoint)
475 if err != nil {
476 return nil, err
477 }
478 baseUrl.Path += fmt.Sprintf("/v3/%v/tagHolds", req.GetParent())
479
480 params := url.Values{}
481 params.Add("$alt", "json;enum-encoding=int")
482 if req.GetValidateOnly() {
483 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
484 }
485
486 baseUrl.RawQuery = params.Encode()
487
488
489 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
490
491 hds = append(c.xGoogHeaders, hds...)
492 hds = append(hds, "Content-Type", "application/json")
493 headers := gax.BuildHeaders(ctx, hds...)
494 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
495 resp := &longrunningpb.Operation{}
496 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
497 if settings.Path != "" {
498 baseUrl.Path = settings.Path
499 }
500 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
501 if err != nil {
502 return err
503 }
504 httpReq = httpReq.WithContext(ctx)
505 httpReq.Header = headers
506
507 httpRsp, err := c.httpClient.Do(httpReq)
508 if err != nil {
509 return err
510 }
511 defer httpRsp.Body.Close()
512
513 if err = googleapi.CheckResponse(httpRsp); err != nil {
514 return err
515 }
516
517 buf, err := io.ReadAll(httpRsp.Body)
518 if err != nil {
519 return err
520 }
521
522 if err := unm.Unmarshal(buf, resp); err != nil {
523 return err
524 }
525
526 return nil
527 }, opts...)
528 if e != nil {
529 return nil, e
530 }
531
532 override := fmt.Sprintf("/v3/%s", resp.GetName())
533 return &CreateTagHoldOperation{
534 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
535 pollPath: override,
536 }, nil
537 }
538
539
540 func (c *tagHoldsRESTClient) DeleteTagHold(ctx context.Context, req *resourcemanagerpb.DeleteTagHoldRequest, opts ...gax.CallOption) (*DeleteTagHoldOperation, error) {
541 baseUrl, err := url.Parse(c.endpoint)
542 if err != nil {
543 return nil, err
544 }
545 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetName())
546
547 params := url.Values{}
548 params.Add("$alt", "json;enum-encoding=int")
549 if req.GetValidateOnly() {
550 params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
551 }
552
553 baseUrl.RawQuery = params.Encode()
554
555
556 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
557
558 hds = append(c.xGoogHeaders, hds...)
559 hds = append(hds, "Content-Type", "application/json")
560 headers := gax.BuildHeaders(ctx, hds...)
561 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
562 resp := &longrunningpb.Operation{}
563 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
564 if settings.Path != "" {
565 baseUrl.Path = settings.Path
566 }
567 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
568 if err != nil {
569 return err
570 }
571 httpReq = httpReq.WithContext(ctx)
572 httpReq.Header = headers
573
574 httpRsp, err := c.httpClient.Do(httpReq)
575 if err != nil {
576 return err
577 }
578 defer httpRsp.Body.Close()
579
580 if err = googleapi.CheckResponse(httpRsp); err != nil {
581 return err
582 }
583
584 buf, err := io.ReadAll(httpRsp.Body)
585 if err != nil {
586 return err
587 }
588
589 if err := unm.Unmarshal(buf, resp); err != nil {
590 return err
591 }
592
593 return nil
594 }, opts...)
595 if e != nil {
596 return nil, e
597 }
598
599 override := fmt.Sprintf("/v3/%s", resp.GetName())
600 return &DeleteTagHoldOperation{
601 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
602 pollPath: override,
603 }, nil
604 }
605
606
607 func (c *tagHoldsRESTClient) ListTagHolds(ctx context.Context, req *resourcemanagerpb.ListTagHoldsRequest, opts ...gax.CallOption) *TagHoldIterator {
608 it := &TagHoldIterator{}
609 req = proto.Clone(req).(*resourcemanagerpb.ListTagHoldsRequest)
610 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
611 it.InternalFetch = func(pageSize int, pageToken string) ([]*resourcemanagerpb.TagHold, string, error) {
612 resp := &resourcemanagerpb.ListTagHoldsResponse{}
613 if pageToken != "" {
614 req.PageToken = pageToken
615 }
616 if pageSize > math.MaxInt32 {
617 req.PageSize = math.MaxInt32
618 } else if pageSize != 0 {
619 req.PageSize = int32(pageSize)
620 }
621 baseUrl, err := url.Parse(c.endpoint)
622 if err != nil {
623 return nil, "", err
624 }
625 baseUrl.Path += fmt.Sprintf("/v3/%v/tagHolds", req.GetParent())
626
627 params := url.Values{}
628 params.Add("$alt", "json;enum-encoding=int")
629 if req.GetFilter() != "" {
630 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
631 }
632 if req.GetPageSize() != 0 {
633 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
634 }
635 if req.GetPageToken() != "" {
636 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
637 }
638
639 baseUrl.RawQuery = params.Encode()
640
641
642 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
643 headers := gax.BuildHeaders(ctx, hds...)
644 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
645 if settings.Path != "" {
646 baseUrl.Path = settings.Path
647 }
648 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
649 if err != nil {
650 return err
651 }
652 httpReq.Header = headers
653
654 httpRsp, err := c.httpClient.Do(httpReq)
655 if err != nil {
656 return err
657 }
658 defer httpRsp.Body.Close()
659
660 if err = googleapi.CheckResponse(httpRsp); err != nil {
661 return err
662 }
663
664 buf, err := io.ReadAll(httpRsp.Body)
665 if err != nil {
666 return err
667 }
668
669 if err := unm.Unmarshal(buf, resp); err != nil {
670 return err
671 }
672
673 return nil
674 }, opts...)
675 if e != nil {
676 return nil, "", e
677 }
678 it.Response = resp
679 return resp.GetTagHolds(), resp.GetNextPageToken(), nil
680 }
681
682 fetch := func(pageSize int, pageToken string) (string, error) {
683 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
684 if err != nil {
685 return "", err
686 }
687 it.items = append(it.items, items...)
688 return nextPageToken, nil
689 }
690
691 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
692 it.pageInfo.MaxSize = int(req.GetPageSize())
693 it.pageInfo.Token = req.GetPageToken()
694
695 return it
696 }
697
698
699 func (c *tagHoldsRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
700 baseUrl, err := url.Parse(c.endpoint)
701 if err != nil {
702 return nil, err
703 }
704 baseUrl.Path += fmt.Sprintf("/v3/%v", req.GetName())
705
706 params := url.Values{}
707 params.Add("$alt", "json;enum-encoding=int")
708
709 baseUrl.RawQuery = params.Encode()
710
711
712 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
713
714 hds = append(c.xGoogHeaders, hds...)
715 hds = append(hds, "Content-Type", "application/json")
716 headers := gax.BuildHeaders(ctx, hds...)
717 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
718 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
719 resp := &longrunningpb.Operation{}
720 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
721 if settings.Path != "" {
722 baseUrl.Path = settings.Path
723 }
724 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
725 if err != nil {
726 return err
727 }
728 httpReq = httpReq.WithContext(ctx)
729 httpReq.Header = headers
730
731 httpRsp, err := c.httpClient.Do(httpReq)
732 if err != nil {
733 return err
734 }
735 defer httpRsp.Body.Close()
736
737 if err = googleapi.CheckResponse(httpRsp); err != nil {
738 return err
739 }
740
741 buf, err := io.ReadAll(httpRsp.Body)
742 if err != nil {
743 return err
744 }
745
746 if err := unm.Unmarshal(buf, resp); err != nil {
747 return err
748 }
749
750 return nil
751 }, opts...)
752 if e != nil {
753 return nil, e
754 }
755 return resp, nil
756 }
757
758
759
760 func (c *tagHoldsGRPCClient) CreateTagHoldOperation(name string) *CreateTagHoldOperation {
761 return &CreateTagHoldOperation{
762 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
763 }
764 }
765
766
767
768 func (c *tagHoldsRESTClient) CreateTagHoldOperation(name string) *CreateTagHoldOperation {
769 override := fmt.Sprintf("/v3/%s", name)
770 return &CreateTagHoldOperation{
771 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
772 pollPath: override,
773 }
774 }
775
776
777
778 func (c *tagHoldsGRPCClient) DeleteTagHoldOperation(name string) *DeleteTagHoldOperation {
779 return &DeleteTagHoldOperation{
780 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
781 }
782 }
783
784
785
786 func (c *tagHoldsRESTClient) DeleteTagHoldOperation(name string) *DeleteTagHoldOperation {
787 override := fmt.Sprintf("/v3/%s", name)
788 return &DeleteTagHoldOperation{
789 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
790 pollPath: override,
791 }
792 }
793
View as plain text