Debian Codegraph @

lifesciences/apiv2beta/workflows_service_v2_beta_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 lifesciences
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 lifesciencespb "cloud.google.com/go/lifesciences/apiv2beta/lifesciencespb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 locationpb "google.golang.org/genproto/googleapis/cloud/location"
40 "google.golang.org/grpc"
41 "google.golang.org/protobuf/encoding/protojson"
42 "google.golang.org/protobuf/proto"
43 )
44
45 var newWorkflowsServiceV2BetaClientHook clientHook
46
47 // WorkflowsServiceV2BetaCallOptions contains the retry settings for each method of WorkflowsServiceV2BetaClient.
48 type WorkflowsServiceV2BetaCallOptions struct {
49 RunPipeline []gax.CallOption
50 GetLocation []gax.CallOption
51 ListLocations []gax.CallOption
52 CancelOperation []gax.CallOption
53 GetOperation []gax.CallOption
54 ListOperations []gax.CallOption
55 }
56
57 func defaultWorkflowsServiceV2BetaGRPCClientOptions() []option.ClientOption {
58 return []option.ClientOption{
59 internaloption.WithDefaultEndpoint("lifesciences.googleapis.com:443"),
60 internaloption.WithDefaultEndpointTemplate("lifesciences.UNIVERSE_DOMAIN:443"),
61 internaloption.WithDefaultMTLSEndpoint("lifesciences.mtls.googleapis.com:443"),
62 internaloption.WithDefaultUniverseDomain("googleapis.com"),
63 internaloption.WithDefaultAudience("https://lifesciences.googleapis.com/"),
64 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
65 internaloption.EnableJwtWithScope(),
66 internaloption.EnableNewAuthLibrary(),
67 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
68 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
69 }
70 }
71
72 func defaultWorkflowsServiceV2BetaCallOptions() *WorkflowsServiceV2BetaCallOptions {
73 return &WorkflowsServiceV2BetaCallOptions{
74 RunPipeline: []gax.CallOption{
75 gax.WithTimeout(60000 * time.Millisecond),
76 },
77 GetLocation: []gax.CallOption{},
78 ListLocations: []gax.CallOption{},
79 CancelOperation: []gax.CallOption{},
80 GetOperation: []gax.CallOption{},
81 ListOperations: []gax.CallOption{},
82 }
83 }
84
85 func defaultWorkflowsServiceV2BetaRESTCallOptions() *WorkflowsServiceV2BetaCallOptions {
86 return &WorkflowsServiceV2BetaCallOptions{
87 RunPipeline: []gax.CallOption{
88 gax.WithTimeout(60000 * time.Millisecond),
89 },
90 GetLocation: []gax.CallOption{},
91 ListLocations: []gax.CallOption{},
92 CancelOperation: []gax.CallOption{},
93 GetOperation: []gax.CallOption{},
94 ListOperations: []gax.CallOption{},
95 }
96 }
97
98 // internalWorkflowsServiceV2BetaClient is an interface that defines the methods available from Cloud Life Sciences API.
99 type internalWorkflowsServiceV2BetaClient interface {
100 Close() error
101 setGoogleClientInfo(...string)
102 Connection() *grpc.ClientConn
103 RunPipeline(context.Context, *lifesciencespb.RunPipelineRequest, ...gax.CallOption) (*RunPipelineOperation, error)
104 RunPipelineOperation(name string) *RunPipelineOperation
105 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
106 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
107 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
108 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
109 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
110 }
111
112 // WorkflowsServiceV2BetaClient is a client for interacting with Cloud Life Sciences API.
113 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
114 //
115 // A service for running workflows, such as pipelines consisting of Docker
116 // containers.
117 type WorkflowsServiceV2BetaClient struct {
118 // The internal transport-dependent client.
119 internalClient internalWorkflowsServiceV2BetaClient
120
121 // The call options for this service.
122 CallOptions *WorkflowsServiceV2BetaCallOptions
123
124 // LROClient is used internally to handle long-running operations.
125 // It is exposed so that its CallOptions can be modified if required.
126 // Users should not Close this client.
127 LROClient *lroauto.OperationsClient
128 }
129
130 // Wrapper methods routed to the internal client.
131
132 // Close closes the connection to the API service. The user should invoke this when
133 // the client is no longer required.
134 func (c *WorkflowsServiceV2BetaClient) Close() error {
135 return c.internalClient.Close()
136 }
137
138 // setGoogleClientInfo sets the name and version of the application in
139 // the `x-goog-api-client` header passed on each request. Intended for
140 // use by Google-written clients.
141 func (c *WorkflowsServiceV2BetaClient) setGoogleClientInfo(keyval ...string) {
142 c.internalClient.setGoogleClientInfo(keyval...)
143 }
144
145 // Connection returns a connection to the API service.
146 //
147 // Deprecated: Connections are now pooled so this method does not always
148 // return the same resource.
149 func (c *WorkflowsServiceV2BetaClient) Connection() *grpc.ClientConn {
150 return c.internalClient.Connection()
151 }
152
153 // RunPipeline runs a pipeline. The returned Operation’s [metadata]
154 // [google.longrunning.Operation.metadata] field will contain a
155 // google.cloud.lifesciences.v2beta.Metadata
156 // object describing the status of the pipeline execution. The
157 // response field will contain a
158 // google.cloud.lifesciences.v2beta.RunPipelineResponse
159 // object if the pipeline completes successfully.
160 //
161 // Note: Before you can use this method, the Life Sciences Service Agent
162 // must have access to your project. This is done automatically when the
163 // Cloud Life Sciences API is first enabled, but if you delete this permission
164 // you must disable and re-enable the API to grant the Life Sciences
165 // Service Agent the required permissions.
166 // Authorization requires the following Google
167 // IAM (at https://cloud.google.com/iam/) permission:
168 //
169 // lifesciences.workflows.run
170 func (c *WorkflowsServiceV2BetaClient) RunPipeline(ctx context.Context, req *lifesciencespb.RunPipelineRequest, opts ...gax.CallOption) (*RunPipelineOperation, error) {
171 return c.internalClient.RunPipeline(ctx, req, opts...)
172 }
173
174 // RunPipelineOperation returns a new RunPipelineOperation from a given name.
175 // The name must be that of a previously created RunPipelineOperation, possibly from a different process.
176 func (c *WorkflowsServiceV2BetaClient) RunPipelineOperation(name string) *RunPipelineOperation {
177 return c.internalClient.RunPipelineOperation(name)
178 }
179
180 // GetLocation gets information about a location.
181 func (c *WorkflowsServiceV2BetaClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
182 return c.internalClient.GetLocation(ctx, req, opts...)
183 }
184
185 // ListLocations lists information about the supported locations for this service.
186 func (c *WorkflowsServiceV2BetaClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
187 return c.internalClient.ListLocations(ctx, req, opts...)
188 }
189
190 // CancelOperation starts asynchronous cancellation on a long-running operation. The
191 // server makes a best effort to cancel the operation, but success is
192 // not guaranteed. Clients may use
193 // Operations.GetOperation or
194 // Operations.ListOperations to
195 // check whether the cancellation succeeded or the operation completed
196 // despite cancellation.
197 // Authorization requires the following Google
198 // IAM (at https://cloud.google.com/iam) permission:
199 //
200 // lifesciences.operations.cancel
201 func (c *WorkflowsServiceV2BetaClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
202 return c.internalClient.CancelOperation(ctx, req, opts...)
203 }
204
205 // GetOperation gets the latest state of a long-running operation. Clients can use this
206 // method to poll the operation result at intervals as recommended by the
207 // API service.
208 // Authorization requires the following Google
209 // IAM (at https://cloud.google.com/iam) permission:
210 //
211 // lifesciences.operations.get
212 func (c *WorkflowsServiceV2BetaClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
213 return c.internalClient.GetOperation(ctx, req, opts...)
214 }
215
216 // ListOperations lists operations that match the specified filter in the
217 // request. Authorization requires the following Google
218 // IAM (at https://cloud.google.com/iam) permission:
219 //
220 // lifesciences.operations.list
221 func (c *WorkflowsServiceV2BetaClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
222 return c.internalClient.ListOperations(ctx, req, opts...)
223 }
224
225 // workflowsServiceV2BetaGRPCClient is a client for interacting with Cloud Life Sciences API over gRPC transport.
226 //
227 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
228 type workflowsServiceV2BetaGRPCClient struct {
229 // Connection pool of gRPC connections to the service.
230 connPool gtransport.ConnPool
231
232 // Points back to the CallOptions field of the containing WorkflowsServiceV2BetaClient
233 CallOptions **WorkflowsServiceV2BetaCallOptions
234
235 // The gRPC API client.
236 workflowsServiceV2BetaClient lifesciencespb.WorkflowsServiceV2BetaClient
237
238 // LROClient is used internally to handle long-running operations.
239 // It is exposed so that its CallOptions can be modified if required.
240 // Users should not Close this client.
241 LROClient **lroauto.OperationsClient
242
243 operationsClient longrunningpb.OperationsClient
244
245 locationsClient locationpb.LocationsClient
246
247 // The x-goog-* metadata to be sent with each request.
248 xGoogHeaders []string
249
250 logger *slog.Logger
251 }
252
253 // NewWorkflowsServiceV2BetaClient creates a new workflows service v2 beta client based on gRPC.
254 // The returned client must be Closed when it is done being used to clean up its underlying connections.
255 //
256 // A service for running workflows, such as pipelines consisting of Docker
257 // containers.
258 func NewWorkflowsServiceV2BetaClient(ctx context.Context, opts ...option.ClientOption) (*WorkflowsServiceV2BetaClient, error) {
259 clientOpts := defaultWorkflowsServiceV2BetaGRPCClientOptions()
260 if newWorkflowsServiceV2BetaClientHook != nil {
261 hookOpts, err := newWorkflowsServiceV2BetaClientHook(ctx, clientHookParams{})
262 if err != nil {
263 return nil, err
264 }
265 clientOpts = append(clientOpts, hookOpts...)
266 }
267
268 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
269 if err != nil {
270 return nil, err
271 }
272 client := WorkflowsServiceV2BetaClient{CallOptions: defaultWorkflowsServiceV2BetaCallOptions()}
273
274 c := &workflowsServiceV2BetaGRPCClient{
275 connPool: connPool,
276 workflowsServiceV2BetaClient: lifesciencespb.NewWorkflowsServiceV2BetaClient(connPool),
277 CallOptions: &client.CallOptions,
278 logger: internaloption.GetLogger(opts),
279 operationsClient: longrunningpb.NewOperationsClient(connPool),
280 locationsClient: locationpb.NewLocationsClient(connPool),
281 }
282 c.setGoogleClientInfo()
283
284 client.internalClient = c
285
286 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
287 if err != nil {
288 // This error "should not happen", since we are just reusing old connection pool
289 // and never actually need to dial.
290 // If this does happen, we could leak connp. However, we cannot close conn:
291 // If the user invoked the constructor with option.WithGRPCConn,
292 // we would close a connection that's still in use.
293 // TODO: investigate error conditions.
294 return nil, err
295 }
296 c.LROClient = &client.LROClient
297 return &client, nil
298 }
299
300 // Connection returns a connection to the API service.
301 //
302 // Deprecated: Connections are now pooled so this method does not always
303 // return the same resource.
304 func (c *workflowsServiceV2BetaGRPCClient) Connection() *grpc.ClientConn {
305 return c.connPool.Conn()
306 }
307
308 // setGoogleClientInfo sets the name and version of the application in
309 // the `x-goog-api-client` header passed on each request. Intended for
310 // use by Google-written clients.
311 func (c *workflowsServiceV2BetaGRPCClient) setGoogleClientInfo(keyval ...string) {
312 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
313 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
314 c.xGoogHeaders = []string{
315 "x-goog-api-client", gax.XGoogHeader(kv...),
316 }
317 }
318
319 // Close closes the connection to the API service. The user should invoke this when
320 // the client is no longer required.
321 func (c *workflowsServiceV2BetaGRPCClient) Close() error {
322 return c.connPool.Close()
323 }
324
325 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
326 type workflowsServiceV2BetaRESTClient struct {
327 // The http endpoint to connect to.
328 endpoint string
329
330 // The http client.
331 httpClient *http.Client
332
333 // LROClient is used internally to handle long-running operations.
334 // It is exposed so that its CallOptions can be modified if required.
335 // Users should not Close this client.
336 LROClient **lroauto.OperationsClient
337
338 // The x-goog-* headers to be sent with each request.
339 xGoogHeaders []string
340
341 // Points back to the CallOptions field of the containing WorkflowsServiceV2BetaClient
342 CallOptions **WorkflowsServiceV2BetaCallOptions
343
344 logger *slog.Logger
345 }
346
347 // NewWorkflowsServiceV2BetaRESTClient creates a new workflows service v2 beta rest client.
348 //
349 // A service for running workflows, such as pipelines consisting of Docker
350 // containers.
351 func NewWorkflowsServiceV2BetaRESTClient(ctx context.Context, opts ...option.ClientOption) (*WorkflowsServiceV2BetaClient, error) {
352 clientOpts := append(defaultWorkflowsServiceV2BetaRESTClientOptions(), opts...)
353 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
354 if err != nil {
355 return nil, err
356 }
357
358 callOpts := defaultWorkflowsServiceV2BetaRESTCallOptions()
359 c := &workflowsServiceV2BetaRESTClient{
360 endpoint: endpoint,
361 httpClient: httpClient,
362 CallOptions: &callOpts,
363 logger: internaloption.GetLogger(opts),
364 }
365 c.setGoogleClientInfo()
366
367 lroOpts := []option.ClientOption{
368 option.WithHTTPClient(httpClient),
369 option.WithEndpoint(endpoint),
370 }
371 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
372 if err != nil {
373 return nil, err
374 }
375 c.LROClient = &opClient
376
377 return &WorkflowsServiceV2BetaClient{internalClient: c, CallOptions: callOpts}, nil
378 }
379
380 func defaultWorkflowsServiceV2BetaRESTClientOptions() []option.ClientOption {
381 return []option.ClientOption{
382 internaloption.WithDefaultEndpoint("https://lifesciences.googleapis.com"),
383 internaloption.WithDefaultEndpointTemplate("https://lifesciences.UNIVERSE_DOMAIN"),
384 internaloption.WithDefaultMTLSEndpoint("https://lifesciences.mtls.googleapis.com"),
385 internaloption.WithDefaultUniverseDomain("googleapis.com"),
386 internaloption.WithDefaultAudience("https://lifesciences.googleapis.com/"),
387 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
388 internaloption.EnableNewAuthLibrary(),
389 }
390 }
391
392 // setGoogleClientInfo sets the name and version of the application in
393 // the `x-goog-api-client` header passed on each request. Intended for
394 // use by Google-written clients.
395 func (c *workflowsServiceV2BetaRESTClient) setGoogleClientInfo(keyval ...string) {
396 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
397 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
398 c.xGoogHeaders = []string{
399 "x-goog-api-client", gax.XGoogHeader(kv...),
400 }
401 }
402
403 // Close closes the connection to the API service. The user should invoke this when
404 // the client is no longer required.
405 func (c *workflowsServiceV2BetaRESTClient) Close() error {
406 // Replace httpClient with nil to force cleanup.
407 c.httpClient = nil
408 return nil
409 }
410
411 // Connection returns a connection to the API service.
412 //
413 // Deprecated: This method always returns nil.
414 func (c *workflowsServiceV2BetaRESTClient) Connection() *grpc.ClientConn {
415 return nil
416 }
417 func (c *workflowsServiceV2BetaGRPCClient) RunPipeline(ctx context.Context, req *lifesciencespb.RunPipelineRequest, opts ...gax.CallOption) (*RunPipelineOperation, error) {
418 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
419
420 hds = append(c.xGoogHeaders, hds...)
421 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
422 opts = append((*c.CallOptions).RunPipeline[0:len((*c.CallOptions).RunPipeline):len((*c.CallOptions).RunPipeline)], opts...)
423 var resp *longrunningpb.Operation
424 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
425 var err error
426 resp, err = executeRPC(ctx, c.workflowsServiceV2BetaClient.RunPipeline, req, settings.GRPC, c.logger, "RunPipeline")
427 return err
428 }, opts...)
429 if err != nil {
430 return nil, err
431 }
432 return &RunPipelineOperation{
433 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
434 }, nil
435 }
436
437 func (c *workflowsServiceV2BetaGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
438 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
439
440 hds = append(c.xGoogHeaders, hds...)
441 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
442 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
443 var resp *locationpb.Location
444 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
445 var err error
446 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
447 return err
448 }, opts...)
449 if err != nil {
450 return nil, err
451 }
452 return resp, nil
453 }
454
455 func (c *workflowsServiceV2BetaGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
456 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
457
458 hds = append(c.xGoogHeaders, hds...)
459 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
460 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
461 it := &LocationIterator{}
462 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
463 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
464 resp := &locationpb.ListLocationsResponse{}
465 if pageToken != "" {
466 req.PageToken = pageToken
467 }
468 if pageSize > math.MaxInt32 {
469 req.PageSize = math.MaxInt32
470 } else if pageSize != 0 {
471 req.PageSize = int32(pageSize)
472 }
473 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
474 var err error
475 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
476 return err
477 }, opts...)
478 if err != nil {
479 return nil, "", err
480 }
481
482 it.Response = resp
483 return resp.GetLocations(), resp.GetNextPageToken(), nil
484 }
485 fetch := func(pageSize int, pageToken string) (string, error) {
486 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
487 if err != nil {
488 return "", err
489 }
490 it.items = append(it.items, items...)
491 return nextPageToken, nil
492 }
493
494 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
495 it.pageInfo.MaxSize = int(req.GetPageSize())
496 it.pageInfo.Token = req.GetPageToken()
497
498 return it
499 }
500
501 func (c *workflowsServiceV2BetaGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
502 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
503
504 hds = append(c.xGoogHeaders, hds...)
505 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
506 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
507 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
508 var err error
509 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
510 return err
511 }, opts...)
512 return err
513 }
514
515 func (c *workflowsServiceV2BetaGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
516 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
517
518 hds = append(c.xGoogHeaders, hds...)
519 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
520 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
521 var resp *longrunningpb.Operation
522 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
523 var err error
524 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
525 return err
526 }, opts...)
527 if err != nil {
528 return nil, err
529 }
530 return resp, nil
531 }
532
533 func (c *workflowsServiceV2BetaGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
534 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
535
536 hds = append(c.xGoogHeaders, hds...)
537 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
538 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
539 it := &OperationIterator{}
540 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
541 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
542 resp := &longrunningpb.ListOperationsResponse{}
543 if pageToken != "" {
544 req.PageToken = pageToken
545 }
546 if pageSize > math.MaxInt32 {
547 req.PageSize = math.MaxInt32
548 } else if pageSize != 0 {
549 req.PageSize = int32(pageSize)
550 }
551 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
552 var err error
553 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
554 return err
555 }, opts...)
556 if err != nil {
557 return nil, "", err
558 }
559
560 it.Response = resp
561 return resp.GetOperations(), resp.GetNextPageToken(), nil
562 }
563 fetch := func(pageSize int, pageToken string) (string, error) {
564 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
565 if err != nil {
566 return "", err
567 }
568 it.items = append(it.items, items...)
569 return nextPageToken, nil
570 }
571
572 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
573 it.pageInfo.MaxSize = int(req.GetPageSize())
574 it.pageInfo.Token = req.GetPageToken()
575
576 return it
577 }
578
579 // RunPipeline runs a pipeline. The returned Operation’s [metadata]
580 // [google.longrunning.Operation.metadata] field will contain a
581 // google.cloud.lifesciences.v2beta.Metadata
582 // object describing the status of the pipeline execution. The
583 // response field will contain a
584 // google.cloud.lifesciences.v2beta.RunPipelineResponse
585 // object if the pipeline completes successfully.
586 //
587 // Note: Before you can use this method, the Life Sciences Service Agent
588 // must have access to your project. This is done automatically when the
589 // Cloud Life Sciences API is first enabled, but if you delete this permission
590 // you must disable and re-enable the API to grant the Life Sciences
591 // Service Agent the required permissions.
592 // Authorization requires the following Google
593 // IAM (at https://cloud.google.com/iam/) permission:
594 //
595 // lifesciences.workflows.run
596 func (c *workflowsServiceV2BetaRESTClient) RunPipeline(ctx context.Context, req *lifesciencespb.RunPipelineRequest, opts ...gax.CallOption) (*RunPipelineOperation, error) {
597 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
598 jsonReq, err := m.Marshal(req)
599 if err != nil {
600 return nil, err
601 }
602
603 baseUrl, err := url.Parse(c.endpoint)
604 if err != nil {
605 return nil, err
606 }
607 baseUrl.Path += fmt.Sprintf("/v2beta/%v/pipelines:run", req.GetParent())
608
609 params := url.Values{}
610 params.Add("$alt", "json;enum-encoding=int")
611
612 baseUrl.RawQuery = params.Encode()
613
614 // Build HTTP headers from client and context metadata.
615 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
616
617 hds = append(c.xGoogHeaders, hds...)
618 hds = append(hds, "Content-Type", "application/json")
619 headers := gax.BuildHeaders(ctx, hds...)
620 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
621 resp := &longrunningpb.Operation{}
622 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
623 if settings.Path != "" {
624 baseUrl.Path = settings.Path
625 }
626 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
627 if err != nil {
628 return err
629 }
630 httpReq = httpReq.WithContext(ctx)
631 httpReq.Header = headers
632
633 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RunPipeline")
634 if err != nil {
635 return err
636 }
637 if err := unm.Unmarshal(buf, resp); err != nil {
638 return err
639 }
640
641 return nil
642 }, opts...)
643 if e != nil {
644 return nil, e
645 }
646
647 override := fmt.Sprintf("/v2beta/%s", resp.GetName())
648 return &RunPipelineOperation{
649 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
650 pollPath: override,
651 }, nil
652 }
653
654 // GetLocation gets information about a location.
655 func (c *workflowsServiceV2BetaRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
656 baseUrl, err := url.Parse(c.endpoint)
657 if err != nil {
658 return nil, err
659 }
660 baseUrl.Path += fmt.Sprintf("/v2beta/%v", req.GetName())
661
662 params := url.Values{}
663 params.Add("$alt", "json;enum-encoding=int")
664
665 baseUrl.RawQuery = params.Encode()
666
667 // Build HTTP headers from client and context metadata.
668 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
669
670 hds = append(c.xGoogHeaders, hds...)
671 hds = append(hds, "Content-Type", "application/json")
672 headers := gax.BuildHeaders(ctx, hds...)
673 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
674 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
675 resp := &locationpb.Location{}
676 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
677 if settings.Path != "" {
678 baseUrl.Path = settings.Path
679 }
680 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
681 if err != nil {
682 return err
683 }
684 httpReq = httpReq.WithContext(ctx)
685 httpReq.Header = headers
686
687 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
688 if err != nil {
689 return err
690 }
691
692 if err := unm.Unmarshal(buf, resp); err != nil {
693 return err
694 }
695
696 return nil
697 }, opts...)
698 if e != nil {
699 return nil, e
700 }
701 return resp, nil
702 }
703
704 // ListLocations lists information about the supported locations for this service.
705 func (c *workflowsServiceV2BetaRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
706 it := &LocationIterator{}
707 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
708 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
709 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
710 resp := &locationpb.ListLocationsResponse{}
711 if pageToken != "" {
712 req.PageToken = pageToken
713 }
714 if pageSize > math.MaxInt32 {
715 req.PageSize = math.MaxInt32
716 } else if pageSize != 0 {
717 req.PageSize = int32(pageSize)
718 }
719 baseUrl, err := url.Parse(c.endpoint)
720 if err != nil {
721 return nil, "", err
722 }
723 baseUrl.Path += fmt.Sprintf("/v2beta/%v/locations", req.GetName())
724
725 params := url.Values{}
726 params.Add("$alt", "json;enum-encoding=int")
727 if req.GetFilter() != "" {
728 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
729 }
730 if req.GetPageSize() != 0 {
731 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
732 }
733 if req.GetPageToken() != "" {
734 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
735 }
736
737 baseUrl.RawQuery = params.Encode()
738
739 // Build HTTP headers from client and context metadata.
740 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
741 headers := gax.BuildHeaders(ctx, hds...)
742 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
743 if settings.Path != "" {
744 baseUrl.Path = settings.Path
745 }
746 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
747 if err != nil {
748 return err
749 }
750 httpReq.Header = headers
751
752 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
753 if err != nil {
754 return err
755 }
756 if err := unm.Unmarshal(buf, resp); err != nil {
757 return err
758 }
759
760 return nil
761 }, opts...)
762 if e != nil {
763 return nil, "", e
764 }
765 it.Response = resp
766 return resp.GetLocations(), resp.GetNextPageToken(), nil
767 }
768
769 fetch := func(pageSize int, pageToken string) (string, error) {
770 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
771 if err != nil {
772 return "", err
773 }
774 it.items = append(it.items, items...)
775 return nextPageToken, nil
776 }
777
778 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
779 it.pageInfo.MaxSize = int(req.GetPageSize())
780 it.pageInfo.Token = req.GetPageToken()
781
782 return it
783 }
784
785 // CancelOperation starts asynchronous cancellation on a long-running operation. The
786 // server makes a best effort to cancel the operation, but success is
787 // not guaranteed. Clients may use
788 // Operations.GetOperation or
789 // Operations.ListOperations to
790 // check whether the cancellation succeeded or the operation completed
791 // despite cancellation.
792 // Authorization requires the following Google
793 // IAM (at https://cloud.google.com/iam) permission:
794 //
795 // lifesciences.operations.cancel
796 func (c *workflowsServiceV2BetaRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
797 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
798 jsonReq, err := m.Marshal(req)
799 if err != nil {
800 return err
801 }
802
803 baseUrl, err := url.Parse(c.endpoint)
804 if err != nil {
805 return err
806 }
807 baseUrl.Path += fmt.Sprintf("/v2beta/%v:cancel", req.GetName())
808
809 params := url.Values{}
810 params.Add("$alt", "json;enum-encoding=int")
811
812 baseUrl.RawQuery = params.Encode()
813
814 // Build HTTP headers from client and context metadata.
815 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
816
817 hds = append(c.xGoogHeaders, hds...)
818 hds = append(hds, "Content-Type", "application/json")
819 headers := gax.BuildHeaders(ctx, hds...)
820 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
821 if settings.Path != "" {
822 baseUrl.Path = settings.Path
823 }
824 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
825 if err != nil {
826 return err
827 }
828 httpReq = httpReq.WithContext(ctx)
829 httpReq.Header = headers
830
831 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
832 return err
833 }, opts...)
834 }
835
836 // GetOperation gets the latest state of a long-running operation. Clients can use this
837 // method to poll the operation result at intervals as recommended by the
838 // API service.
839 // Authorization requires the following Google
840 // IAM (at https://cloud.google.com/iam) permission:
841 //
842 // lifesciences.operations.get
843 func (c *workflowsServiceV2BetaRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
844 baseUrl, err := url.Parse(c.endpoint)
845 if err != nil {
846 return nil, err
847 }
848 baseUrl.Path += fmt.Sprintf("/v2beta/%v", req.GetName())
849
850 params := url.Values{}
851 params.Add("$alt", "json;enum-encoding=int")
852
853 baseUrl.RawQuery = params.Encode()
854
855 // Build HTTP headers from client and context metadata.
856 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
857
858 hds = append(c.xGoogHeaders, hds...)
859 hds = append(hds, "Content-Type", "application/json")
860 headers := gax.BuildHeaders(ctx, hds...)
861 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
862 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
863 resp := &longrunningpb.Operation{}
864 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
865 if settings.Path != "" {
866 baseUrl.Path = settings.Path
867 }
868 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
869 if err != nil {
870 return err
871 }
872 httpReq = httpReq.WithContext(ctx)
873 httpReq.Header = headers
874
875 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
876 if err != nil {
877 return err
878 }
879
880 if err := unm.Unmarshal(buf, resp); err != nil {
881 return err
882 }
883
884 return nil
885 }, opts...)
886 if e != nil {
887 return nil, e
888 }
889 return resp, nil
890 }
891
892 // ListOperations lists operations that match the specified filter in the
893 // request. Authorization requires the following Google
894 // IAM (at https://cloud.google.com/iam) permission:
895 //
896 // lifesciences.operations.list
897 func (c *workflowsServiceV2BetaRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
898 it := &OperationIterator{}
899 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
900 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
901 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
902 resp := &longrunningpb.ListOperationsResponse{}
903 if pageToken != "" {
904 req.PageToken = pageToken
905 }
906 if pageSize > math.MaxInt32 {
907 req.PageSize = math.MaxInt32
908 } else if pageSize != 0 {
909 req.PageSize = int32(pageSize)
910 }
911 baseUrl, err := url.Parse(c.endpoint)
912 if err != nil {
913 return nil, "", err
914 }
915 baseUrl.Path += fmt.Sprintf("/v2beta/%v/operations", req.GetName())
916
917 params := url.Values{}
918 params.Add("$alt", "json;enum-encoding=int")
919 if req.GetFilter() != "" {
920 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
921 }
922 if req.GetPageSize() != 0 {
923 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
924 }
925 if req.GetPageToken() != "" {
926 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
927 }
928
929 baseUrl.RawQuery = params.Encode()
930
931 // Build HTTP headers from client and context metadata.
932 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
933 headers := gax.BuildHeaders(ctx, hds...)
934 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
935 if settings.Path != "" {
936 baseUrl.Path = settings.Path
937 }
938 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
939 if err != nil {
940 return err
941 }
942 httpReq.Header = headers
943
944 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
945 if err != nil {
946 return err
947 }
948 if err := unm.Unmarshal(buf, resp); err != nil {
949 return err
950 }
951
952 return nil
953 }, opts...)
954 if e != nil {
955 return nil, "", e
956 }
957 it.Response = resp
958 return resp.GetOperations(), resp.GetNextPageToken(), nil
959 }
960
961 fetch := func(pageSize int, pageToken string) (string, error) {
962 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
963 if err != nil {
964 return "", err
965 }
966 it.items = append(it.items, items...)
967 return nextPageToken, nil
968 }
969
970 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
971 it.pageInfo.MaxSize = int(req.GetPageSize())
972 it.pageInfo.Token = req.GetPageToken()
973
974 return it
975 }
976
977 // RunPipelineOperation returns a new RunPipelineOperation from a given name.
978 // The name must be that of a previously created RunPipelineOperation, possibly from a different process.
979 func (c *workflowsServiceV2BetaGRPCClient) RunPipelineOperation(name string) *RunPipelineOperation {
980 return &RunPipelineOperation{
981 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
982 }
983 }
984
985 // RunPipelineOperation returns a new RunPipelineOperation from a given name.
986 // The name must be that of a previously created RunPipelineOperation, possibly from a different process.
987 func (c *workflowsServiceV2BetaRESTClient) RunPipelineOperation(name string) *RunPipelineOperation {
988 override := fmt.Sprintf("/v2beta/%s", name)
989 return &RunPipelineOperation{
990 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
991 pollPath: override,
992 }
993 }