Debian Codegraph @

shopping/css/apiv1/accounts_client.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package css
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 csspb "cloud.google.com/go/shopping/css/apiv1/csspb"
30 gax "github.com/googleapis/gax-go/v2"
31 "google.golang.org/api/iterator"
32 "google.golang.org/api/option"
33 "google.golang.org/api/option/internaloption"
34 gtransport "google.golang.org/api/transport/grpc"
35 httptransport "google.golang.org/api/transport/http"
36 "google.golang.org/grpc"
37 "google.golang.org/grpc/codes"
38 "google.golang.org/protobuf/encoding/protojson"
39 "google.golang.org/protobuf/proto"
40 )
41
42 var newAccountsClientHook clientHook
43
44 // AccountsCallOptions contains the retry settings for each method of AccountsClient.
45 type AccountsCallOptions struct {
46 ListChildAccounts []gax.CallOption
47 GetAccount []gax.CallOption
48 UpdateLabels []gax.CallOption
49 }
50
51 func defaultAccountsGRPCClientOptions() []option.ClientOption {
52 return []option.ClientOption{
53 internaloption.WithDefaultEndpoint("css.googleapis.com:443"),
54 internaloption.WithDefaultEndpointTemplate("css.UNIVERSE_DOMAIN:443"),
55 internaloption.WithDefaultMTLSEndpoint("css.mtls.googleapis.com:443"),
56 internaloption.WithDefaultUniverseDomain("googleapis.com"),
57 internaloption.WithDefaultAudience("https://css.googleapis.com/"),
58 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
59 internaloption.EnableJwtWithScope(),
60 internaloption.EnableNewAuthLibrary(),
61 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
62 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
63 }
64 }
65
66 func defaultAccountsCallOptions() *AccountsCallOptions {
67 return &AccountsCallOptions{
68 ListChildAccounts: []gax.CallOption{
69 gax.WithTimeout(60000 * time.Millisecond),
70 gax.WithRetry(func() gax.Retryer {
71 return gax.OnCodes([]codes.Code{
72 codes.Unavailable,
73 }, gax.Backoff{
74 Initial: 1000 * time.Millisecond,
75 Max: 10000 * time.Millisecond,
76 Multiplier: 1.30,
77 })
78 }),
79 },
80 GetAccount: []gax.CallOption{
81 gax.WithTimeout(60000 * time.Millisecond),
82 gax.WithRetry(func() gax.Retryer {
83 return gax.OnCodes([]codes.Code{
84 codes.Unavailable,
85 }, gax.Backoff{
86 Initial: 1000 * time.Millisecond,
87 Max: 10000 * time.Millisecond,
88 Multiplier: 1.30,
89 })
90 }),
91 },
92 UpdateLabels: []gax.CallOption{
93 gax.WithTimeout(60000 * time.Millisecond),
94 },
95 }
96 }
97
98 func defaultAccountsRESTCallOptions() *AccountsCallOptions {
99 return &AccountsCallOptions{
100 ListChildAccounts: []gax.CallOption{
101 gax.WithTimeout(60000 * time.Millisecond),
102 gax.WithRetry(func() gax.Retryer {
103 return gax.OnHTTPCodes(gax.Backoff{
104 Initial: 1000 * time.Millisecond,
105 Max: 10000 * time.Millisecond,
106 Multiplier: 1.30,
107 },
108 http.StatusServiceUnavailable)
109 }),
110 },
111 GetAccount: []gax.CallOption{
112 gax.WithTimeout(60000 * time.Millisecond),
113 gax.WithRetry(func() gax.Retryer {
114 return gax.OnHTTPCodes(gax.Backoff{
115 Initial: 1000 * time.Millisecond,
116 Max: 10000 * time.Millisecond,
117 Multiplier: 1.30,
118 },
119 http.StatusServiceUnavailable)
120 }),
121 },
122 UpdateLabels: []gax.CallOption{
123 gax.WithTimeout(60000 * time.Millisecond),
124 },
125 }
126 }
127
128 // internalAccountsClient is an interface that defines the methods available from CSS API.
129 type internalAccountsClient interface {
130 Close() error
131 setGoogleClientInfo(...string)
132 Connection() *grpc.ClientConn
133 ListChildAccounts(context.Context, *csspb.ListChildAccountsRequest, ...gax.CallOption) *AccountIterator
134 GetAccount(context.Context, *csspb.GetAccountRequest, ...gax.CallOption) (*csspb.Account, error)
135 UpdateLabels(context.Context, *csspb.UpdateAccountLabelsRequest, ...gax.CallOption) (*csspb.Account, error)
136 }
137
138 // AccountsClient is a client for interacting with CSS API.
139 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
140 //
141 // Service for managing CSS/MC account information.
142 type AccountsClient struct {
143 // The internal transport-dependent client.
144 internalClient internalAccountsClient
145
146 // The call options for this service.
147 CallOptions *AccountsCallOptions
148 }
149
150 // Wrapper methods routed to the internal client.
151
152 // Close closes the connection to the API service. The user should invoke this when
153 // the client is no longer required.
154 func (c *AccountsClient) Close() error {
155 return c.internalClient.Close()
156 }
157
158 // setGoogleClientInfo sets the name and version of the application in
159 // the `x-goog-api-client` header passed on each request. Intended for
160 // use by Google-written clients.
161 func (c *AccountsClient) setGoogleClientInfo(keyval ...string) {
162 c.internalClient.setGoogleClientInfo(keyval...)
163 }
164
165 // Connection returns a connection to the API service.
166 //
167 // Deprecated: Connections are now pooled so this method does not always
168 // return the same resource.
169 func (c *AccountsClient) Connection() *grpc.ClientConn {
170 return c.internalClient.Connection()
171 }
172
173 // ListChildAccounts lists all the accounts under the specified CSS account ID, and
174 // optionally filters by label ID and account name.
175 func (c *AccountsClient) ListChildAccounts(ctx context.Context, req *csspb.ListChildAccountsRequest, opts ...gax.CallOption) *AccountIterator {
176 return c.internalClient.ListChildAccounts(ctx, req, opts...)
177 }
178
179 // GetAccount retrieves a single CSS/MC account by ID.
180 func (c *AccountsClient) GetAccount(ctx context.Context, req *csspb.GetAccountRequest, opts ...gax.CallOption) (*csspb.Account, error) {
181 return c.internalClient.GetAccount(ctx, req, opts...)
182 }
183
184 // UpdateLabels updates labels assigned to CSS/MC accounts by a CSS domain.
185 func (c *AccountsClient) UpdateLabels(ctx context.Context, req *csspb.UpdateAccountLabelsRequest, opts ...gax.CallOption) (*csspb.Account, error) {
186 return c.internalClient.UpdateLabels(ctx, req, opts...)
187 }
188
189 // accountsGRPCClient is a client for interacting with CSS API over gRPC transport.
190 //
191 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
192 type accountsGRPCClient struct {
193 // Connection pool of gRPC connections to the service.
194 connPool gtransport.ConnPool
195
196 // Points back to the CallOptions field of the containing AccountsClient
197 CallOptions **AccountsCallOptions
198
199 // The gRPC API client.
200 accountsClient csspb.AccountsServiceClient
201
202 // The x-goog-* metadata to be sent with each request.
203 xGoogHeaders []string
204
205 logger *slog.Logger
206 }
207
208 // NewAccountsClient creates a new accounts service client based on gRPC.
209 // The returned client must be Closed when it is done being used to clean up its underlying connections.
210 //
211 // Service for managing CSS/MC account information.
212 func NewAccountsClient(ctx context.Context, opts ...option.ClientOption) (*AccountsClient, error) {
213 clientOpts := defaultAccountsGRPCClientOptions()
214 if newAccountsClientHook != nil {
215 hookOpts, err := newAccountsClientHook(ctx, clientHookParams{})
216 if err != nil {
217 return nil, err
218 }
219 clientOpts = append(clientOpts, hookOpts...)
220 }
221
222 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
223 if err != nil {
224 return nil, err
225 }
226 client := AccountsClient{CallOptions: defaultAccountsCallOptions()}
227
228 c := &accountsGRPCClient{
229 connPool: connPool,
230 accountsClient: csspb.NewAccountsServiceClient(connPool),
231 CallOptions: &client.CallOptions,
232 logger: internaloption.GetLogger(opts),
233 }
234 c.setGoogleClientInfo()
235
236 client.internalClient = c
237
238 return &client, nil
239 }
240
241 // Connection returns a connection to the API service.
242 //
243 // Deprecated: Connections are now pooled so this method does not always
244 // return the same resource.
245 func (c *accountsGRPCClient) Connection() *grpc.ClientConn {
246 return c.connPool.Conn()
247 }
248
249 // setGoogleClientInfo sets the name and version of the application in
250 // the `x-goog-api-client` header passed on each request. Intended for
251 // use by Google-written clients.
252 func (c *accountsGRPCClient) setGoogleClientInfo(keyval ...string) {
253 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
254 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
255 c.xGoogHeaders = []string{
256 "x-goog-api-client", gax.XGoogHeader(kv...),
257 }
258 }
259
260 // Close closes the connection to the API service. The user should invoke this when
261 // the client is no longer required.
262 func (c *accountsGRPCClient) Close() error {
263 return c.connPool.Close()
264 }
265
266 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
267 type accountsRESTClient struct {
268 // The http endpoint to connect to.
269 endpoint string
270
271 // The http client.
272 httpClient *http.Client
273
274 // The x-goog-* headers to be sent with each request.
275 xGoogHeaders []string
276
277 // Points back to the CallOptions field of the containing AccountsClient
278 CallOptions **AccountsCallOptions
279
280 logger *slog.Logger
281 }
282
283 // NewAccountsRESTClient creates a new accounts service rest client.
284 //
285 // Service for managing CSS/MC account information.
286 func NewAccountsRESTClient(ctx context.Context, opts ...option.ClientOption) (*AccountsClient, error) {
287 clientOpts := append(defaultAccountsRESTClientOptions(), opts...)
288 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
289 if err != nil {
290 return nil, err
291 }
292
293 callOpts := defaultAccountsRESTCallOptions()
294 c := &accountsRESTClient{
295 endpoint: endpoint,
296 httpClient: httpClient,
297 CallOptions: &callOpts,
298 logger: internaloption.GetLogger(opts),
299 }
300 c.setGoogleClientInfo()
301
302 return &AccountsClient{internalClient: c, CallOptions: callOpts}, nil
303 }
304
305 func defaultAccountsRESTClientOptions() []option.ClientOption {
306 return []option.ClientOption{
307 internaloption.WithDefaultEndpoint("https://css.googleapis.com"),
308 internaloption.WithDefaultEndpointTemplate("https://css.UNIVERSE_DOMAIN"),
309 internaloption.WithDefaultMTLSEndpoint("https://css.mtls.googleapis.com"),
310 internaloption.WithDefaultUniverseDomain("googleapis.com"),
311 internaloption.WithDefaultAudience("https://css.googleapis.com/"),
312 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
313 internaloption.EnableNewAuthLibrary(),
314 }
315 }
316
317 // setGoogleClientInfo sets the name and version of the application in
318 // the `x-goog-api-client` header passed on each request. Intended for
319 // use by Google-written clients.
320 func (c *accountsRESTClient) setGoogleClientInfo(keyval ...string) {
321 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
322 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
323 c.xGoogHeaders = []string{
324 "x-goog-api-client", gax.XGoogHeader(kv...),
325 }
326 }
327
328 // Close closes the connection to the API service. The user should invoke this when
329 // the client is no longer required.
330 func (c *accountsRESTClient) Close() error {
331 // Replace httpClient with nil to force cleanup.
332 c.httpClient = nil
333 return nil
334 }
335
336 // Connection returns a connection to the API service.
337 //
338 // Deprecated: This method always returns nil.
339 func (c *accountsRESTClient) Connection() *grpc.ClientConn {
340 return nil
341 }
342 func (c *accountsGRPCClient) ListChildAccounts(ctx context.Context, req *csspb.ListChildAccountsRequest, opts ...gax.CallOption) *AccountIterator {
343 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
344
345 hds = append(c.xGoogHeaders, hds...)
346 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
347 opts = append((*c.CallOptions).ListChildAccounts[0:len((*c.CallOptions).ListChildAccounts):len((*c.CallOptions).ListChildAccounts)], opts...)
348 it := &AccountIterator{}
349 req = proto.Clone(req).(*csspb.ListChildAccountsRequest)
350 it.InternalFetch = func(pageSize int, pageToken string) ([]*csspb.Account, string, error) {
351 resp := &csspb.ListChildAccountsResponse{}
352 if pageToken != "" {
353 req.PageToken = pageToken
354 }
355 if pageSize > math.MaxInt32 {
356 req.PageSize = math.MaxInt32
357 } else if pageSize != 0 {
358 req.PageSize = int32(pageSize)
359 }
360 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
361 var err error
362 resp, err = executeRPC(ctx, c.accountsClient.ListChildAccounts, req, settings.GRPC, c.logger, "ListChildAccounts")
363 return err
364 }, opts...)
365 if err != nil {
366 return nil, "", err
367 }
368
369 it.Response = resp
370 return resp.GetAccounts(), resp.GetNextPageToken(), nil
371 }
372 fetch := func(pageSize int, pageToken string) (string, error) {
373 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
374 if err != nil {
375 return "", err
376 }
377 it.items = append(it.items, items...)
378 return nextPageToken, nil
379 }
380
381 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
382 it.pageInfo.MaxSize = int(req.GetPageSize())
383 it.pageInfo.Token = req.GetPageToken()
384
385 return it
386 }
387
388 func (c *accountsGRPCClient) GetAccount(ctx context.Context, req *csspb.GetAccountRequest, opts ...gax.CallOption) (*csspb.Account, error) {
389 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
390
391 hds = append(c.xGoogHeaders, hds...)
392 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
393 opts = append((*c.CallOptions).GetAccount[0:len((*c.CallOptions).GetAccount):len((*c.CallOptions).GetAccount)], opts...)
394 var resp *csspb.Account
395 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
396 var err error
397 resp, err = executeRPC(ctx, c.accountsClient.GetAccount, req, settings.GRPC, c.logger, "GetAccount")
398 return err
399 }, opts...)
400 if err != nil {
401 return nil, err
402 }
403 return resp, nil
404 }
405
406 func (c *accountsGRPCClient) UpdateLabels(ctx context.Context, req *csspb.UpdateAccountLabelsRequest, opts ...gax.CallOption) (*csspb.Account, error) {
407 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
408
409 hds = append(c.xGoogHeaders, hds...)
410 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
411 opts = append((*c.CallOptions).UpdateLabels[0:len((*c.CallOptions).UpdateLabels):len((*c.CallOptions).UpdateLabels)], opts...)
412 var resp *csspb.Account
413 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
414 var err error
415 resp, err = executeRPC(ctx, c.accountsClient.UpdateLabels, req, settings.GRPC, c.logger, "UpdateLabels")
416 return err
417 }, opts...)
418 if err != nil {
419 return nil, err
420 }
421 return resp, nil
422 }
423
424 // ListChildAccounts lists all the accounts under the specified CSS account ID, and
425 // optionally filters by label ID and account name.
426 func (c *accountsRESTClient) ListChildAccounts(ctx context.Context, req *csspb.ListChildAccountsRequest, opts ...gax.CallOption) *AccountIterator {
427 it := &AccountIterator{}
428 req = proto.Clone(req).(*csspb.ListChildAccountsRequest)
429 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
430 it.InternalFetch = func(pageSize int, pageToken string) ([]*csspb.Account, string, error) {
431 resp := &csspb.ListChildAccountsResponse{}
432 if pageToken != "" {
433 req.PageToken = pageToken
434 }
435 if pageSize > math.MaxInt32 {
436 req.PageSize = math.MaxInt32
437 } else if pageSize != 0 {
438 req.PageSize = int32(pageSize)
439 }
440 baseUrl, err := url.Parse(c.endpoint)
441 if err != nil {
442 return nil, "", err
443 }
444 baseUrl.Path += fmt.Sprintf("/v1/%v:listChildAccounts", req.GetParent())
445
446 params := url.Values{}
447 params.Add("$alt", "json;enum-encoding=int")
448 if req != nil && req.FullName != nil {
449 params.Add("fullName", fmt.Sprintf("%v", req.GetFullName()))
450 }
451 if req != nil && req.LabelId != nil {
452 params.Add("labelId", fmt.Sprintf("%v", req.GetLabelId()))
453 }
454 if req.GetPageSize() != 0 {
455 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
456 }
457 if req.GetPageToken() != "" {
458 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
459 }
460
461 baseUrl.RawQuery = params.Encode()
462
463 // Build HTTP headers from client and context metadata.
464 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
465 headers := gax.BuildHeaders(ctx, hds...)
466 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
467 if settings.Path != "" {
468 baseUrl.Path = settings.Path
469 }
470 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
471 if err != nil {
472 return err
473 }
474 httpReq.Header = headers
475
476 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListChildAccounts")
477 if err != nil {
478 return err
479 }
480 if err := unm.Unmarshal(buf, resp); err != nil {
481 return err
482 }
483
484 return nil
485 }, opts...)
486 if e != nil {
487 return nil, "", e
488 }
489 it.Response = resp
490 return resp.GetAccounts(), resp.GetNextPageToken(), nil
491 }
492
493 fetch := func(pageSize int, pageToken string) (string, error) {
494 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
495 if err != nil {
496 return "", err
497 }
498 it.items = append(it.items, items...)
499 return nextPageToken, nil
500 }
501
502 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
503 it.pageInfo.MaxSize = int(req.GetPageSize())
504 it.pageInfo.Token = req.GetPageToken()
505
506 return it
507 }
508
509 // GetAccount retrieves a single CSS/MC account by ID.
510 func (c *accountsRESTClient) GetAccount(ctx context.Context, req *csspb.GetAccountRequest, opts ...gax.CallOption) (*csspb.Account, error) {
511 baseUrl, err := url.Parse(c.endpoint)
512 if err != nil {
513 return nil, err
514 }
515 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
516
517 params := url.Values{}
518 params.Add("$alt", "json;enum-encoding=int")
519 if req != nil && req.Parent != nil {
520 params.Add("parent", fmt.Sprintf("%v", req.GetParent()))
521 }
522
523 baseUrl.RawQuery = params.Encode()
524
525 // Build HTTP headers from client and context metadata.
526 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
527
528 hds = append(c.xGoogHeaders, hds...)
529 hds = append(hds, "Content-Type", "application/json")
530 headers := gax.BuildHeaders(ctx, hds...)
531 opts = append((*c.CallOptions).GetAccount[0:len((*c.CallOptions).GetAccount):len((*c.CallOptions).GetAccount)], opts...)
532 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
533 resp := &csspb.Account{}
534 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
535 if settings.Path != "" {
536 baseUrl.Path = settings.Path
537 }
538 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
539 if err != nil {
540 return err
541 }
542 httpReq = httpReq.WithContext(ctx)
543 httpReq.Header = headers
544
545 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetAccount")
546 if err != nil {
547 return err
548 }
549
550 if err := unm.Unmarshal(buf, resp); err != nil {
551 return err
552 }
553
554 return nil
555 }, opts...)
556 if e != nil {
557 return nil, e
558 }
559 return resp, nil
560 }
561
562 // UpdateLabels updates labels assigned to CSS/MC accounts by a CSS domain.
563 func (c *accountsRESTClient) UpdateLabels(ctx context.Context, req *csspb.UpdateAccountLabelsRequest, opts ...gax.CallOption) (*csspb.Account, error) {
564 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
565 jsonReq, err := m.Marshal(req)
566 if err != nil {
567 return nil, err
568 }
569
570 baseUrl, err := url.Parse(c.endpoint)
571 if err != nil {
572 return nil, err
573 }
574 baseUrl.Path += fmt.Sprintf("/v1/%v:updateLabels", req.GetName())
575
576 params := url.Values{}
577 params.Add("$alt", "json;enum-encoding=int")
578
579 baseUrl.RawQuery = params.Encode()
580
581 // Build HTTP headers from client and context metadata.
582 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
583
584 hds = append(c.xGoogHeaders, hds...)
585 hds = append(hds, "Content-Type", "application/json")
586 headers := gax.BuildHeaders(ctx, hds...)
587 opts = append((*c.CallOptions).UpdateLabels[0:len((*c.CallOptions).UpdateLabels):len((*c.CallOptions).UpdateLabels)], opts...)
588 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
589 resp := &csspb.Account{}
590 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
591 if settings.Path != "" {
592 baseUrl.Path = settings.Path
593 }
594 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
595 if err != nil {
596 return err
597 }
598 httpReq = httpReq.WithContext(ctx)
599 httpReq.Header = headers
600
601 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateLabels")
602 if err != nil {
603 return err
604 }
605
606 if err := unm.Unmarshal(buf, resp); err != nil {
607 return err
608 }
609
610 return nil
611 }, opts...)
612 if e != nil {
613 return nil, e
614 }
615 return resp, nil
616 }