Debian Codegraph @

shopping/merchant/issueresolution/apiv1beta/issue_resolution_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 issueresolution
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 issueresolutionpb "cloud.google.com/go/shopping/merchant/issueresolution/apiv1beta/issueresolutionpb"
30 gax "github.com/googleapis/gax-go/v2"
31 "google.golang.org/api/option"
32 "google.golang.org/api/option/internaloption"
33 gtransport "google.golang.org/api/transport/grpc"
34 httptransport "google.golang.org/api/transport/http"
35 "google.golang.org/grpc"
36 "google.golang.org/grpc/codes"
37 "google.golang.org/protobuf/encoding/protojson"
38 )
39
40 var newClientHook clientHook
41
42 // CallOptions contains the retry settings for each method of Client.
43 type CallOptions struct {
44 RenderAccountIssues []gax.CallOption
45 RenderProductIssues []gax.CallOption
46 TriggerAction []gax.CallOption
47 }
48
49 func defaultGRPCClientOptions() []option.ClientOption {
50 return []option.ClientOption{
51 internaloption.WithDefaultEndpoint("merchantapi.googleapis.com:443"),
52 internaloption.WithDefaultEndpointTemplate("merchantapi.UNIVERSE_DOMAIN:443"),
53 internaloption.WithDefaultMTLSEndpoint("merchantapi.mtls.googleapis.com:443"),
54 internaloption.WithDefaultUniverseDomain("googleapis.com"),
55 internaloption.WithDefaultAudience("https://merchantapi.googleapis.com/"),
56 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
57 internaloption.EnableJwtWithScope(),
58 internaloption.EnableNewAuthLibrary(),
59 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
60 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
61 }
62 }
63
64 func defaultCallOptions() *CallOptions {
65 return &CallOptions{
66 RenderAccountIssues: []gax.CallOption{
67 gax.WithTimeout(60000 * time.Millisecond),
68 gax.WithRetry(func() gax.Retryer {
69 return gax.OnCodes([]codes.Code{
70 codes.Unavailable,
71 }, gax.Backoff{
72 Initial: 1000 * time.Millisecond,
73 Max: 10000 * time.Millisecond,
74 Multiplier: 1.30,
75 })
76 }),
77 },
78 RenderProductIssues: []gax.CallOption{
79 gax.WithTimeout(60000 * time.Millisecond),
80 gax.WithRetry(func() gax.Retryer {
81 return gax.OnCodes([]codes.Code{
82 codes.Unavailable,
83 }, gax.Backoff{
84 Initial: 1000 * time.Millisecond,
85 Max: 10000 * time.Millisecond,
86 Multiplier: 1.30,
87 })
88 }),
89 },
90 TriggerAction: []gax.CallOption{
91 gax.WithTimeout(60000 * time.Millisecond),
92 gax.WithRetry(func() gax.Retryer {
93 return gax.OnCodes([]codes.Code{
94 codes.Unavailable,
95 }, gax.Backoff{
96 Initial: 1000 * time.Millisecond,
97 Max: 10000 * time.Millisecond,
98 Multiplier: 1.30,
99 })
100 }),
101 },
102 }
103 }
104
105 func defaultRESTCallOptions() *CallOptions {
106 return &CallOptions{
107 RenderAccountIssues: []gax.CallOption{
108 gax.WithTimeout(60000 * time.Millisecond),
109 gax.WithRetry(func() gax.Retryer {
110 return gax.OnHTTPCodes(gax.Backoff{
111 Initial: 1000 * time.Millisecond,
112 Max: 10000 * time.Millisecond,
113 Multiplier: 1.30,
114 },
115 http.StatusServiceUnavailable)
116 }),
117 },
118 RenderProductIssues: []gax.CallOption{
119 gax.WithTimeout(60000 * time.Millisecond),
120 gax.WithRetry(func() gax.Retryer {
121 return gax.OnHTTPCodes(gax.Backoff{
122 Initial: 1000 * time.Millisecond,
123 Max: 10000 * time.Millisecond,
124 Multiplier: 1.30,
125 },
126 http.StatusServiceUnavailable)
127 }),
128 },
129 TriggerAction: []gax.CallOption{
130 gax.WithTimeout(60000 * time.Millisecond),
131 gax.WithRetry(func() gax.Retryer {
132 return gax.OnHTTPCodes(gax.Backoff{
133 Initial: 1000 * time.Millisecond,
134 Max: 10000 * time.Millisecond,
135 Multiplier: 1.30,
136 },
137 http.StatusServiceUnavailable)
138 }),
139 },
140 }
141 }
142
143 // internalClient is an interface that defines the methods available from Merchant API.
144 type internalClient interface {
145 Close() error
146 setGoogleClientInfo(...string)
147 Connection() *grpc.ClientConn
148 RenderAccountIssues(context.Context, *issueresolutionpb.RenderAccountIssuesRequest, ...gax.CallOption) (*issueresolutionpb.RenderAccountIssuesResponse, error)
149 RenderProductIssues(context.Context, *issueresolutionpb.RenderProductIssuesRequest, ...gax.CallOption) (*issueresolutionpb.RenderProductIssuesResponse, error)
150 TriggerAction(context.Context, *issueresolutionpb.TriggerActionRequest, ...gax.CallOption) (*issueresolutionpb.TriggerActionResponse, error)
151 }
152
153 // Client is a client for interacting with Merchant API.
154 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
155 //
156 // Service to provide an issue resolution content for account issues and product
157 // issues.
158 type Client struct {
159 // The internal transport-dependent client.
160 internalClient internalClient
161
162 // The call options for this service.
163 CallOptions *CallOptions
164 }
165
166 // Wrapper methods routed to the internal client.
167
168 // Close closes the connection to the API service. The user should invoke this when
169 // the client is no longer required.
170 func (c *Client) Close() error {
171 return c.internalClient.Close()
172 }
173
174 // setGoogleClientInfo sets the name and version of the application in
175 // the `x-goog-api-client` header passed on each request. Intended for
176 // use by Google-written clients.
177 func (c *Client) setGoogleClientInfo(keyval ...string) {
178 c.internalClient.setGoogleClientInfo(keyval...)
179 }
180
181 // Connection returns a connection to the API service.
182 //
183 // Deprecated: Connections are now pooled so this method does not always
184 // return the same resource.
185 func (c *Client) Connection() *grpc.ClientConn {
186 return c.internalClient.Connection()
187 }
188
189 // RenderAccountIssues provide a list of business’s account issues with an issue resolution
190 // content and available actions. This content and actions are meant to be
191 // rendered and shown in third-party applications.
192 func (c *Client) RenderAccountIssues(ctx context.Context, req *issueresolutionpb.RenderAccountIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderAccountIssuesResponse, error) {
193 return c.internalClient.RenderAccountIssues(ctx, req, opts...)
194 }
195
196 // RenderProductIssues provide a list of issues for business’s product with an issue resolution
197 // content and available actions. This content and actions are meant to be
198 // rendered and shown in third-party applications.
199 func (c *Client) RenderProductIssues(ctx context.Context, req *issueresolutionpb.RenderProductIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderProductIssuesResponse, error) {
200 return c.internalClient.RenderProductIssues(ctx, req, opts...)
201 }
202
203 // TriggerAction start an action. The action can be requested by a business in
204 // third-party application. Before the business can request the action, the
205 // third-party application needs to show them action specific content and
206 // display a user input form.
207 //
208 // The action can be successfully started only once all required inputs are
209 // provided. If any required input is missing, or invalid value was
210 // provided, the service will return 400 error. Validation errors will contain
211 // [Ids][google.shopping.merchant.issueresolution.v1beta.InputField.id (at http://google.shopping.merchant.issueresolution.v1beta.InputField.id)] for
212 // all problematic field together with translated, human readable error
213 // messages that can be shown to the user.
214 func (c *Client) TriggerAction(ctx context.Context, req *issueresolutionpb.TriggerActionRequest, opts ...gax.CallOption) (*issueresolutionpb.TriggerActionResponse, error) {
215 return c.internalClient.TriggerAction(ctx, req, opts...)
216 }
217
218 // gRPCClient is a client for interacting with Merchant API over gRPC transport.
219 //
220 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
221 type gRPCClient struct {
222 // Connection pool of gRPC connections to the service.
223 connPool gtransport.ConnPool
224
225 // Points back to the CallOptions field of the containing Client
226 CallOptions **CallOptions
227
228 // The gRPC API client.
229 client issueresolutionpb.IssueResolutionServiceClient
230
231 // The x-goog-* metadata to be sent with each request.
232 xGoogHeaders []string
233
234 logger *slog.Logger
235 }
236
237 // NewClient creates a new issue resolution service client based on gRPC.
238 // The returned client must be Closed when it is done being used to clean up its underlying connections.
239 //
240 // Service to provide an issue resolution content for account issues and product
241 // issues.
242 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
243 clientOpts := defaultGRPCClientOptions()
244 if newClientHook != nil {
245 hookOpts, err := newClientHook(ctx, clientHookParams{})
246 if err != nil {
247 return nil, err
248 }
249 clientOpts = append(clientOpts, hookOpts...)
250 }
251
252 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
253 if err != nil {
254 return nil, err
255 }
256 client := Client{CallOptions: defaultCallOptions()}
257
258 c := &gRPCClient{
259 connPool: connPool,
260 client: issueresolutionpb.NewIssueResolutionServiceClient(connPool),
261 CallOptions: &client.CallOptions,
262 logger: internaloption.GetLogger(opts),
263 }
264 c.setGoogleClientInfo()
265
266 client.internalClient = c
267
268 return &client, nil
269 }
270
271 // Connection returns a connection to the API service.
272 //
273 // Deprecated: Connections are now pooled so this method does not always
274 // return the same resource.
275 func (c *gRPCClient) Connection() *grpc.ClientConn {
276 return c.connPool.Conn()
277 }
278
279 // setGoogleClientInfo sets the name and version of the application in
280 // the `x-goog-api-client` header passed on each request. Intended for
281 // use by Google-written clients.
282 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
283 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
284 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
285 c.xGoogHeaders = []string{
286 "x-goog-api-client", gax.XGoogHeader(kv...),
287 }
288 }
289
290 // Close closes the connection to the API service. The user should invoke this when
291 // the client is no longer required.
292 func (c *gRPCClient) Close() error {
293 return c.connPool.Close()
294 }
295
296 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
297 type restClient struct {
298 // The http endpoint to connect to.
299 endpoint string
300
301 // The http client.
302 httpClient *http.Client
303
304 // The x-goog-* headers to be sent with each request.
305 xGoogHeaders []string
306
307 // Points back to the CallOptions field of the containing Client
308 CallOptions **CallOptions
309
310 logger *slog.Logger
311 }
312
313 // NewRESTClient creates a new issue resolution service rest client.
314 //
315 // Service to provide an issue resolution content for account issues and product
316 // issues.
317 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
318 clientOpts := append(defaultRESTClientOptions(), opts...)
319 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
320 if err != nil {
321 return nil, err
322 }
323
324 callOpts := defaultRESTCallOptions()
325 c := &restClient{
326 endpoint: endpoint,
327 httpClient: httpClient,
328 CallOptions: &callOpts,
329 logger: internaloption.GetLogger(opts),
330 }
331 c.setGoogleClientInfo()
332
333 return &Client{internalClient: c, CallOptions: callOpts}, nil
334 }
335
336 func defaultRESTClientOptions() []option.ClientOption {
337 return []option.ClientOption{
338 internaloption.WithDefaultEndpoint("https://merchantapi.googleapis.com"),
339 internaloption.WithDefaultEndpointTemplate("https://merchantapi.UNIVERSE_DOMAIN"),
340 internaloption.WithDefaultMTLSEndpoint("https://merchantapi.mtls.googleapis.com"),
341 internaloption.WithDefaultUniverseDomain("googleapis.com"),
342 internaloption.WithDefaultAudience("https://merchantapi.googleapis.com/"),
343 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
344 internaloption.EnableNewAuthLibrary(),
345 }
346 }
347
348 // setGoogleClientInfo sets the name and version of the application in
349 // the `x-goog-api-client` header passed on each request. Intended for
350 // use by Google-written clients.
351 func (c *restClient) setGoogleClientInfo(keyval ...string) {
352 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
353 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
354 c.xGoogHeaders = []string{
355 "x-goog-api-client", gax.XGoogHeader(kv...),
356 }
357 }
358
359 // Close closes the connection to the API service. The user should invoke this when
360 // the client is no longer required.
361 func (c *restClient) Close() error {
362 // Replace httpClient with nil to force cleanup.
363 c.httpClient = nil
364 return nil
365 }
366
367 // Connection returns a connection to the API service.
368 //
369 // Deprecated: This method always returns nil.
370 func (c *restClient) Connection() *grpc.ClientConn {
371 return nil
372 }
373 func (c *gRPCClient) RenderAccountIssues(ctx context.Context, req *issueresolutionpb.RenderAccountIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderAccountIssuesResponse, error) {
374 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
375
376 hds = append(c.xGoogHeaders, hds...)
377 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
378 opts = append((*c.CallOptions).RenderAccountIssues[0:len((*c.CallOptions).RenderAccountIssues):len((*c.CallOptions).RenderAccountIssues)], opts...)
379 var resp *issueresolutionpb.RenderAccountIssuesResponse
380 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
381 var err error
382 resp, err = executeRPC(ctx, c.client.RenderAccountIssues, req, settings.GRPC, c.logger, "RenderAccountIssues")
383 return err
384 }, opts...)
385 if err != nil {
386 return nil, err
387 }
388 return resp, nil
389 }
390
391 func (c *gRPCClient) RenderProductIssues(ctx context.Context, req *issueresolutionpb.RenderProductIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderProductIssuesResponse, error) {
392 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
393
394 hds = append(c.xGoogHeaders, hds...)
395 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
396 opts = append((*c.CallOptions).RenderProductIssues[0:len((*c.CallOptions).RenderProductIssues):len((*c.CallOptions).RenderProductIssues)], opts...)
397 var resp *issueresolutionpb.RenderProductIssuesResponse
398 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
399 var err error
400 resp, err = executeRPC(ctx, c.client.RenderProductIssues, req, settings.GRPC, c.logger, "RenderProductIssues")
401 return err
402 }, opts...)
403 if err != nil {
404 return nil, err
405 }
406 return resp, nil
407 }
408
409 func (c *gRPCClient) TriggerAction(ctx context.Context, req *issueresolutionpb.TriggerActionRequest, opts ...gax.CallOption) (*issueresolutionpb.TriggerActionResponse, error) {
410 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
411
412 hds = append(c.xGoogHeaders, hds...)
413 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
414 opts = append((*c.CallOptions).TriggerAction[0:len((*c.CallOptions).TriggerAction):len((*c.CallOptions).TriggerAction)], opts...)
415 var resp *issueresolutionpb.TriggerActionResponse
416 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
417 var err error
418 resp, err = executeRPC(ctx, c.client.TriggerAction, req, settings.GRPC, c.logger, "TriggerAction")
419 return err
420 }, opts...)
421 if err != nil {
422 return nil, err
423 }
424 return resp, nil
425 }
426
427 // RenderAccountIssues provide a list of business’s account issues with an issue resolution
428 // content and available actions. This content and actions are meant to be
429 // rendered and shown in third-party applications.
430 func (c *restClient) RenderAccountIssues(ctx context.Context, req *issueresolutionpb.RenderAccountIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderAccountIssuesResponse, error) {
431 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
432 body := req.GetPayload()
433 jsonReq, err := m.Marshal(body)
434 if err != nil {
435 return nil, err
436 }
437
438 baseUrl, err := url.Parse(c.endpoint)
439 if err != nil {
440 return nil, err
441 }
442 baseUrl.Path += fmt.Sprintf("/issueresolution/v1beta/%v:renderaccountissues", req.GetName())
443
444 params := url.Values{}
445 params.Add("$alt", "json;enum-encoding=int")
446 if req.GetLanguageCode() != "" {
447 params.Add("languageCode", fmt.Sprintf("%v", req.GetLanguageCode()))
448 }
449 if req.GetTimeZone() != "" {
450 params.Add("timeZone", fmt.Sprintf("%v", req.GetTimeZone()))
451 }
452
453 baseUrl.RawQuery = params.Encode()
454
455 // Build HTTP headers from client and context metadata.
456 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
457
458 hds = append(c.xGoogHeaders, hds...)
459 hds = append(hds, "Content-Type", "application/json")
460 headers := gax.BuildHeaders(ctx, hds...)
461 opts = append((*c.CallOptions).RenderAccountIssues[0:len((*c.CallOptions).RenderAccountIssues):len((*c.CallOptions).RenderAccountIssues)], opts...)
462 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
463 resp := &issueresolutionpb.RenderAccountIssuesResponse{}
464 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
465 if settings.Path != "" {
466 baseUrl.Path = settings.Path
467 }
468 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
469 if err != nil {
470 return err
471 }
472 httpReq = httpReq.WithContext(ctx)
473 httpReq.Header = headers
474
475 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RenderAccountIssues")
476 if err != nil {
477 return err
478 }
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 return resp, nil
490 }
491
492 // RenderProductIssues provide a list of issues for business’s product with an issue resolution
493 // content and available actions. This content and actions are meant to be
494 // rendered and shown in third-party applications.
495 func (c *restClient) RenderProductIssues(ctx context.Context, req *issueresolutionpb.RenderProductIssuesRequest, opts ...gax.CallOption) (*issueresolutionpb.RenderProductIssuesResponse, error) {
496 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
497 body := req.GetPayload()
498 jsonReq, err := m.Marshal(body)
499 if err != nil {
500 return nil, err
501 }
502
503 baseUrl, err := url.Parse(c.endpoint)
504 if err != nil {
505 return nil, err
506 }
507 baseUrl.Path += fmt.Sprintf("/issueresolution/v1beta/%v:renderproductissues", req.GetName())
508
509 params := url.Values{}
510 params.Add("$alt", "json;enum-encoding=int")
511 if req.GetLanguageCode() != "" {
512 params.Add("languageCode", fmt.Sprintf("%v", req.GetLanguageCode()))
513 }
514 if req.GetTimeZone() != "" {
515 params.Add("timeZone", fmt.Sprintf("%v", req.GetTimeZone()))
516 }
517
518 baseUrl.RawQuery = params.Encode()
519
520 // Build HTTP headers from client and context metadata.
521 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
522
523 hds = append(c.xGoogHeaders, hds...)
524 hds = append(hds, "Content-Type", "application/json")
525 headers := gax.BuildHeaders(ctx, hds...)
526 opts = append((*c.CallOptions).RenderProductIssues[0:len((*c.CallOptions).RenderProductIssues):len((*c.CallOptions).RenderProductIssues)], opts...)
527 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
528 resp := &issueresolutionpb.RenderProductIssuesResponse{}
529 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
530 if settings.Path != "" {
531 baseUrl.Path = settings.Path
532 }
533 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
534 if err != nil {
535 return err
536 }
537 httpReq = httpReq.WithContext(ctx)
538 httpReq.Header = headers
539
540 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RenderProductIssues")
541 if err != nil {
542 return err
543 }
544
545 if err := unm.Unmarshal(buf, resp); err != nil {
546 return err
547 }
548
549 return nil
550 }, opts...)
551 if e != nil {
552 return nil, e
553 }
554 return resp, nil
555 }
556
557 // TriggerAction start an action. The action can be requested by a business in
558 // third-party application. Before the business can request the action, the
559 // third-party application needs to show them action specific content and
560 // display a user input form.
561 //
562 // The action can be successfully started only once all required inputs are
563 // provided. If any required input is missing, or invalid value was
564 // provided, the service will return 400 error. Validation errors will contain
565 // [Ids][google.shopping.merchant.issueresolution.v1beta.InputField.id (at http://google.shopping.merchant.issueresolution.v1beta.InputField.id)] for
566 // all problematic field together with translated, human readable error
567 // messages that can be shown to the user.
568 func (c *restClient) TriggerAction(ctx context.Context, req *issueresolutionpb.TriggerActionRequest, opts ...gax.CallOption) (*issueresolutionpb.TriggerActionResponse, error) {
569 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
570 body := req.GetPayload()
571 jsonReq, err := m.Marshal(body)
572 if err != nil {
573 return nil, err
574 }
575
576 baseUrl, err := url.Parse(c.endpoint)
577 if err != nil {
578 return nil, err
579 }
580 baseUrl.Path += fmt.Sprintf("/issueresolution/v1beta/%v:triggeraction", req.GetName())
581
582 params := url.Values{}
583 params.Add("$alt", "json;enum-encoding=int")
584 if req.GetLanguageCode() != "" {
585 params.Add("languageCode", fmt.Sprintf("%v", req.GetLanguageCode()))
586 }
587
588 baseUrl.RawQuery = params.Encode()
589
590 // Build HTTP headers from client and context metadata.
591 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
592
593 hds = append(c.xGoogHeaders, hds...)
594 hds = append(hds, "Content-Type", "application/json")
595 headers := gax.BuildHeaders(ctx, hds...)
596 opts = append((*c.CallOptions).TriggerAction[0:len((*c.CallOptions).TriggerAction):len((*c.CallOptions).TriggerAction)], opts...)
597 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
598 resp := &issueresolutionpb.TriggerActionResponse{}
599 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
600 if settings.Path != "" {
601 baseUrl.Path = settings.Path
602 }
603 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
604 if err != nil {
605 return err
606 }
607 httpReq = httpReq.WithContext(ctx)
608 httpReq.Header = headers
609
610 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TriggerAction")
611 if err != nil {
612 return err
613 }
614
615 if err := unm.Unmarshal(buf, resp); err != nil {
616 return err
617 }
618
619 return nil
620 }, opts...)
621 if e != nil {
622 return nil, e
623 }
624 return resp, nil
625 }