Debian Codegraph @

dialogflow/cx/apiv3beta1/playbooks_client.go

raw symbols SCIP
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 cx
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 cxpb "cloud.google.com/go/dialogflow/cx/apiv3beta1/cxpb"
30 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
31 gax "github.com/googleapis/gax-go/v2"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 httptransport "google.golang.org/api/transport/http"
37 locationpb "google.golang.org/genproto/googleapis/cloud/location"
38 "google.golang.org/grpc"
39 "google.golang.org/grpc/codes"
40 "google.golang.org/protobuf/encoding/protojson"
41 "google.golang.org/protobuf/proto"
42 )
43
44 var newPlaybooksClientHook clientHook
45
46 // PlaybooksCallOptions contains the retry settings for each method of PlaybooksClient.
47 type PlaybooksCallOptions struct {
48 CreatePlaybook []gax.CallOption
49 DeletePlaybook []gax.CallOption
50 ListPlaybooks []gax.CallOption
51 GetPlaybook []gax.CallOption
52 UpdatePlaybook []gax.CallOption
53 CreatePlaybookVersion []gax.CallOption
54 GetPlaybookVersion []gax.CallOption
55 ListPlaybookVersions []gax.CallOption
56 DeletePlaybookVersion []gax.CallOption
57 GetLocation []gax.CallOption
58 ListLocations []gax.CallOption
59 CancelOperation []gax.CallOption
60 GetOperation []gax.CallOption
61 ListOperations []gax.CallOption
62 }
63
64 func defaultPlaybooksGRPCClientOptions() []option.ClientOption {
65 return []option.ClientOption{
66 internaloption.WithDefaultEndpoint("dialogflow.googleapis.com:443"),
67 internaloption.WithDefaultEndpointTemplate("dialogflow.UNIVERSE_DOMAIN:443"),
68 internaloption.WithDefaultMTLSEndpoint("dialogflow.mtls.googleapis.com:443"),
69 internaloption.WithDefaultUniverseDomain("googleapis.com"),
70 internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"),
71 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
72 internaloption.EnableJwtWithScope(),
73 internaloption.EnableNewAuthLibrary(),
74 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
75 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
76 }
77 }
78
79 func defaultPlaybooksCallOptions() *PlaybooksCallOptions {
80 return &PlaybooksCallOptions{
81 CreatePlaybook: []gax.CallOption{
82 gax.WithTimeout(60000 * time.Millisecond),
83 gax.WithRetry(func() gax.Retryer {
84 return gax.OnCodes([]codes.Code{
85 codes.Unavailable,
86 }, gax.Backoff{
87 Initial: 100 * time.Millisecond,
88 Max: 60000 * time.Millisecond,
89 Multiplier: 1.30,
90 })
91 }),
92 },
93 DeletePlaybook: []gax.CallOption{
94 gax.WithTimeout(60000 * time.Millisecond),
95 gax.WithRetry(func() gax.Retryer {
96 return gax.OnCodes([]codes.Code{
97 codes.Unavailable,
98 }, gax.Backoff{
99 Initial: 100 * time.Millisecond,
100 Max: 60000 * time.Millisecond,
101 Multiplier: 1.30,
102 })
103 }),
104 },
105 ListPlaybooks: []gax.CallOption{
106 gax.WithTimeout(60000 * time.Millisecond),
107 gax.WithRetry(func() gax.Retryer {
108 return gax.OnCodes([]codes.Code{
109 codes.Unavailable,
110 }, gax.Backoff{
111 Initial: 100 * time.Millisecond,
112 Max: 60000 * time.Millisecond,
113 Multiplier: 1.30,
114 })
115 }),
116 },
117 GetPlaybook: []gax.CallOption{
118 gax.WithTimeout(60000 * time.Millisecond),
119 gax.WithRetry(func() gax.Retryer {
120 return gax.OnCodes([]codes.Code{
121 codes.Unavailable,
122 }, gax.Backoff{
123 Initial: 100 * time.Millisecond,
124 Max: 60000 * time.Millisecond,
125 Multiplier: 1.30,
126 })
127 }),
128 },
129 UpdatePlaybook: []gax.CallOption{
130 gax.WithTimeout(60000 * time.Millisecond),
131 gax.WithRetry(func() gax.Retryer {
132 return gax.OnCodes([]codes.Code{
133 codes.Unavailable,
134 }, gax.Backoff{
135 Initial: 100 * time.Millisecond,
136 Max: 60000 * time.Millisecond,
137 Multiplier: 1.30,
138 })
139 }),
140 },
141 CreatePlaybookVersion: []gax.CallOption{
142 gax.WithTimeout(60000 * time.Millisecond),
143 gax.WithRetry(func() gax.Retryer {
144 return gax.OnCodes([]codes.Code{
145 codes.Unavailable,
146 }, gax.Backoff{
147 Initial: 100 * time.Millisecond,
148 Max: 60000 * time.Millisecond,
149 Multiplier: 1.30,
150 })
151 }),
152 },
153 GetPlaybookVersion: []gax.CallOption{
154 gax.WithTimeout(60000 * time.Millisecond),
155 gax.WithRetry(func() gax.Retryer {
156 return gax.OnCodes([]codes.Code{
157 codes.Unavailable,
158 }, gax.Backoff{
159 Initial: 100 * time.Millisecond,
160 Max: 60000 * time.Millisecond,
161 Multiplier: 1.30,
162 })
163 }),
164 },
165 ListPlaybookVersions: []gax.CallOption{
166 gax.WithTimeout(60000 * time.Millisecond),
167 gax.WithRetry(func() gax.Retryer {
168 return gax.OnCodes([]codes.Code{
169 codes.Unavailable,
170 }, gax.Backoff{
171 Initial: 100 * time.Millisecond,
172 Max: 60000 * time.Millisecond,
173 Multiplier: 1.30,
174 })
175 }),
176 },
177 DeletePlaybookVersion: []gax.CallOption{
178 gax.WithTimeout(60000 * time.Millisecond),
179 gax.WithRetry(func() gax.Retryer {
180 return gax.OnCodes([]codes.Code{
181 codes.Unavailable,
182 }, gax.Backoff{
183 Initial: 100 * time.Millisecond,
184 Max: 60000 * time.Millisecond,
185 Multiplier: 1.30,
186 })
187 }),
188 },
189 GetLocation: []gax.CallOption{},
190 ListLocations: []gax.CallOption{},
191 CancelOperation: []gax.CallOption{},
192 GetOperation: []gax.CallOption{},
193 ListOperations: []gax.CallOption{},
194 }
195 }
196
197 func defaultPlaybooksRESTCallOptions() *PlaybooksCallOptions {
198 return &PlaybooksCallOptions{
199 CreatePlaybook: []gax.CallOption{
200 gax.WithTimeout(60000 * time.Millisecond),
201 gax.WithRetry(func() gax.Retryer {
202 return gax.OnHTTPCodes(gax.Backoff{
203 Initial: 100 * time.Millisecond,
204 Max: 60000 * time.Millisecond,
205 Multiplier: 1.30,
206 },
207 http.StatusServiceUnavailable)
208 }),
209 },
210 DeletePlaybook: []gax.CallOption{
211 gax.WithTimeout(60000 * time.Millisecond),
212 gax.WithRetry(func() gax.Retryer {
213 return gax.OnHTTPCodes(gax.Backoff{
214 Initial: 100 * time.Millisecond,
215 Max: 60000 * time.Millisecond,
216 Multiplier: 1.30,
217 },
218 http.StatusServiceUnavailable)
219 }),
220 },
221 ListPlaybooks: []gax.CallOption{
222 gax.WithTimeout(60000 * time.Millisecond),
223 gax.WithRetry(func() gax.Retryer {
224 return gax.OnHTTPCodes(gax.Backoff{
225 Initial: 100 * time.Millisecond,
226 Max: 60000 * time.Millisecond,
227 Multiplier: 1.30,
228 },
229 http.StatusServiceUnavailable)
230 }),
231 },
232 GetPlaybook: []gax.CallOption{
233 gax.WithTimeout(60000 * time.Millisecond),
234 gax.WithRetry(func() gax.Retryer {
235 return gax.OnHTTPCodes(gax.Backoff{
236 Initial: 100 * time.Millisecond,
237 Max: 60000 * time.Millisecond,
238 Multiplier: 1.30,
239 },
240 http.StatusServiceUnavailable)
241 }),
242 },
243 UpdatePlaybook: []gax.CallOption{
244 gax.WithTimeout(60000 * time.Millisecond),
245 gax.WithRetry(func() gax.Retryer {
246 return gax.OnHTTPCodes(gax.Backoff{
247 Initial: 100 * time.Millisecond,
248 Max: 60000 * time.Millisecond,
249 Multiplier: 1.30,
250 },
251 http.StatusServiceUnavailable)
252 }),
253 },
254 CreatePlaybookVersion: []gax.CallOption{
255 gax.WithTimeout(60000 * time.Millisecond),
256 gax.WithRetry(func() gax.Retryer {
257 return gax.OnHTTPCodes(gax.Backoff{
258 Initial: 100 * time.Millisecond,
259 Max: 60000 * time.Millisecond,
260 Multiplier: 1.30,
261 },
262 http.StatusServiceUnavailable)
263 }),
264 },
265 GetPlaybookVersion: []gax.CallOption{
266 gax.WithTimeout(60000 * time.Millisecond),
267 gax.WithRetry(func() gax.Retryer {
268 return gax.OnHTTPCodes(gax.Backoff{
269 Initial: 100 * time.Millisecond,
270 Max: 60000 * time.Millisecond,
271 Multiplier: 1.30,
272 },
273 http.StatusServiceUnavailable)
274 }),
275 },
276 ListPlaybookVersions: []gax.CallOption{
277 gax.WithTimeout(60000 * time.Millisecond),
278 gax.WithRetry(func() gax.Retryer {
279 return gax.OnHTTPCodes(gax.Backoff{
280 Initial: 100 * time.Millisecond,
281 Max: 60000 * time.Millisecond,
282 Multiplier: 1.30,
283 },
284 http.StatusServiceUnavailable)
285 }),
286 },
287 DeletePlaybookVersion: []gax.CallOption{
288 gax.WithTimeout(60000 * time.Millisecond),
289 gax.WithRetry(func() gax.Retryer {
290 return gax.OnHTTPCodes(gax.Backoff{
291 Initial: 100 * time.Millisecond,
292 Max: 60000 * time.Millisecond,
293 Multiplier: 1.30,
294 },
295 http.StatusServiceUnavailable)
296 }),
297 },
298 GetLocation: []gax.CallOption{},
299 ListLocations: []gax.CallOption{},
300 CancelOperation: []gax.CallOption{},
301 GetOperation: []gax.CallOption{},
302 ListOperations: []gax.CallOption{},
303 }
304 }
305
306 // internalPlaybooksClient is an interface that defines the methods available from Dialogflow API.
307 type internalPlaybooksClient interface {
308 Close() error
309 setGoogleClientInfo(...string)
310 Connection() *grpc.ClientConn
311 CreatePlaybook(context.Context, *cxpb.CreatePlaybookRequest, ...gax.CallOption) (*cxpb.Playbook, error)
312 DeletePlaybook(context.Context, *cxpb.DeletePlaybookRequest, ...gax.CallOption) error
313 ListPlaybooks(context.Context, *cxpb.ListPlaybooksRequest, ...gax.CallOption) *PlaybookIterator
314 GetPlaybook(context.Context, *cxpb.GetPlaybookRequest, ...gax.CallOption) (*cxpb.Playbook, error)
315 UpdatePlaybook(context.Context, *cxpb.UpdatePlaybookRequest, ...gax.CallOption) (*cxpb.Playbook, error)
316 CreatePlaybookVersion(context.Context, *cxpb.CreatePlaybookVersionRequest, ...gax.CallOption) (*cxpb.PlaybookVersion, error)
317 GetPlaybookVersion(context.Context, *cxpb.GetPlaybookVersionRequest, ...gax.CallOption) (*cxpb.PlaybookVersion, error)
318 ListPlaybookVersions(context.Context, *cxpb.ListPlaybookVersionsRequest, ...gax.CallOption) *PlaybookVersionIterator
319 DeletePlaybookVersion(context.Context, *cxpb.DeletePlaybookVersionRequest, ...gax.CallOption) error
320 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
321 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
322 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
323 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
324 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
325 }
326
327 // PlaybooksClient is a client for interacting with Dialogflow API.
328 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
329 //
330 // Service for managing
331 // Playbooks.
332 type PlaybooksClient struct {
333 // The internal transport-dependent client.
334 internalClient internalPlaybooksClient
335
336 // The call options for this service.
337 CallOptions *PlaybooksCallOptions
338 }
339
340 // Wrapper methods routed to the internal client.
341
342 // Close closes the connection to the API service. The user should invoke this when
343 // the client is no longer required.
344 func (c *PlaybooksClient) Close() error {
345 return c.internalClient.Close()
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 *PlaybooksClient) setGoogleClientInfo(keyval ...string) {
352 c.internalClient.setGoogleClientInfo(keyval...)
353 }
354
355 // Connection returns a connection to the API service.
356 //
357 // Deprecated: Connections are now pooled so this method does not always
358 // return the same resource.
359 func (c *PlaybooksClient) Connection() *grpc.ClientConn {
360 return c.internalClient.Connection()
361 }
362
363 // CreatePlaybook creates a playbook in a specified agent.
364 func (c *PlaybooksClient) CreatePlaybook(ctx context.Context, req *cxpb.CreatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
365 return c.internalClient.CreatePlaybook(ctx, req, opts...)
366 }
367
368 // DeletePlaybook deletes a specified playbook.
369 func (c *PlaybooksClient) DeletePlaybook(ctx context.Context, req *cxpb.DeletePlaybookRequest, opts ...gax.CallOption) error {
370 return c.internalClient.DeletePlaybook(ctx, req, opts...)
371 }
372
373 // ListPlaybooks returns a list of playbooks in the specified agent.
374 func (c *PlaybooksClient) ListPlaybooks(ctx context.Context, req *cxpb.ListPlaybooksRequest, opts ...gax.CallOption) *PlaybookIterator {
375 return c.internalClient.ListPlaybooks(ctx, req, opts...)
376 }
377
378 // GetPlaybook retrieves the specified Playbook.
379 func (c *PlaybooksClient) GetPlaybook(ctx context.Context, req *cxpb.GetPlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
380 return c.internalClient.GetPlaybook(ctx, req, opts...)
381 }
382
383 // UpdatePlaybook updates the specified Playbook.
384 func (c *PlaybooksClient) UpdatePlaybook(ctx context.Context, req *cxpb.UpdatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
385 return c.internalClient.UpdatePlaybook(ctx, req, opts...)
386 }
387
388 // CreatePlaybookVersion creates a version for the specified Playbook.
389 func (c *PlaybooksClient) CreatePlaybookVersion(ctx context.Context, req *cxpb.CreatePlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
390 return c.internalClient.CreatePlaybookVersion(ctx, req, opts...)
391 }
392
393 // GetPlaybookVersion retrieves the specified version of the Playbook.
394 func (c *PlaybooksClient) GetPlaybookVersion(ctx context.Context, req *cxpb.GetPlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
395 return c.internalClient.GetPlaybookVersion(ctx, req, opts...)
396 }
397
398 // ListPlaybookVersions lists versions for the specified Playbook.
399 func (c *PlaybooksClient) ListPlaybookVersions(ctx context.Context, req *cxpb.ListPlaybookVersionsRequest, opts ...gax.CallOption) *PlaybookVersionIterator {
400 return c.internalClient.ListPlaybookVersions(ctx, req, opts...)
401 }
402
403 // DeletePlaybookVersion deletes the specified version of the Playbook.
404 func (c *PlaybooksClient) DeletePlaybookVersion(ctx context.Context, req *cxpb.DeletePlaybookVersionRequest, opts ...gax.CallOption) error {
405 return c.internalClient.DeletePlaybookVersion(ctx, req, opts...)
406 }
407
408 // GetLocation gets information about a location.
409 func (c *PlaybooksClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
410 return c.internalClient.GetLocation(ctx, req, opts...)
411 }
412
413 // ListLocations lists information about the supported locations for this service.
414 func (c *PlaybooksClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
415 return c.internalClient.ListLocations(ctx, req, opts...)
416 }
417
418 // CancelOperation is a utility method from google.longrunning.Operations.
419 func (c *PlaybooksClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
420 return c.internalClient.CancelOperation(ctx, req, opts...)
421 }
422
423 // GetOperation is a utility method from google.longrunning.Operations.
424 func (c *PlaybooksClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
425 return c.internalClient.GetOperation(ctx, req, opts...)
426 }
427
428 // ListOperations is a utility method from google.longrunning.Operations.
429 func (c *PlaybooksClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
430 return c.internalClient.ListOperations(ctx, req, opts...)
431 }
432
433 // playbooksGRPCClient is a client for interacting with Dialogflow API over gRPC transport.
434 //
435 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
436 type playbooksGRPCClient struct {
437 // Connection pool of gRPC connections to the service.
438 connPool gtransport.ConnPool
439
440 // Points back to the CallOptions field of the containing PlaybooksClient
441 CallOptions **PlaybooksCallOptions
442
443 // The gRPC API client.
444 playbooksClient cxpb.PlaybooksClient
445
446 operationsClient longrunningpb.OperationsClient
447
448 locationsClient locationpb.LocationsClient
449
450 // The x-goog-* metadata to be sent with each request.
451 xGoogHeaders []string
452
453 logger *slog.Logger
454 }
455
456 // NewPlaybooksClient creates a new playbooks client based on gRPC.
457 // The returned client must be Closed when it is done being used to clean up its underlying connections.
458 //
459 // Service for managing
460 // Playbooks.
461 func NewPlaybooksClient(ctx context.Context, opts ...option.ClientOption) (*PlaybooksClient, error) {
462 clientOpts := defaultPlaybooksGRPCClientOptions()
463 if newPlaybooksClientHook != nil {
464 hookOpts, err := newPlaybooksClientHook(ctx, clientHookParams{})
465 if err != nil {
466 return nil, err
467 }
468 clientOpts = append(clientOpts, hookOpts...)
469 }
470
471 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
472 if err != nil {
473 return nil, err
474 }
475 client := PlaybooksClient{CallOptions: defaultPlaybooksCallOptions()}
476
477 c := &playbooksGRPCClient{
478 connPool: connPool,
479 playbooksClient: cxpb.NewPlaybooksClient(connPool),
480 CallOptions: &client.CallOptions,
481 logger: internaloption.GetLogger(opts),
482 operationsClient: longrunningpb.NewOperationsClient(connPool),
483 locationsClient: locationpb.NewLocationsClient(connPool),
484 }
485 c.setGoogleClientInfo()
486
487 client.internalClient = c
488
489 return &client, nil
490 }
491
492 // Connection returns a connection to the API service.
493 //
494 // Deprecated: Connections are now pooled so this method does not always
495 // return the same resource.
496 func (c *playbooksGRPCClient) Connection() *grpc.ClientConn {
497 return c.connPool.Conn()
498 }
499
500 // setGoogleClientInfo sets the name and version of the application in
501 // the `x-goog-api-client` header passed on each request. Intended for
502 // use by Google-written clients.
503 func (c *playbooksGRPCClient) setGoogleClientInfo(keyval ...string) {
504 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
505 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
506 c.xGoogHeaders = []string{
507 "x-goog-api-client", gax.XGoogHeader(kv...),
508 }
509 }
510
511 // Close closes the connection to the API service. The user should invoke this when
512 // the client is no longer required.
513 func (c *playbooksGRPCClient) Close() error {
514 return c.connPool.Close()
515 }
516
517 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
518 type playbooksRESTClient struct {
519 // The http endpoint to connect to.
520 endpoint string
521
522 // The http client.
523 httpClient *http.Client
524
525 // The x-goog-* headers to be sent with each request.
526 xGoogHeaders []string
527
528 // Points back to the CallOptions field of the containing PlaybooksClient
529 CallOptions **PlaybooksCallOptions
530
531 logger *slog.Logger
532 }
533
534 // NewPlaybooksRESTClient creates a new playbooks rest client.
535 //
536 // Service for managing
537 // Playbooks.
538 func NewPlaybooksRESTClient(ctx context.Context, opts ...option.ClientOption) (*PlaybooksClient, error) {
539 clientOpts := append(defaultPlaybooksRESTClientOptions(), opts...)
540 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
541 if err != nil {
542 return nil, err
543 }
544
545 callOpts := defaultPlaybooksRESTCallOptions()
546 c := &playbooksRESTClient{
547 endpoint: endpoint,
548 httpClient: httpClient,
549 CallOptions: &callOpts,
550 logger: internaloption.GetLogger(opts),
551 }
552 c.setGoogleClientInfo()
553
554 return &PlaybooksClient{internalClient: c, CallOptions: callOpts}, nil
555 }
556
557 func defaultPlaybooksRESTClientOptions() []option.ClientOption {
558 return []option.ClientOption{
559 internaloption.WithDefaultEndpoint("https://dialogflow.googleapis.com"),
560 internaloption.WithDefaultEndpointTemplate("https://dialogflow.UNIVERSE_DOMAIN"),
561 internaloption.WithDefaultMTLSEndpoint("https://dialogflow.mtls.googleapis.com"),
562 internaloption.WithDefaultUniverseDomain("googleapis.com"),
563 internaloption.WithDefaultAudience("https://dialogflow.googleapis.com/"),
564 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
565 internaloption.EnableNewAuthLibrary(),
566 }
567 }
568
569 // setGoogleClientInfo sets the name and version of the application in
570 // the `x-goog-api-client` header passed on each request. Intended for
571 // use by Google-written clients.
572 func (c *playbooksRESTClient) setGoogleClientInfo(keyval ...string) {
573 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
574 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
575 c.xGoogHeaders = []string{
576 "x-goog-api-client", gax.XGoogHeader(kv...),
577 }
578 }
579
580 // Close closes the connection to the API service. The user should invoke this when
581 // the client is no longer required.
582 func (c *playbooksRESTClient) Close() error {
583 // Replace httpClient with nil to force cleanup.
584 c.httpClient = nil
585 return nil
586 }
587
588 // Connection returns a connection to the API service.
589 //
590 // Deprecated: This method always returns nil.
591 func (c *playbooksRESTClient) Connection() *grpc.ClientConn {
592 return nil
593 }
594 func (c *playbooksGRPCClient) CreatePlaybook(ctx context.Context, req *cxpb.CreatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
595 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
596
597 hds = append(c.xGoogHeaders, hds...)
598 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
599 opts = append((*c.CallOptions).CreatePlaybook[0:len((*c.CallOptions).CreatePlaybook):len((*c.CallOptions).CreatePlaybook)], opts...)
600 var resp *cxpb.Playbook
601 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
602 var err error
603 resp, err = executeRPC(ctx, c.playbooksClient.CreatePlaybook, req, settings.GRPC, c.logger, "CreatePlaybook")
604 return err
605 }, opts...)
606 if err != nil {
607 return nil, err
608 }
609 return resp, nil
610 }
611
612 func (c *playbooksGRPCClient) DeletePlaybook(ctx context.Context, req *cxpb.DeletePlaybookRequest, opts ...gax.CallOption) error {
613 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
614
615 hds = append(c.xGoogHeaders, hds...)
616 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
617 opts = append((*c.CallOptions).DeletePlaybook[0:len((*c.CallOptions).DeletePlaybook):len((*c.CallOptions).DeletePlaybook)], opts...)
618 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
619 var err error
620 _, err = executeRPC(ctx, c.playbooksClient.DeletePlaybook, req, settings.GRPC, c.logger, "DeletePlaybook")
621 return err
622 }, opts...)
623 return err
624 }
625
626 func (c *playbooksGRPCClient) ListPlaybooks(ctx context.Context, req *cxpb.ListPlaybooksRequest, opts ...gax.CallOption) *PlaybookIterator {
627 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
628
629 hds = append(c.xGoogHeaders, hds...)
630 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
631 opts = append((*c.CallOptions).ListPlaybooks[0:len((*c.CallOptions).ListPlaybooks):len((*c.CallOptions).ListPlaybooks)], opts...)
632 it := &PlaybookIterator{}
633 req = proto.Clone(req).(*cxpb.ListPlaybooksRequest)
634 it.InternalFetch = func(pageSize int, pageToken string) ([]*cxpb.Playbook, string, error) {
635 resp := &cxpb.ListPlaybooksResponse{}
636 if pageToken != "" {
637 req.PageToken = pageToken
638 }
639 if pageSize > math.MaxInt32 {
640 req.PageSize = math.MaxInt32
641 } else if pageSize != 0 {
642 req.PageSize = int32(pageSize)
643 }
644 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
645 var err error
646 resp, err = executeRPC(ctx, c.playbooksClient.ListPlaybooks, req, settings.GRPC, c.logger, "ListPlaybooks")
647 return err
648 }, opts...)
649 if err != nil {
650 return nil, "", err
651 }
652
653 it.Response = resp
654 return resp.GetPlaybooks(), resp.GetNextPageToken(), nil
655 }
656 fetch := func(pageSize int, pageToken string) (string, error) {
657 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
658 if err != nil {
659 return "", err
660 }
661 it.items = append(it.items, items...)
662 return nextPageToken, nil
663 }
664
665 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
666 it.pageInfo.MaxSize = int(req.GetPageSize())
667 it.pageInfo.Token = req.GetPageToken()
668
669 return it
670 }
671
672 func (c *playbooksGRPCClient) GetPlaybook(ctx context.Context, req *cxpb.GetPlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
673 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
674
675 hds = append(c.xGoogHeaders, hds...)
676 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
677 opts = append((*c.CallOptions).GetPlaybook[0:len((*c.CallOptions).GetPlaybook):len((*c.CallOptions).GetPlaybook)], opts...)
678 var resp *cxpb.Playbook
679 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
680 var err error
681 resp, err = executeRPC(ctx, c.playbooksClient.GetPlaybook, req, settings.GRPC, c.logger, "GetPlaybook")
682 return err
683 }, opts...)
684 if err != nil {
685 return nil, err
686 }
687 return resp, nil
688 }
689
690 func (c *playbooksGRPCClient) UpdatePlaybook(ctx context.Context, req *cxpb.UpdatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
691 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "playbook.name", url.QueryEscape(req.GetPlaybook().GetName()))}
692
693 hds = append(c.xGoogHeaders, hds...)
694 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
695 opts = append((*c.CallOptions).UpdatePlaybook[0:len((*c.CallOptions).UpdatePlaybook):len((*c.CallOptions).UpdatePlaybook)], opts...)
696 var resp *cxpb.Playbook
697 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
698 var err error
699 resp, err = executeRPC(ctx, c.playbooksClient.UpdatePlaybook, req, settings.GRPC, c.logger, "UpdatePlaybook")
700 return err
701 }, opts...)
702 if err != nil {
703 return nil, err
704 }
705 return resp, nil
706 }
707
708 func (c *playbooksGRPCClient) CreatePlaybookVersion(ctx context.Context, req *cxpb.CreatePlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
709 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
710
711 hds = append(c.xGoogHeaders, hds...)
712 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
713 opts = append((*c.CallOptions).CreatePlaybookVersion[0:len((*c.CallOptions).CreatePlaybookVersion):len((*c.CallOptions).CreatePlaybookVersion)], opts...)
714 var resp *cxpb.PlaybookVersion
715 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
716 var err error
717 resp, err = executeRPC(ctx, c.playbooksClient.CreatePlaybookVersion, req, settings.GRPC, c.logger, "CreatePlaybookVersion")
718 return err
719 }, opts...)
720 if err != nil {
721 return nil, err
722 }
723 return resp, nil
724 }
725
726 func (c *playbooksGRPCClient) GetPlaybookVersion(ctx context.Context, req *cxpb.GetPlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
727 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
728
729 hds = append(c.xGoogHeaders, hds...)
730 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
731 opts = append((*c.CallOptions).GetPlaybookVersion[0:len((*c.CallOptions).GetPlaybookVersion):len((*c.CallOptions).GetPlaybookVersion)], opts...)
732 var resp *cxpb.PlaybookVersion
733 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
734 var err error
735 resp, err = executeRPC(ctx, c.playbooksClient.GetPlaybookVersion, req, settings.GRPC, c.logger, "GetPlaybookVersion")
736 return err
737 }, opts...)
738 if err != nil {
739 return nil, err
740 }
741 return resp, nil
742 }
743
744 func (c *playbooksGRPCClient) ListPlaybookVersions(ctx context.Context, req *cxpb.ListPlaybookVersionsRequest, opts ...gax.CallOption) *PlaybookVersionIterator {
745 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
746
747 hds = append(c.xGoogHeaders, hds...)
748 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
749 opts = append((*c.CallOptions).ListPlaybookVersions[0:len((*c.CallOptions).ListPlaybookVersions):len((*c.CallOptions).ListPlaybookVersions)], opts...)
750 it := &PlaybookVersionIterator{}
751 req = proto.Clone(req).(*cxpb.ListPlaybookVersionsRequest)
752 it.InternalFetch = func(pageSize int, pageToken string) ([]*cxpb.PlaybookVersion, string, error) {
753 resp := &cxpb.ListPlaybookVersionsResponse{}
754 if pageToken != "" {
755 req.PageToken = pageToken
756 }
757 if pageSize > math.MaxInt32 {
758 req.PageSize = math.MaxInt32
759 } else if pageSize != 0 {
760 req.PageSize = int32(pageSize)
761 }
762 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
763 var err error
764 resp, err = executeRPC(ctx, c.playbooksClient.ListPlaybookVersions, req, settings.GRPC, c.logger, "ListPlaybookVersions")
765 return err
766 }, opts...)
767 if err != nil {
768 return nil, "", err
769 }
770
771 it.Response = resp
772 return resp.GetPlaybookVersions(), resp.GetNextPageToken(), nil
773 }
774 fetch := func(pageSize int, pageToken string) (string, error) {
775 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
776 if err != nil {
777 return "", err
778 }
779 it.items = append(it.items, items...)
780 return nextPageToken, nil
781 }
782
783 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
784 it.pageInfo.MaxSize = int(req.GetPageSize())
785 it.pageInfo.Token = req.GetPageToken()
786
787 return it
788 }
789
790 func (c *playbooksGRPCClient) DeletePlaybookVersion(ctx context.Context, req *cxpb.DeletePlaybookVersionRequest, opts ...gax.CallOption) error {
791 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
792
793 hds = append(c.xGoogHeaders, hds...)
794 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
795 opts = append((*c.CallOptions).DeletePlaybookVersion[0:len((*c.CallOptions).DeletePlaybookVersion):len((*c.CallOptions).DeletePlaybookVersion)], opts...)
796 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
797 var err error
798 _, err = executeRPC(ctx, c.playbooksClient.DeletePlaybookVersion, req, settings.GRPC, c.logger, "DeletePlaybookVersion")
799 return err
800 }, opts...)
801 return err
802 }
803
804 func (c *playbooksGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
805 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
806
807 hds = append(c.xGoogHeaders, hds...)
808 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
809 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
810 var resp *locationpb.Location
811 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
812 var err error
813 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
814 return err
815 }, opts...)
816 if err != nil {
817 return nil, err
818 }
819 return resp, nil
820 }
821
822 func (c *playbooksGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
823 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
824
825 hds = append(c.xGoogHeaders, hds...)
826 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
827 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
828 it := &LocationIterator{}
829 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
830 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
831 resp := &locationpb.ListLocationsResponse{}
832 if pageToken != "" {
833 req.PageToken = pageToken
834 }
835 if pageSize > math.MaxInt32 {
836 req.PageSize = math.MaxInt32
837 } else if pageSize != 0 {
838 req.PageSize = int32(pageSize)
839 }
840 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
841 var err error
842 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
843 return err
844 }, opts...)
845 if err != nil {
846 return nil, "", err
847 }
848
849 it.Response = resp
850 return resp.GetLocations(), resp.GetNextPageToken(), nil
851 }
852 fetch := func(pageSize int, pageToken string) (string, error) {
853 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
854 if err != nil {
855 return "", err
856 }
857 it.items = append(it.items, items...)
858 return nextPageToken, nil
859 }
860
861 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
862 it.pageInfo.MaxSize = int(req.GetPageSize())
863 it.pageInfo.Token = req.GetPageToken()
864
865 return it
866 }
867
868 func (c *playbooksGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
869 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
870
871 hds = append(c.xGoogHeaders, hds...)
872 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
873 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
874 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
875 var err error
876 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
877 return err
878 }, opts...)
879 return err
880 }
881
882 func (c *playbooksGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
883 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
884
885 hds = append(c.xGoogHeaders, hds...)
886 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
887 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
888 var resp *longrunningpb.Operation
889 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
890 var err error
891 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
892 return err
893 }, opts...)
894 if err != nil {
895 return nil, err
896 }
897 return resp, nil
898 }
899
900 func (c *playbooksGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
901 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
902
903 hds = append(c.xGoogHeaders, hds...)
904 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
905 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
906 it := &OperationIterator{}
907 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
908 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
909 resp := &longrunningpb.ListOperationsResponse{}
910 if pageToken != "" {
911 req.PageToken = pageToken
912 }
913 if pageSize > math.MaxInt32 {
914 req.PageSize = math.MaxInt32
915 } else if pageSize != 0 {
916 req.PageSize = int32(pageSize)
917 }
918 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
919 var err error
920 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
921 return err
922 }, opts...)
923 if err != nil {
924 return nil, "", err
925 }
926
927 it.Response = resp
928 return resp.GetOperations(), resp.GetNextPageToken(), nil
929 }
930 fetch := func(pageSize int, pageToken string) (string, error) {
931 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
932 if err != nil {
933 return "", err
934 }
935 it.items = append(it.items, items...)
936 return nextPageToken, nil
937 }
938
939 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
940 it.pageInfo.MaxSize = int(req.GetPageSize())
941 it.pageInfo.Token = req.GetPageToken()
942
943 return it
944 }
945
946 // CreatePlaybook creates a playbook in a specified agent.
947 func (c *playbooksRESTClient) CreatePlaybook(ctx context.Context, req *cxpb.CreatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
948 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
949 body := req.GetPlaybook()
950 jsonReq, err := m.Marshal(body)
951 if err != nil {
952 return nil, err
953 }
954
955 baseUrl, err := url.Parse(c.endpoint)
956 if err != nil {
957 return nil, err
958 }
959 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/playbooks", req.GetParent())
960
961 params := url.Values{}
962 params.Add("$alt", "json;enum-encoding=int")
963
964 baseUrl.RawQuery = params.Encode()
965
966 // Build HTTP headers from client and context metadata.
967 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
968
969 hds = append(c.xGoogHeaders, hds...)
970 hds = append(hds, "Content-Type", "application/json")
971 headers := gax.BuildHeaders(ctx, hds...)
972 opts = append((*c.CallOptions).CreatePlaybook[0:len((*c.CallOptions).CreatePlaybook):len((*c.CallOptions).CreatePlaybook)], opts...)
973 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
974 resp := &cxpb.Playbook{}
975 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
976 if settings.Path != "" {
977 baseUrl.Path = settings.Path
978 }
979 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
980 if err != nil {
981 return err
982 }
983 httpReq = httpReq.WithContext(ctx)
984 httpReq.Header = headers
985
986 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreatePlaybook")
987 if err != nil {
988 return err
989 }
990
991 if err := unm.Unmarshal(buf, resp); err != nil {
992 return err
993 }
994
995 return nil
996 }, opts...)
997 if e != nil {
998 return nil, e
999 }
1000 return resp, nil
1001 }
1002
1003 // DeletePlaybook deletes a specified playbook.
1004 func (c *playbooksRESTClient) DeletePlaybook(ctx context.Context, req *cxpb.DeletePlaybookRequest, opts ...gax.CallOption) error {
1005 baseUrl, err := url.Parse(c.endpoint)
1006 if err != nil {
1007 return err
1008 }
1009 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1010
1011 params := url.Values{}
1012 params.Add("$alt", "json;enum-encoding=int")
1013
1014 baseUrl.RawQuery = params.Encode()
1015
1016 // Build HTTP headers from client and context metadata.
1017 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1018
1019 hds = append(c.xGoogHeaders, hds...)
1020 hds = append(hds, "Content-Type", "application/json")
1021 headers := gax.BuildHeaders(ctx, hds...)
1022 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1023 if settings.Path != "" {
1024 baseUrl.Path = settings.Path
1025 }
1026 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1027 if err != nil {
1028 return err
1029 }
1030 httpReq = httpReq.WithContext(ctx)
1031 httpReq.Header = headers
1032
1033 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeletePlaybook")
1034 return err
1035 }, opts...)
1036 }
1037
1038 // ListPlaybooks returns a list of playbooks in the specified agent.
1039 func (c *playbooksRESTClient) ListPlaybooks(ctx context.Context, req *cxpb.ListPlaybooksRequest, opts ...gax.CallOption) *PlaybookIterator {
1040 it := &PlaybookIterator{}
1041 req = proto.Clone(req).(*cxpb.ListPlaybooksRequest)
1042 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1043 it.InternalFetch = func(pageSize int, pageToken string) ([]*cxpb.Playbook, string, error) {
1044 resp := &cxpb.ListPlaybooksResponse{}
1045 if pageToken != "" {
1046 req.PageToken = pageToken
1047 }
1048 if pageSize > math.MaxInt32 {
1049 req.PageSize = math.MaxInt32
1050 } else if pageSize != 0 {
1051 req.PageSize = int32(pageSize)
1052 }
1053 baseUrl, err := url.Parse(c.endpoint)
1054 if err != nil {
1055 return nil, "", err
1056 }
1057 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/playbooks", req.GetParent())
1058
1059 params := url.Values{}
1060 params.Add("$alt", "json;enum-encoding=int")
1061 if req.GetPageSize() != 0 {
1062 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1063 }
1064 if req.GetPageToken() != "" {
1065 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1066 }
1067
1068 baseUrl.RawQuery = params.Encode()
1069
1070 // Build HTTP headers from client and context metadata.
1071 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1072 headers := gax.BuildHeaders(ctx, hds...)
1073 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1074 if settings.Path != "" {
1075 baseUrl.Path = settings.Path
1076 }
1077 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1078 if err != nil {
1079 return err
1080 }
1081 httpReq.Header = headers
1082
1083 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPlaybooks")
1084 if err != nil {
1085 return err
1086 }
1087 if err := unm.Unmarshal(buf, resp); err != nil {
1088 return err
1089 }
1090
1091 return nil
1092 }, opts...)
1093 if e != nil {
1094 return nil, "", e
1095 }
1096 it.Response = resp
1097 return resp.GetPlaybooks(), resp.GetNextPageToken(), nil
1098 }
1099
1100 fetch := func(pageSize int, pageToken string) (string, error) {
1101 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1102 if err != nil {
1103 return "", err
1104 }
1105 it.items = append(it.items, items...)
1106 return nextPageToken, nil
1107 }
1108
1109 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1110 it.pageInfo.MaxSize = int(req.GetPageSize())
1111 it.pageInfo.Token = req.GetPageToken()
1112
1113 return it
1114 }
1115
1116 // GetPlaybook retrieves the specified Playbook.
1117 func (c *playbooksRESTClient) GetPlaybook(ctx context.Context, req *cxpb.GetPlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
1118 baseUrl, err := url.Parse(c.endpoint)
1119 if err != nil {
1120 return nil, err
1121 }
1122 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1123
1124 params := url.Values{}
1125 params.Add("$alt", "json;enum-encoding=int")
1126
1127 baseUrl.RawQuery = params.Encode()
1128
1129 // Build HTTP headers from client and context metadata.
1130 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1131
1132 hds = append(c.xGoogHeaders, hds...)
1133 hds = append(hds, "Content-Type", "application/json")
1134 headers := gax.BuildHeaders(ctx, hds...)
1135 opts = append((*c.CallOptions).GetPlaybook[0:len((*c.CallOptions).GetPlaybook):len((*c.CallOptions).GetPlaybook)], opts...)
1136 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1137 resp := &cxpb.Playbook{}
1138 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1139 if settings.Path != "" {
1140 baseUrl.Path = settings.Path
1141 }
1142 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1143 if err != nil {
1144 return err
1145 }
1146 httpReq = httpReq.WithContext(ctx)
1147 httpReq.Header = headers
1148
1149 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPlaybook")
1150 if err != nil {
1151 return err
1152 }
1153
1154 if err := unm.Unmarshal(buf, resp); err != nil {
1155 return err
1156 }
1157
1158 return nil
1159 }, opts...)
1160 if e != nil {
1161 return nil, e
1162 }
1163 return resp, nil
1164 }
1165
1166 // UpdatePlaybook updates the specified Playbook.
1167 func (c *playbooksRESTClient) UpdatePlaybook(ctx context.Context, req *cxpb.UpdatePlaybookRequest, opts ...gax.CallOption) (*cxpb.Playbook, error) {
1168 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1169 body := req.GetPlaybook()
1170 jsonReq, err := m.Marshal(body)
1171 if err != nil {
1172 return nil, err
1173 }
1174
1175 baseUrl, err := url.Parse(c.endpoint)
1176 if err != nil {
1177 return nil, err
1178 }
1179 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetPlaybook().GetName())
1180
1181 params := url.Values{}
1182 params.Add("$alt", "json;enum-encoding=int")
1183 if req.GetUpdateMask() != nil {
1184 field, err := protojson.Marshal(req.GetUpdateMask())
1185 if err != nil {
1186 return nil, err
1187 }
1188 params.Add("updateMask", string(field[1:len(field)-1]))
1189 }
1190
1191 baseUrl.RawQuery = params.Encode()
1192
1193 // Build HTTP headers from client and context metadata.
1194 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "playbook.name", url.QueryEscape(req.GetPlaybook().GetName()))}
1195
1196 hds = append(c.xGoogHeaders, hds...)
1197 hds = append(hds, "Content-Type", "application/json")
1198 headers := gax.BuildHeaders(ctx, hds...)
1199 opts = append((*c.CallOptions).UpdatePlaybook[0:len((*c.CallOptions).UpdatePlaybook):len((*c.CallOptions).UpdatePlaybook)], opts...)
1200 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1201 resp := &cxpb.Playbook{}
1202 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1203 if settings.Path != "" {
1204 baseUrl.Path = settings.Path
1205 }
1206 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1207 if err != nil {
1208 return err
1209 }
1210 httpReq = httpReq.WithContext(ctx)
1211 httpReq.Header = headers
1212
1213 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdatePlaybook")
1214 if err != nil {
1215 return err
1216 }
1217
1218 if err := unm.Unmarshal(buf, resp); err != nil {
1219 return err
1220 }
1221
1222 return nil
1223 }, opts...)
1224 if e != nil {
1225 return nil, e
1226 }
1227 return resp, nil
1228 }
1229
1230 // CreatePlaybookVersion creates a version for the specified Playbook.
1231 func (c *playbooksRESTClient) CreatePlaybookVersion(ctx context.Context, req *cxpb.CreatePlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
1232 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1233 body := req.GetPlaybookVersion()
1234 jsonReq, err := m.Marshal(body)
1235 if err != nil {
1236 return nil, err
1237 }
1238
1239 baseUrl, err := url.Parse(c.endpoint)
1240 if err != nil {
1241 return nil, err
1242 }
1243 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/versions", req.GetParent())
1244
1245 params := url.Values{}
1246 params.Add("$alt", "json;enum-encoding=int")
1247
1248 baseUrl.RawQuery = params.Encode()
1249
1250 // Build HTTP headers from client and context metadata.
1251 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1252
1253 hds = append(c.xGoogHeaders, hds...)
1254 hds = append(hds, "Content-Type", "application/json")
1255 headers := gax.BuildHeaders(ctx, hds...)
1256 opts = append((*c.CallOptions).CreatePlaybookVersion[0:len((*c.CallOptions).CreatePlaybookVersion):len((*c.CallOptions).CreatePlaybookVersion)], opts...)
1257 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1258 resp := &cxpb.PlaybookVersion{}
1259 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1260 if settings.Path != "" {
1261 baseUrl.Path = settings.Path
1262 }
1263 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1264 if err != nil {
1265 return err
1266 }
1267 httpReq = httpReq.WithContext(ctx)
1268 httpReq.Header = headers
1269
1270 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreatePlaybookVersion")
1271 if err != nil {
1272 return err
1273 }
1274
1275 if err := unm.Unmarshal(buf, resp); err != nil {
1276 return err
1277 }
1278
1279 return nil
1280 }, opts...)
1281 if e != nil {
1282 return nil, e
1283 }
1284 return resp, nil
1285 }
1286
1287 // GetPlaybookVersion retrieves the specified version of the Playbook.
1288 func (c *playbooksRESTClient) GetPlaybookVersion(ctx context.Context, req *cxpb.GetPlaybookVersionRequest, opts ...gax.CallOption) (*cxpb.PlaybookVersion, error) {
1289 baseUrl, err := url.Parse(c.endpoint)
1290 if err != nil {
1291 return nil, err
1292 }
1293 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1294
1295 params := url.Values{}
1296 params.Add("$alt", "json;enum-encoding=int")
1297
1298 baseUrl.RawQuery = params.Encode()
1299
1300 // Build HTTP headers from client and context metadata.
1301 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1302
1303 hds = append(c.xGoogHeaders, hds...)
1304 hds = append(hds, "Content-Type", "application/json")
1305 headers := gax.BuildHeaders(ctx, hds...)
1306 opts = append((*c.CallOptions).GetPlaybookVersion[0:len((*c.CallOptions).GetPlaybookVersion):len((*c.CallOptions).GetPlaybookVersion)], opts...)
1307 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1308 resp := &cxpb.PlaybookVersion{}
1309 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1310 if settings.Path != "" {
1311 baseUrl.Path = settings.Path
1312 }
1313 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1314 if err != nil {
1315 return err
1316 }
1317 httpReq = httpReq.WithContext(ctx)
1318 httpReq.Header = headers
1319
1320 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPlaybookVersion")
1321 if err != nil {
1322 return err
1323 }
1324
1325 if err := unm.Unmarshal(buf, resp); err != nil {
1326 return err
1327 }
1328
1329 return nil
1330 }, opts...)
1331 if e != nil {
1332 return nil, e
1333 }
1334 return resp, nil
1335 }
1336
1337 // ListPlaybookVersions lists versions for the specified Playbook.
1338 func (c *playbooksRESTClient) ListPlaybookVersions(ctx context.Context, req *cxpb.ListPlaybookVersionsRequest, opts ...gax.CallOption) *PlaybookVersionIterator {
1339 it := &PlaybookVersionIterator{}
1340 req = proto.Clone(req).(*cxpb.ListPlaybookVersionsRequest)
1341 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1342 it.InternalFetch = func(pageSize int, pageToken string) ([]*cxpb.PlaybookVersion, string, error) {
1343 resp := &cxpb.ListPlaybookVersionsResponse{}
1344 if pageToken != "" {
1345 req.PageToken = pageToken
1346 }
1347 if pageSize > math.MaxInt32 {
1348 req.PageSize = math.MaxInt32
1349 } else if pageSize != 0 {
1350 req.PageSize = int32(pageSize)
1351 }
1352 baseUrl, err := url.Parse(c.endpoint)
1353 if err != nil {
1354 return nil, "", err
1355 }
1356 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/versions", req.GetParent())
1357
1358 params := url.Values{}
1359 params.Add("$alt", "json;enum-encoding=int")
1360 if req.GetPageSize() != 0 {
1361 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1362 }
1363 if req.GetPageToken() != "" {
1364 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1365 }
1366
1367 baseUrl.RawQuery = params.Encode()
1368
1369 // Build HTTP headers from client and context metadata.
1370 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1371 headers := gax.BuildHeaders(ctx, hds...)
1372 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1373 if settings.Path != "" {
1374 baseUrl.Path = settings.Path
1375 }
1376 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1377 if err != nil {
1378 return err
1379 }
1380 httpReq.Header = headers
1381
1382 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPlaybookVersions")
1383 if err != nil {
1384 return err
1385 }
1386 if err := unm.Unmarshal(buf, resp); err != nil {
1387 return err
1388 }
1389
1390 return nil
1391 }, opts...)
1392 if e != nil {
1393 return nil, "", e
1394 }
1395 it.Response = resp
1396 return resp.GetPlaybookVersions(), resp.GetNextPageToken(), nil
1397 }
1398
1399 fetch := func(pageSize int, pageToken string) (string, error) {
1400 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1401 if err != nil {
1402 return "", err
1403 }
1404 it.items = append(it.items, items...)
1405 return nextPageToken, nil
1406 }
1407
1408 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1409 it.pageInfo.MaxSize = int(req.GetPageSize())
1410 it.pageInfo.Token = req.GetPageToken()
1411
1412 return it
1413 }
1414
1415 // DeletePlaybookVersion deletes the specified version of the Playbook.
1416 func (c *playbooksRESTClient) DeletePlaybookVersion(ctx context.Context, req *cxpb.DeletePlaybookVersionRequest, opts ...gax.CallOption) error {
1417 baseUrl, err := url.Parse(c.endpoint)
1418 if err != nil {
1419 return err
1420 }
1421 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1422
1423 params := url.Values{}
1424 params.Add("$alt", "json;enum-encoding=int")
1425
1426 baseUrl.RawQuery = params.Encode()
1427
1428 // Build HTTP headers from client and context metadata.
1429 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1430
1431 hds = append(c.xGoogHeaders, hds...)
1432 hds = append(hds, "Content-Type", "application/json")
1433 headers := gax.BuildHeaders(ctx, hds...)
1434 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1435 if settings.Path != "" {
1436 baseUrl.Path = settings.Path
1437 }
1438 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1439 if err != nil {
1440 return err
1441 }
1442 httpReq = httpReq.WithContext(ctx)
1443 httpReq.Header = headers
1444
1445 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeletePlaybookVersion")
1446 return err
1447 }, opts...)
1448 }
1449
1450 // GetLocation gets information about a location.
1451 func (c *playbooksRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1452 baseUrl, err := url.Parse(c.endpoint)
1453 if err != nil {
1454 return nil, err
1455 }
1456 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1457
1458 params := url.Values{}
1459 params.Add("$alt", "json;enum-encoding=int")
1460
1461 baseUrl.RawQuery = params.Encode()
1462
1463 // Build HTTP headers from client and context metadata.
1464 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1465
1466 hds = append(c.xGoogHeaders, hds...)
1467 hds = append(hds, "Content-Type", "application/json")
1468 headers := gax.BuildHeaders(ctx, hds...)
1469 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1470 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1471 resp := &locationpb.Location{}
1472 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1473 if settings.Path != "" {
1474 baseUrl.Path = settings.Path
1475 }
1476 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1477 if err != nil {
1478 return err
1479 }
1480 httpReq = httpReq.WithContext(ctx)
1481 httpReq.Header = headers
1482
1483 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
1484 if err != nil {
1485 return err
1486 }
1487
1488 if err := unm.Unmarshal(buf, resp); err != nil {
1489 return err
1490 }
1491
1492 return nil
1493 }, opts...)
1494 if e != nil {
1495 return nil, e
1496 }
1497 return resp, nil
1498 }
1499
1500 // ListLocations lists information about the supported locations for this service.
1501 func (c *playbooksRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1502 it := &LocationIterator{}
1503 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1504 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1505 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1506 resp := &locationpb.ListLocationsResponse{}
1507 if pageToken != "" {
1508 req.PageToken = pageToken
1509 }
1510 if pageSize > math.MaxInt32 {
1511 req.PageSize = math.MaxInt32
1512 } else if pageSize != 0 {
1513 req.PageSize = int32(pageSize)
1514 }
1515 baseUrl, err := url.Parse(c.endpoint)
1516 if err != nil {
1517 return nil, "", err
1518 }
1519 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/locations", req.GetName())
1520
1521 params := url.Values{}
1522 params.Add("$alt", "json;enum-encoding=int")
1523 if req.GetFilter() != "" {
1524 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1525 }
1526 if req.GetPageSize() != 0 {
1527 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1528 }
1529 if req.GetPageToken() != "" {
1530 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1531 }
1532
1533 baseUrl.RawQuery = params.Encode()
1534
1535 // Build HTTP headers from client and context metadata.
1536 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1537 headers := gax.BuildHeaders(ctx, hds...)
1538 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1539 if settings.Path != "" {
1540 baseUrl.Path = settings.Path
1541 }
1542 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1543 if err != nil {
1544 return err
1545 }
1546 httpReq.Header = headers
1547
1548 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
1549 if err != nil {
1550 return err
1551 }
1552 if err := unm.Unmarshal(buf, resp); err != nil {
1553 return err
1554 }
1555
1556 return nil
1557 }, opts...)
1558 if e != nil {
1559 return nil, "", e
1560 }
1561 it.Response = resp
1562 return resp.GetLocations(), resp.GetNextPageToken(), nil
1563 }
1564
1565 fetch := func(pageSize int, pageToken string) (string, error) {
1566 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1567 if err != nil {
1568 return "", err
1569 }
1570 it.items = append(it.items, items...)
1571 return nextPageToken, nil
1572 }
1573
1574 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1575 it.pageInfo.MaxSize = int(req.GetPageSize())
1576 it.pageInfo.Token = req.GetPageToken()
1577
1578 return it
1579 }
1580
1581 // CancelOperation is a utility method from google.longrunning.Operations.
1582 func (c *playbooksRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1583 baseUrl, err := url.Parse(c.endpoint)
1584 if err != nil {
1585 return err
1586 }
1587 baseUrl.Path += fmt.Sprintf("/v3beta1/%v:cancel", req.GetName())
1588
1589 params := url.Values{}
1590 params.Add("$alt", "json;enum-encoding=int")
1591
1592 baseUrl.RawQuery = params.Encode()
1593
1594 // Build HTTP headers from client and context metadata.
1595 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1596
1597 hds = append(c.xGoogHeaders, hds...)
1598 hds = append(hds, "Content-Type", "application/json")
1599 headers := gax.BuildHeaders(ctx, hds...)
1600 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1601 if settings.Path != "" {
1602 baseUrl.Path = settings.Path
1603 }
1604 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
1605 if err != nil {
1606 return err
1607 }
1608 httpReq = httpReq.WithContext(ctx)
1609 httpReq.Header = headers
1610
1611 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
1612 return err
1613 }, opts...)
1614 }
1615
1616 // GetOperation is a utility method from google.longrunning.Operations.
1617 func (c *playbooksRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1618 baseUrl, err := url.Parse(c.endpoint)
1619 if err != nil {
1620 return nil, err
1621 }
1622 baseUrl.Path += fmt.Sprintf("/v3beta1/%v", req.GetName())
1623
1624 params := url.Values{}
1625 params.Add("$alt", "json;enum-encoding=int")
1626
1627 baseUrl.RawQuery = params.Encode()
1628
1629 // Build HTTP headers from client and context metadata.
1630 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1631
1632 hds = append(c.xGoogHeaders, hds...)
1633 hds = append(hds, "Content-Type", "application/json")
1634 headers := gax.BuildHeaders(ctx, hds...)
1635 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1636 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1637 resp := &longrunningpb.Operation{}
1638 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1639 if settings.Path != "" {
1640 baseUrl.Path = settings.Path
1641 }
1642 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1643 if err != nil {
1644 return err
1645 }
1646 httpReq = httpReq.WithContext(ctx)
1647 httpReq.Header = headers
1648
1649 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
1650 if err != nil {
1651 return err
1652 }
1653
1654 if err := unm.Unmarshal(buf, resp); err != nil {
1655 return err
1656 }
1657
1658 return nil
1659 }, opts...)
1660 if e != nil {
1661 return nil, e
1662 }
1663 return resp, nil
1664 }
1665
1666 // ListOperations is a utility method from google.longrunning.Operations.
1667 func (c *playbooksRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1668 it := &OperationIterator{}
1669 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1670 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1671 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1672 resp := &longrunningpb.ListOperationsResponse{}
1673 if pageToken != "" {
1674 req.PageToken = pageToken
1675 }
1676 if pageSize > math.MaxInt32 {
1677 req.PageSize = math.MaxInt32
1678 } else if pageSize != 0 {
1679 req.PageSize = int32(pageSize)
1680 }
1681 baseUrl, err := url.Parse(c.endpoint)
1682 if err != nil {
1683 return nil, "", err
1684 }
1685 baseUrl.Path += fmt.Sprintf("/v3beta1/%v/operations", req.GetName())
1686
1687 params := url.Values{}
1688 params.Add("$alt", "json;enum-encoding=int")
1689 if req.GetFilter() != "" {
1690 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1691 }
1692 if req.GetPageSize() != 0 {
1693 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1694 }
1695 if req.GetPageToken() != "" {
1696 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1697 }
1698
1699 baseUrl.RawQuery = params.Encode()
1700
1701 // Build HTTP headers from client and context metadata.
1702 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1703 headers := gax.BuildHeaders(ctx, hds...)
1704 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1705 if settings.Path != "" {
1706 baseUrl.Path = settings.Path
1707 }
1708 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1709 if err != nil {
1710 return err
1711 }
1712 httpReq.Header = headers
1713
1714 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
1715 if err != nil {
1716 return err
1717 }
1718 if err := unm.Unmarshal(buf, resp); err != nil {
1719 return err
1720 }
1721
1722 return nil
1723 }, opts...)
1724 if e != nil {
1725 return nil, "", e
1726 }
1727 it.Response = resp
1728 return resp.GetOperations(), resp.GetNextPageToken(), nil
1729 }
1730
1731 fetch := func(pageSize int, pageToken string) (string, error) {
1732 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1733 if err != nil {
1734 return "", err
1735 }
1736 it.items = append(it.items, items...)
1737 return nextPageToken, nil
1738 }
1739
1740 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1741 it.pageInfo.MaxSize = int(req.GetPageSize())
1742 it.pageInfo.Token = req.GetPageToken()
1743
1744 return it
1745 }