You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

527 lines
22 KiB

  1. // Copyright 2019 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. // Code generated by gapic-generator. DO NOT EDIT.
  15. package dataproc
  16. import (
  17. "context"
  18. "math"
  19. "time"
  20. "cloud.google.com/go/longrunning"
  21. lroauto "cloud.google.com/go/longrunning/autogen"
  22. "github.com/golang/protobuf/proto"
  23. gax "github.com/googleapis/gax-go/v2"
  24. "google.golang.org/api/iterator"
  25. "google.golang.org/api/option"
  26. "google.golang.org/api/transport"
  27. dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1"
  28. longrunningpb "google.golang.org/genproto/googleapis/longrunning"
  29. "google.golang.org/grpc"
  30. "google.golang.org/grpc/codes"
  31. "google.golang.org/grpc/metadata"
  32. )
  33. // WorkflowTemplateCallOptions contains the retry settings for each method of WorkflowTemplateClient.
  34. type WorkflowTemplateCallOptions struct {
  35. CreateWorkflowTemplate []gax.CallOption
  36. GetWorkflowTemplate []gax.CallOption
  37. InstantiateWorkflowTemplate []gax.CallOption
  38. InstantiateInlineWorkflowTemplate []gax.CallOption
  39. UpdateWorkflowTemplate []gax.CallOption
  40. ListWorkflowTemplates []gax.CallOption
  41. DeleteWorkflowTemplate []gax.CallOption
  42. }
  43. func defaultWorkflowTemplateClientOptions() []option.ClientOption {
  44. return []option.ClientOption{
  45. option.WithEndpoint("dataproc.googleapis.com:443"),
  46. option.WithScopes(DefaultAuthScopes()...),
  47. }
  48. }
  49. func defaultWorkflowTemplateCallOptions() *WorkflowTemplateCallOptions {
  50. retry := map[[2]string][]gax.CallOption{
  51. {"default", "idempotent"}: {
  52. gax.WithRetry(func() gax.Retryer {
  53. return gax.OnCodes([]codes.Code{
  54. codes.DeadlineExceeded,
  55. codes.Internal,
  56. codes.Unavailable,
  57. }, gax.Backoff{
  58. Initial: 100 * time.Millisecond,
  59. Max: 60000 * time.Millisecond,
  60. Multiplier: 1.3,
  61. })
  62. }),
  63. },
  64. {"default", "non_idempotent"}: {
  65. gax.WithRetry(func() gax.Retryer {
  66. return gax.OnCodes([]codes.Code{
  67. codes.Unavailable,
  68. }, gax.Backoff{
  69. Initial: 100 * time.Millisecond,
  70. Max: 60000 * time.Millisecond,
  71. Multiplier: 1.3,
  72. })
  73. }),
  74. },
  75. }
  76. return &WorkflowTemplateCallOptions{
  77. CreateWorkflowTemplate: retry[[2]string{"default", "non_idempotent"}],
  78. GetWorkflowTemplate: retry[[2]string{"default", "idempotent"}],
  79. InstantiateWorkflowTemplate: retry[[2]string{"default", "non_idempotent"}],
  80. InstantiateInlineWorkflowTemplate: retry[[2]string{"default", "non_idempotent"}],
  81. UpdateWorkflowTemplate: retry[[2]string{"default", "non_idempotent"}],
  82. ListWorkflowTemplates: retry[[2]string{"default", "idempotent"}],
  83. DeleteWorkflowTemplate: retry[[2]string{"default", "non_idempotent"}],
  84. }
  85. }
  86. // WorkflowTemplateClient is a client for interacting with Google Cloud Dataproc API.
  87. //
  88. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
  89. type WorkflowTemplateClient struct {
  90. // The connection to the service.
  91. conn *grpc.ClientConn
  92. // The gRPC API client.
  93. workflowTemplateClient dataprocpb.WorkflowTemplateServiceClient
  94. // LROClient is used internally to handle longrunning operations.
  95. // It is exposed so that its CallOptions can be modified if required.
  96. // Users should not Close this client.
  97. LROClient *lroauto.OperationsClient
  98. // The call options for this service.
  99. CallOptions *WorkflowTemplateCallOptions
  100. // The x-goog-* metadata to be sent with each request.
  101. xGoogMetadata metadata.MD
  102. }
  103. // NewWorkflowTemplateClient creates a new workflow template service client.
  104. //
  105. // The API interface for managing Workflow Templates in the
  106. // Cloud Dataproc API.
  107. func NewWorkflowTemplateClient(ctx context.Context, opts ...option.ClientOption) (*WorkflowTemplateClient, error) {
  108. conn, err := transport.DialGRPC(ctx, append(defaultWorkflowTemplateClientOptions(), opts...)...)
  109. if err != nil {
  110. return nil, err
  111. }
  112. c := &WorkflowTemplateClient{
  113. conn: conn,
  114. CallOptions: defaultWorkflowTemplateCallOptions(),
  115. workflowTemplateClient: dataprocpb.NewWorkflowTemplateServiceClient(conn),
  116. }
  117. c.setGoogleClientInfo()
  118. c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn))
  119. if err != nil {
  120. // This error "should not happen", since we are just reusing old connection
  121. // and never actually need to dial.
  122. // If this does happen, we could leak conn. However, we cannot close conn:
  123. // If the user invoked the function with option.WithGRPCConn,
  124. // we would close a connection that's still in use.
  125. // TODO(pongad): investigate error conditions.
  126. return nil, err
  127. }
  128. return c, nil
  129. }
  130. // Connection returns the client's connection to the API service.
  131. func (c *WorkflowTemplateClient) Connection() *grpc.ClientConn {
  132. return c.conn
  133. }
  134. // Close closes the connection to the API service. The user should invoke this when
  135. // the client is no longer required.
  136. func (c *WorkflowTemplateClient) Close() error {
  137. return c.conn.Close()
  138. }
  139. // setGoogleClientInfo sets the name and version of the application in
  140. // the `x-goog-api-client` header passed on each request. Intended for
  141. // use by Google-written clients.
  142. func (c *WorkflowTemplateClient) setGoogleClientInfo(keyval ...string) {
  143. kv := append([]string{"gl-go", versionGo()}, keyval...)
  144. kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
  145. c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
  146. }
  147. // CreateWorkflowTemplate creates new workflow template.
  148. func (c *WorkflowTemplateClient) CreateWorkflowTemplate(ctx context.Context, req *dataprocpb.CreateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) {
  149. ctx = insertMetadata(ctx, c.xGoogMetadata)
  150. opts = append(c.CallOptions.CreateWorkflowTemplate[0:len(c.CallOptions.CreateWorkflowTemplate):len(c.CallOptions.CreateWorkflowTemplate)], opts...)
  151. var resp *dataprocpb.WorkflowTemplate
  152. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  153. var err error
  154. resp, err = c.workflowTemplateClient.CreateWorkflowTemplate(ctx, req, settings.GRPC...)
  155. return err
  156. }, opts...)
  157. if err != nil {
  158. return nil, err
  159. }
  160. return resp, nil
  161. }
  162. // GetWorkflowTemplate retrieves the latest workflow template.
  163. //
  164. // Can retrieve previously instantiated template by specifying optional
  165. // version parameter.
  166. func (c *WorkflowTemplateClient) GetWorkflowTemplate(ctx context.Context, req *dataprocpb.GetWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) {
  167. ctx = insertMetadata(ctx, c.xGoogMetadata)
  168. opts = append(c.CallOptions.GetWorkflowTemplate[0:len(c.CallOptions.GetWorkflowTemplate):len(c.CallOptions.GetWorkflowTemplate)], opts...)
  169. var resp *dataprocpb.WorkflowTemplate
  170. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  171. var err error
  172. resp, err = c.workflowTemplateClient.GetWorkflowTemplate(ctx, req, settings.GRPC...)
  173. return err
  174. }, opts...)
  175. if err != nil {
  176. return nil, err
  177. }
  178. return resp, nil
  179. }
  180. // InstantiateWorkflowTemplate instantiates a template and begins execution.
  181. //
  182. // The returned Operation can be used to track execution of
  183. // workflow by polling
  184. // [operations.get][google.longrunning.Operations.GetOperation].
  185. // The Operation will complete when entire workflow is finished.
  186. //
  187. // The running workflow can be aborted via
  188. // [operations.cancel][google.longrunning.Operations.CancelOperation].
  189. // This will cause any inflight jobs to be cancelled and workflow-owned
  190. // clusters to be deleted.
  191. //
  192. // The [Operation.metadata][google.longrunning.Operation.metadata] will be
  193. // [WorkflowMetadata][google.cloud.dataproc.v1.WorkflowMetadata].
  194. //
  195. // On successful completion,
  196. // [Operation.response][google.longrunning.Operation.response] will be
  197. // [Empty][google.protobuf.Empty].
  198. func (c *WorkflowTemplateClient) InstantiateWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateWorkflowTemplateOperation, error) {
  199. ctx = insertMetadata(ctx, c.xGoogMetadata)
  200. opts = append(c.CallOptions.InstantiateWorkflowTemplate[0:len(c.CallOptions.InstantiateWorkflowTemplate):len(c.CallOptions.InstantiateWorkflowTemplate)], opts...)
  201. var resp *longrunningpb.Operation
  202. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  203. var err error
  204. resp, err = c.workflowTemplateClient.InstantiateWorkflowTemplate(ctx, req, settings.GRPC...)
  205. return err
  206. }, opts...)
  207. if err != nil {
  208. return nil, err
  209. }
  210. return &InstantiateWorkflowTemplateOperation{
  211. lro: longrunning.InternalNewOperation(c.LROClient, resp),
  212. }, nil
  213. }
  214. // InstantiateInlineWorkflowTemplate instantiates a template and begins execution.
  215. //
  216. // This method is equivalent to executing the sequence
  217. // [CreateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.CreateWorkflowTemplate],
  218. // [InstantiateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.InstantiateWorkflowTemplate],
  219. // [DeleteWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.DeleteWorkflowTemplate].
  220. //
  221. // The returned Operation can be used to track execution of
  222. // workflow by polling
  223. // [operations.get][google.longrunning.Operations.GetOperation].
  224. // The Operation will complete when entire workflow is finished.
  225. //
  226. // The running workflow can be aborted via
  227. // [operations.cancel][google.longrunning.Operations.CancelOperation].
  228. // This will cause any inflight jobs to be cancelled and workflow-owned
  229. // clusters to be deleted.
  230. //
  231. // The [Operation.metadata][google.longrunning.Operation.metadata] will be
  232. // [WorkflowMetadata][google.cloud.dataproc.v1.WorkflowMetadata].
  233. //
  234. // On successful completion,
  235. // [Operation.response][google.longrunning.Operation.response] will be
  236. // [Empty][google.protobuf.Empty].
  237. func (c *WorkflowTemplateClient) InstantiateInlineWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateInlineWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateInlineWorkflowTemplateOperation, error) {
  238. ctx = insertMetadata(ctx, c.xGoogMetadata)
  239. opts = append(c.CallOptions.InstantiateInlineWorkflowTemplate[0:len(c.CallOptions.InstantiateInlineWorkflowTemplate):len(c.CallOptions.InstantiateInlineWorkflowTemplate)], opts...)
  240. var resp *longrunningpb.Operation
  241. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  242. var err error
  243. resp, err = c.workflowTemplateClient.InstantiateInlineWorkflowTemplate(ctx, req, settings.GRPC...)
  244. return err
  245. }, opts...)
  246. if err != nil {
  247. return nil, err
  248. }
  249. return &InstantiateInlineWorkflowTemplateOperation{
  250. lro: longrunning.InternalNewOperation(c.LROClient, resp),
  251. }, nil
  252. }
  253. // UpdateWorkflowTemplate updates (replaces) workflow template. The updated template
  254. // must contain version that matches the current server version.
  255. func (c *WorkflowTemplateClient) UpdateWorkflowTemplate(ctx context.Context, req *dataprocpb.UpdateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) {
  256. ctx = insertMetadata(ctx, c.xGoogMetadata)
  257. opts = append(c.CallOptions.UpdateWorkflowTemplate[0:len(c.CallOptions.UpdateWorkflowTemplate):len(c.CallOptions.UpdateWorkflowTemplate)], opts...)
  258. var resp *dataprocpb.WorkflowTemplate
  259. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  260. var err error
  261. resp, err = c.workflowTemplateClient.UpdateWorkflowTemplate(ctx, req, settings.GRPC...)
  262. return err
  263. }, opts...)
  264. if err != nil {
  265. return nil, err
  266. }
  267. return resp, nil
  268. }
  269. // ListWorkflowTemplates lists workflows that match the specified filter in the request.
  270. func (c *WorkflowTemplateClient) ListWorkflowTemplates(ctx context.Context, req *dataprocpb.ListWorkflowTemplatesRequest, opts ...gax.CallOption) *WorkflowTemplateIterator {
  271. ctx = insertMetadata(ctx, c.xGoogMetadata)
  272. opts = append(c.CallOptions.ListWorkflowTemplates[0:len(c.CallOptions.ListWorkflowTemplates):len(c.CallOptions.ListWorkflowTemplates)], opts...)
  273. it := &WorkflowTemplateIterator{}
  274. req = proto.Clone(req).(*dataprocpb.ListWorkflowTemplatesRequest)
  275. it.InternalFetch = func(pageSize int, pageToken string) ([]*dataprocpb.WorkflowTemplate, string, error) {
  276. var resp *dataprocpb.ListWorkflowTemplatesResponse
  277. req.PageToken = pageToken
  278. if pageSize > math.MaxInt32 {
  279. req.PageSize = math.MaxInt32
  280. } else {
  281. req.PageSize = int32(pageSize)
  282. }
  283. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  284. var err error
  285. resp, err = c.workflowTemplateClient.ListWorkflowTemplates(ctx, req, settings.GRPC...)
  286. return err
  287. }, opts...)
  288. if err != nil {
  289. return nil, "", err
  290. }
  291. return resp.Templates, resp.NextPageToken, nil
  292. }
  293. fetch := func(pageSize int, pageToken string) (string, error) {
  294. items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  295. if err != nil {
  296. return "", err
  297. }
  298. it.items = append(it.items, items...)
  299. return nextPageToken, nil
  300. }
  301. it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  302. it.pageInfo.MaxSize = int(req.PageSize)
  303. return it
  304. }
  305. // DeleteWorkflowTemplate deletes a workflow template. It does not cancel in-progress workflows.
  306. func (c *WorkflowTemplateClient) DeleteWorkflowTemplate(ctx context.Context, req *dataprocpb.DeleteWorkflowTemplateRequest, opts ...gax.CallOption) error {
  307. ctx = insertMetadata(ctx, c.xGoogMetadata)
  308. opts = append(c.CallOptions.DeleteWorkflowTemplate[0:len(c.CallOptions.DeleteWorkflowTemplate):len(c.CallOptions.DeleteWorkflowTemplate)], opts...)
  309. err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  310. var err error
  311. _, err = c.workflowTemplateClient.DeleteWorkflowTemplate(ctx, req, settings.GRPC...)
  312. return err
  313. }, opts...)
  314. return err
  315. }
  316. // WorkflowTemplateIterator manages a stream of *dataprocpb.WorkflowTemplate.
  317. type WorkflowTemplateIterator struct {
  318. items []*dataprocpb.WorkflowTemplate
  319. pageInfo *iterator.PageInfo
  320. nextFunc func() error
  321. // InternalFetch is for use by the Google Cloud Libraries only.
  322. // It is not part of the stable interface of this package.
  323. //
  324. // InternalFetch returns results from a single call to the underlying RPC.
  325. // The number of results is no greater than pageSize.
  326. // If there are no more results, nextPageToken is empty and err is nil.
  327. InternalFetch func(pageSize int, pageToken string) (results []*dataprocpb.WorkflowTemplate, nextPageToken string, err error)
  328. }
  329. // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
  330. func (it *WorkflowTemplateIterator) PageInfo() *iterator.PageInfo {
  331. return it.pageInfo
  332. }
  333. // Next returns the next result. Its second return value is iterator.Done if there are no more
  334. // results. Once Next returns Done, all subsequent calls will return Done.
  335. func (it *WorkflowTemplateIterator) Next() (*dataprocpb.WorkflowTemplate, error) {
  336. var item *dataprocpb.WorkflowTemplate
  337. if err := it.nextFunc(); err != nil {
  338. return item, err
  339. }
  340. item = it.items[0]
  341. it.items = it.items[1:]
  342. return item, nil
  343. }
  344. func (it *WorkflowTemplateIterator) bufLen() int {
  345. return len(it.items)
  346. }
  347. func (it *WorkflowTemplateIterator) takeBuf() interface{} {
  348. b := it.items
  349. it.items = nil
  350. return b
  351. }
  352. // InstantiateInlineWorkflowTemplateOperation manages a long-running operation from InstantiateInlineWorkflowTemplate.
  353. type InstantiateInlineWorkflowTemplateOperation struct {
  354. lro *longrunning.Operation
  355. }
  356. // InstantiateInlineWorkflowTemplateOperation returns a new InstantiateInlineWorkflowTemplateOperation from a given name.
  357. // The name must be that of a previously created InstantiateInlineWorkflowTemplateOperation, possibly from a different process.
  358. func (c *WorkflowTemplateClient) InstantiateInlineWorkflowTemplateOperation(name string) *InstantiateInlineWorkflowTemplateOperation {
  359. return &InstantiateInlineWorkflowTemplateOperation{
  360. lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
  361. }
  362. }
  363. // Wait blocks until the long-running operation is completed, returning any error encountered.
  364. //
  365. // See documentation of Poll for error-handling information.
  366. func (op *InstantiateInlineWorkflowTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
  367. return op.lro.WaitWithInterval(ctx, nil, 10000*time.Millisecond, opts...)
  368. }
  369. // Poll fetches the latest state of the long-running operation.
  370. //
  371. // Poll also fetches the latest metadata, which can be retrieved by Metadata.
  372. //
  373. // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
  374. // the operation has completed with failure, the error is returned and op.Done will return true.
  375. // If Poll succeeds and the operation has completed successfully, op.Done will return true.
  376. func (op *InstantiateInlineWorkflowTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
  377. return op.lro.Poll(ctx, nil, opts...)
  378. }
  379. // Metadata returns metadata associated with the long-running operation.
  380. // Metadata itself does not contact the server, but Poll does.
  381. // To get the latest metadata, call this method after a successful call to Poll.
  382. // If the metadata is not available, the returned metadata and error are both nil.
  383. func (op *InstantiateInlineWorkflowTemplateOperation) Metadata() (*dataprocpb.WorkflowMetadata, error) {
  384. var meta dataprocpb.WorkflowMetadata
  385. if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
  386. return nil, nil
  387. } else if err != nil {
  388. return nil, err
  389. }
  390. return &meta, nil
  391. }
  392. // Done reports whether the long-running operation has completed.
  393. func (op *InstantiateInlineWorkflowTemplateOperation) Done() bool {
  394. return op.lro.Done()
  395. }
  396. // Name returns the name of the long-running operation.
  397. // The name is assigned by the server and is unique within the service from which the operation is created.
  398. func (op *InstantiateInlineWorkflowTemplateOperation) Name() string {
  399. return op.lro.Name()
  400. }
  401. // Cancel starts asynchronous cancellation on a long-running operation.
  402. // The server makes a best effort to cancel the operation, but success is not guaranteed.
  403. // Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation
  404. // completed despite cancellation. On successful cancellation, the operation is not deleted;
  405. // instead, op.Poll returns an error with code Canceled.
  406. func (op *InstantiateInlineWorkflowTemplateOperation) Cancel(ctx context.Context, opts ...gax.CallOption) error {
  407. return op.lro.Cancel(ctx, opts...)
  408. }
  409. // Delete deletes a long-running operation.
  410. // This method indicates that the client is no longer interested in the operation result.
  411. // It does not cancel the operation.
  412. func (op *InstantiateInlineWorkflowTemplateOperation) Delete(ctx context.Context, opts ...gax.CallOption) error {
  413. return op.lro.Delete(ctx, opts...)
  414. }
  415. // InstantiateWorkflowTemplateOperation manages a long-running operation from InstantiateWorkflowTemplate.
  416. type InstantiateWorkflowTemplateOperation struct {
  417. lro *longrunning.Operation
  418. }
  419. // InstantiateWorkflowTemplateOperation returns a new InstantiateWorkflowTemplateOperation from a given name.
  420. // The name must be that of a previously created InstantiateWorkflowTemplateOperation, possibly from a different process.
  421. func (c *WorkflowTemplateClient) InstantiateWorkflowTemplateOperation(name string) *InstantiateWorkflowTemplateOperation {
  422. return &InstantiateWorkflowTemplateOperation{
  423. lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
  424. }
  425. }
  426. // Wait blocks until the long-running operation is completed, returning any error encountered.
  427. //
  428. // See documentation of Poll for error-handling information.
  429. func (op *InstantiateWorkflowTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
  430. return op.lro.WaitWithInterval(ctx, nil, 10000*time.Millisecond, opts...)
  431. }
  432. // Poll fetches the latest state of the long-running operation.
  433. //
  434. // Poll also fetches the latest metadata, which can be retrieved by Metadata.
  435. //
  436. // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
  437. // the operation has completed with failure, the error is returned and op.Done will return true.
  438. // If Poll succeeds and the operation has completed successfully, op.Done will return true.
  439. func (op *InstantiateWorkflowTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
  440. return op.lro.Poll(ctx, nil, opts...)
  441. }
  442. // Metadata returns metadata associated with the long-running operation.
  443. // Metadata itself does not contact the server, but Poll does.
  444. // To get the latest metadata, call this method after a successful call to Poll.
  445. // If the metadata is not available, the returned metadata and error are both nil.
  446. func (op *InstantiateWorkflowTemplateOperation) Metadata() (*dataprocpb.WorkflowMetadata, error) {
  447. var meta dataprocpb.WorkflowMetadata
  448. if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
  449. return nil, nil
  450. } else if err != nil {
  451. return nil, err
  452. }
  453. return &meta, nil
  454. }
  455. // Done reports whether the long-running operation has completed.
  456. func (op *InstantiateWorkflowTemplateOperation) Done() bool {
  457. return op.lro.Done()
  458. }
  459. // Name returns the name of the long-running operation.
  460. // The name is assigned by the server and is unique within the service from which the operation is created.
  461. func (op *InstantiateWorkflowTemplateOperation) Name() string {
  462. return op.lro.Name()
  463. }
  464. // Cancel starts asynchronous cancellation on a long-running operation.
  465. // The server makes a best effort to cancel the operation, but success is not guaranteed.
  466. // Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation
  467. // completed despite cancellation. On successful cancellation, the operation is not deleted;
  468. // instead, op.Poll returns an error with code Canceled.
  469. func (op *InstantiateWorkflowTemplateOperation) Cancel(ctx context.Context, opts ...gax.CallOption) error {
  470. return op.lro.Cancel(ctx, opts...)
  471. }
  472. // Delete deletes a long-running operation.
  473. // This method indicates that the client is no longer interested in the operation result.
  474. // It does not cancel the operation.
  475. func (op *InstantiateWorkflowTemplateOperation) Delete(ctx context.Context, opts ...gax.CallOption) error {
  476. return op.lro.Delete(ctx, opts...)
  477. }