From 80e959202b1d4d46a6e7a988a515848eab173ed1 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 22 Jun 2021 00:40:54 +0000 Subject: [PATCH 1/2] chore: remove all monolith Bazel deps chore: release gapic-generator-csharp v1.3.7 chore: release gapic-generator-go 0.20.5 chore: release gapic-generator-java 1.0.14 chore: release gapic-generator-php 1.0.1 chore: release gapic-generator-python 0.50.0 chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: https://github.com/googleapis/googleapis/commit/076f7e9f0b258bdb54338895d7251b202e8f0de3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/27e4c88b4048e5f56508d4e1aa417d60a3380892 --- .../workflows/executions/v1/executions.proto | 253 ++++ owl-bot-staging/executions/v1/src/index.ts | 25 + .../executions/v1/src/v1/executions_client.ts | 859 ++++++++++++++ .../v1/src/v1/executions_client_config.json | 42 + .../v1/src/v1/executions_proto_list.json | 3 + .../executions/v1/src/v1/gapic_metadata.json | 67 ++ owl-bot-staging/executions/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../executions/v1/system-test/install.ts | 49 + .../executions/v1/test/gapic_executions_v1.ts | 744 ++++++++++++ .../executions/v1beta/executions.proto | 252 ++++ .../executions/v1beta/src/index.ts | 25 + .../v1beta/src/v1beta/executions_client.ts | 859 ++++++++++++++ .../src/v1beta/executions_client_config.json | 42 + .../src/v1beta/executions_proto_list.json | 3 + .../v1beta/src/v1beta/gapic_metadata.json | 67 ++ .../executions/v1beta/src/v1beta/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../executions/v1beta/system-test/install.ts | 49 + .../v1beta/test/gapic_executions_v1beta.ts | 744 ++++++++++++ .../workflows/executions/v1/executions.proto | 253 ++++ .../google/cloud/workflows/v1/workflows.proto | 314 +++++ owl-bot-staging/v1/src/index.ts | 25 + .../v1/src/v1/executions_client.ts | 859 ++++++++++++++ .../v1/src/v1/executions_client_config.json | 42 + .../v1/src/v1/executions_proto_list.json | 3 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 77 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + owl-bot-staging/v1/src/v1/workflows_client.ts | 1038 +++++++++++++++++ .../v1/src/v1/workflows_client_config.json | 46 + .../v1/src/v1/workflows_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_executions_v1.ts | 744 ++++++++++++ owl-bot-staging/v1/test/gapic_workflows_v1.ts | 1012 ++++++++++++++++ .../executions/v1beta/executions.proto | 252 ++++ .../cloud/workflows/v1beta/workflows.proto | 314 +++++ owl-bot-staging/v1beta/src/index.ts | 25 + .../v1beta/src/v1beta/executions_client.ts | 859 ++++++++++++++ .../src/v1beta/executions_client_config.json | 42 + .../src/v1beta/executions_proto_list.json | 3 + .../v1beta/src/v1beta/gapic_metadata.json | 77 ++ owl-bot-staging/v1beta/src/v1beta/index.ts | 19 + .../v1beta/src/v1beta/workflows_client.ts | 1038 +++++++++++++++++ .../src/v1beta/workflows_client_config.json | 46 + .../src/v1beta/workflows_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1beta/system-test/install.ts | 49 + .../v1beta/test/gapic_executions_v1beta.ts | 744 ++++++++++++ .../v1beta/test/gapic_workflows_v1beta.ts | 1012 ++++++++++++++++ 54 files changed, 13324 insertions(+) create mode 100644 owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto create mode 100644 owl-bot-staging/executions/v1/src/index.ts create mode 100644 owl-bot-staging/executions/v1/src/v1/executions_client.ts create mode 100644 owl-bot-staging/executions/v1/src/v1/executions_client_config.json create mode 100644 owl-bot-staging/executions/v1/src/v1/executions_proto_list.json create mode 100644 owl-bot-staging/executions/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/executions/v1/src/v1/index.ts create mode 100644 owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/executions/v1/system-test/install.ts create mode 100644 owl-bot-staging/executions/v1/test/gapic_executions_v1.ts create mode 100644 owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto create mode 100644 owl-bot-staging/executions/v1beta/src/index.ts create mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts create mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json create mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json create mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/index.ts create mode 100644 owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/executions/v1beta/system-test/install.ts create mode 100644 owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts create mode 100644 owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/executions_client.ts create mode 100644 owl-bot-staging/v1/src/v1/executions_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/executions_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/workflows_client.ts create mode 100644 owl-bot-staging/v1/src/v1/workflows_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/workflows_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_executions_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_workflows_v1.ts create mode 100644 owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto create mode 100644 owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto create mode 100644 owl-bot-staging/v1beta/src/index.ts create mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_client.ts create mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_client_config.json create mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json create mode 100644 owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta/src/v1beta/index.ts create mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_client.ts create mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json create mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json create mode 100644 owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta/system-test/install.ts create mode 100644 owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts create mode 100644 owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts diff --git a/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto b/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto new file mode 100644 index 0000000..583a5d9 --- /dev/null +++ b/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto @@ -0,0 +1,253 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.executions.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1;executions"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionsProto"; +option java_package = "com.google.cloud.workflows.executions.v1"; +option (google.api.resource_definition) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" +}; + +// Executions is used to start and manage running instances of +// [Workflows][google.cloud.workflows.v1.Workflow] called executions. +service Executions { + option (google.api.default_host) = "workflowexecutions.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Returns a list of executions which belong to the workflow with + // the given name. The method returns executions of all workflow + // revisions. Returned executions are ordered by their start time (newest + // first). + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a new execution using the latest revision of the given workflow. + rpc CreateExecution(CreateExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" + body: "execution" + }; + option (google.api.method_signature) = "parent,execution"; + } + + // Returns an execution of the given name. + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Cancels an execution of the given name. + rpc CancelExecution(CancelExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// A running instance of a +// [Workflow](/workflows/docs/reference/rest/v1/projects.locations.workflows). +message Execution { + option (google.api.resource) = { + type: "workflowexecutions.googleapis.com/Execution" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" + }; + + // Error describes why the execution was abnormally terminated. + message Error { + // Error payload returned by the execution, represented as a JSON string. + string payload = 1; + + // Human readable error context, helpful for debugging purposes. + string context = 2; + } + + // Describes the current state of the execution. More states may be added + // in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The execution is in progress. + ACTIVE = 1; + + // The execution finished successfully. + SUCCEEDED = 2; + + // The execution failed with an error. + FAILED = 3; + + // The execution was stopped intentionally. + CANCELLED = 4; + } + + // Output only. The resource name of the execution. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the beginning of execution. + google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the end of execution, successful or not. + google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Current state of the execution. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input parameters of the execution represented as a JSON string. + // The size limit is 32KB. + string argument = 5; + + // Output only. Output of the execution represented as a JSON string. The + // value can only be present if the execution's state is `SUCCEEDED`. + string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The error which caused the execution to finish prematurely. + // The value is only present if the execution's state is `FAILED` + // or `CANCELLED`. + Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Revision of the workflow this execution is using. + string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for the +// [ListExecutions][] +// method. +message ListExecutionsRequest { + // Required. Name of the workflow for which the executions should be listed. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Maximum number of executions to return per call. + // Max supported value depends on the selected Execution view: it's 10000 for + // BASIC and 100 for FULL. The default value used if the field is not + // specified is 100, regardless of the selected view. Values greater than + // the max value will be coerced down to it. + int32 page_size = 2; + + // A page token, received from a previous `ListExecutions` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListExecutions` must + // match the call that provided the page token. + string page_token = 3; + + // Optional. A view defining which fields should be filled in the returned executions. + // The API will default to the BASIC view. + ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for the +// [ListExecutions][google.cloud.workflows.executions.v1.Executions.ListExecutions] +// method. +message ListExecutionsResponse { + // The executions which match the request. + repeated Execution executions = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Request for the +// [CreateExecution][google.cloud.workflows.executions.v1.Executions.CreateExecution] +// method. +message CreateExecutionRequest { + // Required. Name of the workflow for which an execution should be created. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + // The latest revision of the workflow will be used. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Required. Execution to be created. + Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [GetExecution][google.cloud.workflows.executions.v1.Executions.GetExecution] +// method. +message GetExecutionRequest { + // Required. Name of the execution to be retrieved. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; + + // Optional. A view defining which fields should be filled in the returned execution. + // The API will default to the FULL view. + ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for the +// [CancelExecution][google.cloud.workflows.executions.v1.Executions.CancelExecution] +// method. +message CancelExecutionRequest { + // Required. Name of the execution to be cancelled. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; +} + +// Defines possible views for execution resource. +enum ExecutionView { + // The default / unset value. + EXECUTION_VIEW_UNSPECIFIED = 0; + + // Includes only basic metadata about the execution. + // Following fields are returned: name, start_time, end_time, state + // and workflow_revision_id. + BASIC = 1; + + // Includes all data. + FULL = 2; +} diff --git a/owl-bot-staging/executions/v1/src/index.ts b/owl-bot-staging/executions/v1/src/index.ts new file mode 100644 index 0000000..a593c0e --- /dev/null +++ b/owl-bot-staging/executions/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ExecutionsClient = v1.ExecutionsClient; +type ExecutionsClient = v1.ExecutionsClient; +export {v1, ExecutionsClient}; +export default {v1, ExecutionsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_client.ts b/owl-bot-staging/executions/v1/src/v1/executions_client.ts new file mode 100644 index 0000000..1133ca0 --- /dev/null +++ b/owl-bot-staging/executions/v1/src/v1/executions_client.ts @@ -0,0 +1,859 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/executions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './executions_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Executions is used to start and manage running instances of + * {@link google.cloud.workflows.v1.Workflow|Workflows} called executions. + * @class + * @memberof v1 + */ +export class ExecutionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + executionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExecutionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExecutionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.executions.v1.Executions', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.executionsStub) { + return this.executionsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.executions.v1.Executions. + this.executionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1.Executions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.executions.v1.Executions, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const executionsStubMethods = + ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; + for (const methodName of executionsStubMethods) { + const callPromise = this.executionsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.executionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createExecution( + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined + ]>; + createExecution( + request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; + createExecution( + request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new execution using the latest revision of the given workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which an execution should be created. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * The latest revision of the workflow will be used. + * @param {google.cloud.workflows.executions.v1.Execution} request.execution + * Required. Execution to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createExecution(request); + */ + createExecution( + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createExecution(request, options, callback); + } + getExecution( + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be retrieved. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned execution. + * The API will default to the FULL view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getExecution(request); + */ + getExecution( + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined + ]>; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Cancels an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be cancelled. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.cancelExecution(request); + */ + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.cancelExecution(request, options, callback); + } + + listExecutions( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution[], + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): void; + listExecutions( + request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): void; +/** + * Returns a list of executions which belong to the workflow with + * the given name. The method returns executions of all workflow + * revisions. Returned executions are ordered by their start time (newest + * first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution[], + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Execution]{@link google.cloud.workflows.executions.v1.Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listExecutionsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listExecutionsAsync( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,workflow:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the workflow from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).workflow; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.executionsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_client_config.json b/owl-bot-staging/executions/v1/src/v1/executions_client_config.json new file mode 100644 index 0000000..ea2d78f --- /dev/null +++ b/owl-bot-staging/executions/v1/src/v1/executions_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.workflows.executions.v1.Executions": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListExecutions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CancelExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json b/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json new file mode 100644 index 0000000..3cffd5d --- /dev/null +++ b/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/executions/v1/executions.proto" +] diff --git a/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json b/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json new file mode 100644 index 0000000..aea6126 --- /dev/null +++ b/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json @@ -0,0 +1,67 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.workflows.executions.v1", + "libraryPackage": "@google-cloud/workflow-executions", + "services": { + "Executions": { + "clients": { + "grpc": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CancelExecution": { + "methods": [ + "cancelExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CancelExecution": { + "methods": [ + "cancelExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/executions/v1/src/v1/index.ts b/owl-bot-staging/executions/v1/src/v1/index.ts new file mode 100644 index 0000000..beee77e --- /dev/null +++ b/owl-bot-staging/executions/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {ExecutionsClient} from './executions_client'; diff --git a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..b7ac36b --- /dev/null +++ b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const executions = require('@google-cloud/workflow-executions'); + +function main() { + const executionsClient = new executions.ExecutionsClient(); +} + +main(); diff --git a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..125bbdb --- /dev/null +++ b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ExecutionsClient} from '@google-cloud/workflow-executions'; + +// check that the client class type name can be used +function doStuffWithExecutionsClient(client: ExecutionsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const executionsClient = new ExecutionsClient(); + doStuffWithExecutionsClient(executionsClient); +} + +main(); diff --git a/owl-bot-staging/executions/v1/system-test/install.ts b/owl-bot-staging/executions/v1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/executions/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts b/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts new file mode 100644 index 0000000..2093e36 --- /dev/null +++ b/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts @@ -0,0 +1,744 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as executionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ExecutionsClient', () => { + it('has servicePath', () => { + const servicePath = executionsModule.v1.ExecutionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = executionsModule.v1.ExecutionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = executionsModule.v1.ExecutionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new executionsModule.v1.ExecutionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new executionsModule.v1.ExecutionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + await client.initialize(); + assert(client.executionsStub); + }); + + it('has close method', () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); + const [response] = await client.createExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createExecution(request), expectedError); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('cancelExecution', () => { + it('invokes cancelExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); + const [response] = await client.cancelExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes cancelExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes cancelExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelExecution(request), expectedError); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listExecutions with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + execution: "executionValue", + }; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromExecutionName', () => { + const result = client.matchWorkflowFromExecutionName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto b/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto new file mode 100644 index 0000000..5b03fdf --- /dev/null +++ b/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto @@ -0,0 +1,252 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.executions.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1beta;executions"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionsProto"; +option java_package = "com.google.cloud.workflows.executions.v1beta"; +option (google.api.resource_definition) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" +}; + +// Executions is used to start and manage running instances of +// [Workflows][google.cloud.workflows.v1beta.Workflow] called executions. +service Executions { + option (google.api.default_host) = "workflowexecutions.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Returns a list of executions which belong to the workflow with + // the given name. The method returns executions of all workflow + // revisions. Returned executions are ordered by their start time (newest + // first). + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a new execution using the latest revision of the given workflow. + rpc CreateExecution(CreateExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" + body: "execution" + }; + option (google.api.method_signature) = "parent,execution"; + } + + // Returns an execution of the given name. + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Cancels an execution of the given name. + rpc CancelExecution(CancelExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// A running instance of a [Workflow][google.cloud.workflows.v1beta.Workflow]. +message Execution { + option (google.api.resource) = { + type: "workflowexecutions.googleapis.com/Execution" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" + }; + + // Error describes why the execution was abnormally terminated. + message Error { + // Error payload returned by the execution, represented as a JSON string. + string payload = 1; + + // Human readable error context, helpful for debugging purposes. + string context = 2; + } + + // Describes the current state of the execution. More states may be added + // in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The execution is in progress. + ACTIVE = 1; + + // The execution finished successfully. + SUCCEEDED = 2; + + // The execution failed with an error. + FAILED = 3; + + // The execution was stopped intentionally. + CANCELLED = 4; + } + + // Output only. The resource name of the execution. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the beginning of execution. + google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the end of execution, successful or not. + google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Current state of the execution. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input parameters of the execution represented as a JSON string. + // The size limit is 32KB. + string argument = 5; + + // Output only. Output of the execution represented as a JSON string. The + // value can only be present if the execution's state is `SUCCEEDED`. + string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The error which caused the execution to finish prematurely. + // The value is only present if the execution's state is `FAILED` + // or `CANCELLED`. + Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Revision of the workflow this execution is using. + string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for the +// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] +// method. +message ListExecutionsRequest { + // Required. Name of the workflow for which the executions should be listed. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Maximum number of executions to return per call. + // Max supported value depends on the selected Execution view: it's 10000 for + // BASIC and 100 for FULL. The default value used if the field is not + // specified is 100, regardless of the selected view. Values greater than + // the max value will be coerced down to it. + int32 page_size = 2; + + // A page token, received from a previous `ListExecutions` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListExecutions` must + // match the call that provided the page token. + string page_token = 3; + + // Optional. A view defining which fields should be filled in the returned executions. + // The API will default to the BASIC view. + ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for the +// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] +// method. +message ListExecutionsResponse { + // The executions which match the request. + repeated Execution executions = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Request for the +// [CreateExecution][google.cloud.workflows.executions.v1beta.Executions.CreateExecution] +// method. +message CreateExecutionRequest { + // Required. Name of the workflow for which an execution should be created. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + // The latest revision of the workflow will be used. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Required. Execution to be created. + Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [GetExecution][google.cloud.workflows.executions.v1beta.Executions.GetExecution] +// method. +message GetExecutionRequest { + // Required. Name of the execution to be retrieved. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; + + // Optional. A view defining which fields should be filled in the returned execution. + // The API will default to the FULL view. + ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for the +// [CancelExecution][google.cloud.workflows.executions.v1beta.Executions.CancelExecution] +// method. +message CancelExecutionRequest { + // Required. Name of the execution to be cancelled. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; +} + +// Defines possible views for execution resource. +enum ExecutionView { + // The default / unset value. + EXECUTION_VIEW_UNSPECIFIED = 0; + + // Includes only basic metadata about the execution. + // Following fields are returned: name, start_time, end_time, state + // and workflow_revision_id. + BASIC = 1; + + // Includes all data. + FULL = 2; +} diff --git a/owl-bot-staging/executions/v1beta/src/index.ts b/owl-bot-staging/executions/v1beta/src/index.ts new file mode 100644 index 0000000..f4dfeed --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta from './v1beta'; +const ExecutionsClient = v1beta.ExecutionsClient; +type ExecutionsClient = v1beta.ExecutionsClient; +export {v1beta, ExecutionsClient}; +export default {v1beta, ExecutionsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts new file mode 100644 index 0000000..e9afb3e --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts @@ -0,0 +1,859 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/executions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './executions_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Executions is used to start and manage running instances of + * {@link google.cloud.workflows.v1beta.Workflow|Workflows} called executions. + * @class + * @memberof v1beta + */ +export class ExecutionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + executionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExecutionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExecutionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.executions.v1beta.Executions', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.executionsStub) { + return this.executionsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.executions.v1beta.Executions. + this.executionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1beta.Executions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.executions.v1beta.Executions, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const executionsStubMethods = + ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; + for (const methodName of executionsStubMethods) { + const callPromise = this.executionsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.executionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined + ]>; + createExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; + createExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new execution using the latest revision of the given workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which an execution should be created. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * The latest revision of the workflow will be used. + * @param {google.cloud.workflows.executions.v1beta.Execution} request.execution + * Required. Execution to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createExecution(request); + */ + createExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createExecution(request, options, callback); + } + getExecution( + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be retrieved. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned execution. + * The API will default to the FULL view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getExecution(request); + */ + getExecution( + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined + ]>; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Cancels an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be cancelled. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.cancelExecution(request); + */ + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.cancelExecution(request, options, callback); + } + + listExecutions( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution[], + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): void; + listExecutions( + request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): void; +/** + * Returns a list of executions which belong to the workflow with + * the given name. The method returns executions of all workflow + * revisions. Returned executions are ordered by their start time (newest + * first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution[], + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listExecutionsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listExecutionsAsync( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,workflow:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the workflow from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).workflow; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.executionsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json new file mode 100644 index 0000000..bf2692e --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.workflows.executions.v1beta.Executions": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListExecutions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CancelExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json b/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json new file mode 100644 index 0000000..2450667 --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/executions/v1beta/executions.proto" +] diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 0000000..254e6e2 --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,67 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.workflows.executions.v1beta", + "libraryPackage": "@google-cloud/workflows-executions", + "services": { + "Executions": { + "clients": { + "grpc": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CancelExecution": { + "methods": [ + "cancelExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ExecutionsClient", + "rpcs": { + "CreateExecution": { + "methods": [ + "createExecution" + ] + }, + "GetExecution": { + "methods": [ + "getExecution" + ] + }, + "CancelExecution": { + "methods": [ + "cancelExecution" + ] + }, + "ListExecutions": { + "methods": [ + "listExecutions", + "listExecutionsStream", + "listExecutionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/index.ts b/owl-bot-staging/executions/v1beta/src/v1beta/index.ts new file mode 100644 index 0000000..beee77e --- /dev/null +++ b/owl-bot-staging/executions/v1beta/src/v1beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {ExecutionsClient} from './executions_client'; diff --git a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..12ccbfa --- /dev/null +++ b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const executions = require('@google-cloud/workflows-executions'); + +function main() { + const executionsClient = new executions.ExecutionsClient(); +} + +main(); diff --git a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..e7cf00f --- /dev/null +++ b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {ExecutionsClient} from '@google-cloud/workflows-executions'; + +// check that the client class type name can be used +function doStuffWithExecutionsClient(client: ExecutionsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const executionsClient = new ExecutionsClient(); + doStuffWithExecutionsClient(executionsClient); +} + +main(); diff --git a/owl-bot-staging/executions/v1beta/system-test/install.ts b/owl-bot-staging/executions/v1beta/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/executions/v1beta/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts b/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts new file mode 100644 index 0000000..725c793 --- /dev/null +++ b/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts @@ -0,0 +1,744 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as executionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.ExecutionsClient', () => { + it('has servicePath', () => { + const servicePath = executionsModule.v1beta.ExecutionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = executionsModule.v1beta.ExecutionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = executionsModule.v1beta.ExecutionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new executionsModule.v1beta.ExecutionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + await client.initialize(); + assert(client.executionsStub); + }); + + it('has close method', () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); + const [response] = await client.createExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createExecution(request), expectedError); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('cancelExecution', () => { + it('invokes cancelExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); + const [response] = await client.cancelExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes cancelExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes cancelExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelExecution(request), expectedError); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listExecutions with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + execution: "executionValue", + }; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromExecutionName', () => { + const result = client.matchWorkflowFromExecutionName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto b/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto new file mode 100644 index 0000000..583a5d9 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto @@ -0,0 +1,253 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.executions.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1;executions"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionsProto"; +option java_package = "com.google.cloud.workflows.executions.v1"; +option (google.api.resource_definition) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" +}; + +// Executions is used to start and manage running instances of +// [Workflows][google.cloud.workflows.v1.Workflow] called executions. +service Executions { + option (google.api.default_host) = "workflowexecutions.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Returns a list of executions which belong to the workflow with + // the given name. The method returns executions of all workflow + // revisions. Returned executions are ordered by their start time (newest + // first). + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a new execution using the latest revision of the given workflow. + rpc CreateExecution(CreateExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" + body: "execution" + }; + option (google.api.method_signature) = "parent,execution"; + } + + // Returns an execution of the given name. + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Cancels an execution of the given name. + rpc CancelExecution(CancelExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// A running instance of a +// [Workflow](/workflows/docs/reference/rest/v1/projects.locations.workflows). +message Execution { + option (google.api.resource) = { + type: "workflowexecutions.googleapis.com/Execution" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" + }; + + // Error describes why the execution was abnormally terminated. + message Error { + // Error payload returned by the execution, represented as a JSON string. + string payload = 1; + + // Human readable error context, helpful for debugging purposes. + string context = 2; + } + + // Describes the current state of the execution. More states may be added + // in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The execution is in progress. + ACTIVE = 1; + + // The execution finished successfully. + SUCCEEDED = 2; + + // The execution failed with an error. + FAILED = 3; + + // The execution was stopped intentionally. + CANCELLED = 4; + } + + // Output only. The resource name of the execution. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the beginning of execution. + google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the end of execution, successful or not. + google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Current state of the execution. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input parameters of the execution represented as a JSON string. + // The size limit is 32KB. + string argument = 5; + + // Output only. Output of the execution represented as a JSON string. The + // value can only be present if the execution's state is `SUCCEEDED`. + string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The error which caused the execution to finish prematurely. + // The value is only present if the execution's state is `FAILED` + // or `CANCELLED`. + Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Revision of the workflow this execution is using. + string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for the +// [ListExecutions][] +// method. +message ListExecutionsRequest { + // Required. Name of the workflow for which the executions should be listed. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Maximum number of executions to return per call. + // Max supported value depends on the selected Execution view: it's 10000 for + // BASIC and 100 for FULL. The default value used if the field is not + // specified is 100, regardless of the selected view. Values greater than + // the max value will be coerced down to it. + int32 page_size = 2; + + // A page token, received from a previous `ListExecutions` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListExecutions` must + // match the call that provided the page token. + string page_token = 3; + + // Optional. A view defining which fields should be filled in the returned executions. + // The API will default to the BASIC view. + ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for the +// [ListExecutions][google.cloud.workflows.executions.v1.Executions.ListExecutions] +// method. +message ListExecutionsResponse { + // The executions which match the request. + repeated Execution executions = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Request for the +// [CreateExecution][google.cloud.workflows.executions.v1.Executions.CreateExecution] +// method. +message CreateExecutionRequest { + // Required. Name of the workflow for which an execution should be created. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + // The latest revision of the workflow will be used. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Required. Execution to be created. + Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [GetExecution][google.cloud.workflows.executions.v1.Executions.GetExecution] +// method. +message GetExecutionRequest { + // Required. Name of the execution to be retrieved. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; + + // Optional. A view defining which fields should be filled in the returned execution. + // The API will default to the FULL view. + ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for the +// [CancelExecution][google.cloud.workflows.executions.v1.Executions.CancelExecution] +// method. +message CancelExecutionRequest { + // Required. Name of the execution to be cancelled. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; +} + +// Defines possible views for execution resource. +enum ExecutionView { + // The default / unset value. + EXECUTION_VIEW_UNSPECIFIED = 0; + + // Includes only basic metadata about the execution. + // Following fields are returned: name, start_time, end_time, state + // and workflow_revision_id. + BASIC = 1; + + // Includes all data. + FULL = 2; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto b/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto new file mode 100644 index 0000000..7e46c2f --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto @@ -0,0 +1,314 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/v1;workflows"; +option java_multiple_files = true; +option java_outer_classname = "WorkflowsProto"; +option java_package = "com.google.cloud.workflows.v1"; + +// Workflows is used to deploy and execute workflow programs. +// Workflows makes sure the program executes reliably, despite hardware and +// networking interruptions. +service Workflows { + option (google.api.default_host) = "workflows.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists Workflows in a given project and location. + // The default order is not specified. + rpc ListWorkflows(ListWorkflowsRequest) returns (ListWorkflowsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/workflows" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Workflow. + rpc GetWorkflow(GetWorkflowRequest) returns (Workflow) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/workflows/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new workflow. If a workflow with the specified name already + // exists in the specified project and location, the long running operation + // will return [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. + rpc CreateWorkflow(CreateWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/workflows" + body: "workflow" + }; + option (google.api.method_signature) = "parent,workflow,workflow_id"; + option (google.longrunning.operation_info) = { + response_type: "Workflow" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a workflow with the specified name. + // This method also cancels and deletes all running executions of the + // workflow. + rpc DeleteWorkflow(DeleteWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/workflows/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Updates an existing workflow. + // Running this method has no impact on already running executions of the + // workflow. A new revision of the workflow may be created as a result of a + // successful update operation. In that case, such revision will be used + // in new workflow executions. + rpc UpdateWorkflow(UpdateWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{workflow.name=projects/*/locations/*/workflows/*}" + body: "workflow" + }; + option (google.api.method_signature) = "workflow,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Workflow" + metadata_type: "OperationMetadata" + }; + } +} + +// Workflow program to be executed by Workflows. +message Workflow { + option (google.api.resource) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" + }; + + // Describes the current state of workflow deployment. More states may be + // added in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The workflow has been deployed successfully and is serving. + ACTIVE = 1; + } + + // The resource name of the workflow. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1; + + // Description of the workflow provided by the user. + // Must be at most 1000 unicode characters long. + string description = 2; + + // Output only. State of the workflow deployment. + State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The revision of the workflow. + // A new revision of a workflow is created as a result of updating the + // following fields of a workflow: + // - `source_code` + // - `service_account` + // The format is "000001-a4d", where the first 6 characters define + // the zero-padded revision ordinal number. They are followed by a hyphen and + // 3 hexadecimal random characters. + string revision_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp of when the workflow was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the workflow. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp that the latest revision of the workflow + // was created. + google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Labels associated with this workflow. + // Labels can contain at most 64 entries. Keys and values can be no longer + // than 63 characters and can only contain lowercase letters, numeric + // characters, underscores and dashes. Label keys must start with a letter. + // International characters are allowed. + map labels = 8; + + // Name of the service account associated with the latest workflow version. + // This service account represents the identity of the workflow and determines + // what permissions the workflow has. + // Format: projects/{project}/serviceAccounts/{account} + // + // Using `-` as a wildcard for the `{project}` will infer the project from + // the account. The `{account}` value can be the `email` address or the + // `unique_id` of the service account. + // + // If not provided, workflow will use the project's default service account. + // Modifying this field for an existing workflow results in a new workflow + // revision. + string service_account = 9; + + // Required. Location of the workflow source code. + // Modifying this field for an existing workflow results in a new workflow + // revision. + oneof source_code { + // Workflow code to be executed. The size limit is 32KB. + string source_contents = 10; + } +} + +// Request for the +// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows] +// method. +message ListWorkflowsRequest { + // Required. Project and location from which the workflows should be listed. + // Format: projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of workflows to return per call. The service may return + // fewer than this value. If the value is not specified, a default value of + // 500 will be used. The maximum permitted value is 1000 and values greater + // than 1000 will be coerced down to 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListWorkflows` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListWorkflows` must + // match the call that provided the page token. + string page_token = 3; + + // Filter to restrict results to specific workflows. + string filter = 4; + + // Comma-separated list of fields that that specify the order of the results. + // Default sorting order for a field is ascending. To specify descending order + // for a field, append a " desc" suffix. + // If not specified, the results will be returned in an unspecified order. + string order_by = 5; +} + +// Response for the +// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows] +// method. +message ListWorkflowsResponse { + // The workflows which match the request. + repeated Workflow workflows = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; + + // Unreachable resources. + repeated string unreachable = 3; +} + +// Request for the +// [GetWorkflow][google.cloud.workflows.v1.Workflows.GetWorkflow] method. +message GetWorkflowRequest { + // Required. Name of the workflow which information should be retrieved. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; +} + +// Request for the +// [CreateWorkflow][google.cloud.workflows.v1.Workflows.CreateWorkflow] +// method. +message CreateWorkflowRequest { + // Required. Project and location in which the workflow should be created. + // Format: projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. Workflow to be created. + Workflow workflow = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID of the workflow to be created. It has to fulfill the + // following requirements: + // + // * Must contain only letters, numbers, underscores and hyphens. + // * Must start with a letter. + // * Must be between 1-64 characters. + // * Must end with a number or a letter. + // * Must be unique within the customer project and location. + string workflow_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [DeleteWorkflow][google.cloud.workflows.v1.Workflows.DeleteWorkflow] +// method. +message DeleteWorkflowRequest { + // Required. Name of the workflow to be deleted. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; +} + +// Request for the +// [UpdateWorkflow][google.cloud.workflows.v1.Workflows.UpdateWorkflow] +// method. +message UpdateWorkflowRequest { + // Required. Workflow to be updated. + Workflow workflow = 1 [(google.api.field_behavior) = REQUIRED]; + + // List of fields to be updated. If not present, the entire workflow + // will be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Server-defined resource path for the target of the operation. + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // API version used to start the operation. + string api_version = 5; +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 0000000..5616212 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const WorkflowsClient = v1.WorkflowsClient; +type WorkflowsClient = v1.WorkflowsClient; +export {v1, WorkflowsClient}; +export default {v1, WorkflowsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/executions_client.ts b/owl-bot-staging/v1/src/v1/executions_client.ts new file mode 100644 index 0000000..1133ca0 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/executions_client.ts @@ -0,0 +1,859 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/executions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './executions_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Executions is used to start and manage running instances of + * {@link google.cloud.workflows.v1.Workflow|Workflows} called executions. + * @class + * @memberof v1 + */ +export class ExecutionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + executionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExecutionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExecutionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.executions.v1.Executions', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.executionsStub) { + return this.executionsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.executions.v1.Executions. + this.executionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1.Executions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.executions.v1.Executions, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const executionsStubMethods = + ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; + for (const methodName of executionsStubMethods) { + const callPromise = this.executionsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.executionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createExecution( + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined + ]>; + createExecution( + request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; + createExecution( + request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new execution using the latest revision of the given workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which an execution should be created. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * The latest revision of the workflow will be used. + * @param {google.cloud.workflows.executions.v1.Execution} request.execution + * Required. Execution to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createExecution(request); + */ + createExecution( + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createExecution(request, options, callback); + } + getExecution( + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be retrieved. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned execution. + * The API will default to the FULL view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getExecution(request); + */ + getExecution( + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined + ]>; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Cancels an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be cancelled. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.cancelExecution(request); + */ + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution, + protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.cancelExecution(request, options, callback); + } + + listExecutions( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution[], + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): void; + listExecutions( + request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): void; +/** + * Returns a list of executions which belong to the workflow with + * the given name. The method returns executions of all workflow + * revisions. Returned executions are ordered by their start time (newest + * first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1.Execution}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1.IExecution>): + Promise<[ + protos.google.cloud.workflows.executions.v1.IExecution[], + protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Execution]{@link google.cloud.workflows.executions.v1.Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listExecutionsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listExecutionsAsync( + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,workflow:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the workflow from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).workflow; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.executionsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/executions_client_config.json b/owl-bot-staging/v1/src/v1/executions_client_config.json new file mode 100644 index 0000000..ea2d78f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/executions_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.workflows.executions.v1.Executions": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListExecutions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CancelExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/executions_proto_list.json b/owl-bot-staging/v1/src/v1/executions_proto_list.json new file mode 100644 index 0000000..3cffd5d --- /dev/null +++ b/owl-bot-staging/v1/src/v1/executions_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/executions/v1/executions.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 0000000..4beac11 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,77 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.workflows.v1", + "libraryPackage": "@google-cloud/workflows", + "services": { + "Workflows": { + "clients": { + "grpc": { + "libraryClient": "WorkflowsClient", + "rpcs": { + "GetWorkflow": { + "methods": [ + "getWorkflow" + ] + }, + "CreateWorkflow": { + "methods": [ + "createWorkflow" + ] + }, + "DeleteWorkflow": { + "methods": [ + "deleteWorkflow" + ] + }, + "UpdateWorkflow": { + "methods": [ + "updateWorkflow" + ] + }, + "ListWorkflows": { + "methods": [ + "listWorkflows", + "listWorkflowsStream", + "listWorkflowsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WorkflowsClient", + "rpcs": { + "GetWorkflow": { + "methods": [ + "getWorkflow" + ] + }, + "CreateWorkflow": { + "methods": [ + "createWorkflow" + ] + }, + "DeleteWorkflow": { + "methods": [ + "deleteWorkflow" + ] + }, + "UpdateWorkflow": { + "methods": [ + "updateWorkflow" + ] + }, + "ListWorkflows": { + "methods": [ + "listWorkflows", + "listWorkflowsStream", + "listWorkflowsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 0000000..79adf07 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {WorkflowsClient} from './workflows_client'; diff --git a/owl-bot-staging/v1/src/v1/workflows_client.ts b/owl-bot-staging/v1/src/v1/workflows_client.ts new file mode 100644 index 0000000..d23eec3 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/workflows_client.ts @@ -0,0 +1,1038 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/workflows_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './workflows_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Workflows is used to deploy and execute workflow programs. + * Workflows makes sure the program executes reliably, despite hardware and + * networking interruptions. + * @class + * @memberof v1 + */ +export class WorkflowsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + workflowsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WorkflowsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WorkflowsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listWorkflows: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'workflows') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const createWorkflowResponse = protoFilesRoot.lookup( + '.google.cloud.workflows.v1.Workflow') as gax.protobuf.Type; + const createWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; + const deleteWorkflowResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; + const updateWorkflowResponse = protoFilesRoot.lookup( + '.google.cloud.workflows.v1.Workflow') as gax.protobuf.Type; + const updateWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createWorkflowResponse.decode.bind(createWorkflowResponse), + createWorkflowMetadata.decode.bind(createWorkflowMetadata)), + deleteWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteWorkflowResponse.decode.bind(deleteWorkflowResponse), + deleteWorkflowMetadata.decode.bind(deleteWorkflowMetadata)), + updateWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateWorkflowResponse.decode.bind(updateWorkflowResponse), + updateWorkflowMetadata.decode.bind(updateWorkflowMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.v1.Workflows', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.workflowsStub) { + return this.workflowsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.v1.Workflows. + this.workflowsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.v1.Workflows') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.v1.Workflows, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const workflowsStubMethods = + ['listWorkflows', 'getWorkflow', 'createWorkflow', 'deleteWorkflow', 'updateWorkflow']; + for (const methodName of workflowsStubMethods) { + const callPromise = this.workflowsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.workflowsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflows.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflows.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getWorkflow( + request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|undefined, {}|undefined + ]>; + getWorkflow( + request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): void; + getWorkflow( + request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + callback: Callback< + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets details of a single Workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the workflow which information should be retrieved. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Workflow]{@link google.cloud.workflows.v1.Workflow}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getWorkflow(request); + */ + getWorkflow( + request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.v1.IWorkflow, + protos.google.cloud.workflows.v1.IGetWorkflowRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getWorkflow(request, options, callback); + } + + createWorkflow( + request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createWorkflow( + request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createWorkflow( + request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new workflow. If a workflow with the specified name already + * exists in the specified project and location, the long running operation + * will return {@link google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS} error. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location in which the workflow should be created. + * Format: projects/{project}/locations/{location} + * @param {google.cloud.workflows.v1.Workflow} request.workflow + * Required. Workflow to be created. + * @param {string} request.workflowId + * Required. The ID of the workflow to be created. It has to fulfill the + * following requirements: + * + * * Must contain only letters, numbers, underscores and hyphens. + * * Must start with a letter. + * * Must be between 1-64 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project and location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.createWorkflow(request); + * const [response] = await operation.promise(); + */ + createWorkflow( + request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkCreateWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkCreateWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + deleteWorkflow( + request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteWorkflow( + request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteWorkflow( + request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Deletes a workflow with the specified name. + * This method also cancels and deletes all running executions of the + * workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the workflow to be deleted. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.deleteWorkflow(request); + * const [response] = await operation.promise(); + */ + deleteWorkflow( + request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkDeleteWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkDeleteWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + updateWorkflow( + request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateWorkflow( + request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateWorkflow( + request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Updates an existing workflow. + * Running this method has no impact on already running executions of the + * workflow. A new revision of the workflow may be created as a result of a + * successful update operation. In that case, such revision will be used + * in new workflow executions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.workflows.v1.Workflow} request.workflow + * Required. Workflow to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * List of fields to be updated. If not present, the entire workflow + * will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.updateWorkflow(request); + * const [response] = await operation.promise(); + */ + updateWorkflow( + request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'workflow.name': request.workflow!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkUpdateWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkUpdateWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + listWorkflows( + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.v1.IWorkflow[], + protos.google.cloud.workflows.v1.IListWorkflowsRequest|null, + protos.google.cloud.workflows.v1.IListWorkflowsResponse + ]>; + listWorkflows( + request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.v1.IListWorkflowsRequest, + protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1.IWorkflow>): void; + listWorkflows( + request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.v1.IListWorkflowsRequest, + protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1.IWorkflow>): void; +/** + * Lists Workflows in a given project and location. + * The default order is not specified. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Workflow]{@link google.cloud.workflows.v1.Workflow}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listWorkflowsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listWorkflows( + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.v1.IListWorkflowsRequest, + protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1.IWorkflow>, + callback?: PaginationCallback< + protos.google.cloud.workflows.v1.IListWorkflowsRequest, + protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1.IWorkflow>): + Promise<[ + protos.google.cloud.workflows.v1.IWorkflow[], + protos.google.cloud.workflows.v1.IListWorkflowsRequest|null, + protos.google.cloud.workflows.v1.IListWorkflowsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listWorkflows(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Workflow]{@link google.cloud.workflows.v1.Workflow} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listWorkflowsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listWorkflowsStream( + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listWorkflows.createStream( + this.innerApiCalls.listWorkflows as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listWorkflows`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Workflow]{@link google.cloud.workflows.v1.Workflow}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listWorkflowsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listWorkflowsAsync( + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listWorkflows.asyncIterate( + this.innerApiCalls['listWorkflows'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.workflowsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/workflows_client_config.json b/owl-bot-staging/v1/src/v1/workflows_client_config.json new file mode 100644 index 0000000..02f67fc --- /dev/null +++ b/owl-bot-staging/v1/src/v1/workflows_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.workflows.v1.Workflows": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListWorkflows": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/workflows_proto_list.json b/owl-bot-staging/v1/src/v1/workflows_proto_list.json new file mode 100644 index 0000000..46c65a9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/workflows_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/v1/workflows.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..f57e805 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const workflows = require('@google-cloud/workflows'); + +function main() { + const workflowsClient = new workflows.WorkflowsClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..3aa8565 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {WorkflowsClient} from '@google-cloud/workflows'; + +// check that the client class type name can be used +function doStuffWithWorkflowsClient(client: WorkflowsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const workflowsClient = new WorkflowsClient(); + doStuffWithWorkflowsClient(workflowsClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_executions_v1.ts b/owl-bot-staging/v1/test/gapic_executions_v1.ts new file mode 100644 index 0000000..2093e36 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_executions_v1.ts @@ -0,0 +1,744 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as executionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ExecutionsClient', () => { + it('has servicePath', () => { + const servicePath = executionsModule.v1.ExecutionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = executionsModule.v1.ExecutionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = executionsModule.v1.ExecutionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new executionsModule.v1.ExecutionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new executionsModule.v1.ExecutionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + await client.initialize(); + assert(client.executionsStub); + }); + + it('has close method', () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); + const [response] = await client.createExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createExecution(request), expectedError); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('cancelExecution', () => { + it('invokes cancelExecution without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); + const [response] = await client.cancelExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes cancelExecution without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes cancelExecution with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelExecution(request), expectedError); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listExecutions with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + execution: "executionValue", + }; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromExecutionName', () => { + const result = client.matchWorkflowFromExecutionName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new executionsModule.v1.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_workflows_v1.ts b/owl-bot-staging/v1/test/gapic_workflows_v1.ts new file mode 100644 index 0000000..dba0a6b --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_workflows_v1.ts @@ -0,0 +1,1012 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as workflowsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.WorkflowsClient', () => { + it('has servicePath', () => { + const servicePath = workflowsModule.v1.WorkflowsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = workflowsModule.v1.WorkflowsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = workflowsModule.v1.WorkflowsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new workflowsModule.v1.WorkflowsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new workflowsModule.v1.WorkflowsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowsStub, undefined); + await client.initialize(); + assert(client.workflowsStub); + }); + + it('has close method', () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getWorkflow', () => { + it('invokes getWorkflow without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()); + client.innerApiCalls.getWorkflow = stubSimpleCall(expectedResponse); + const [response] = await client.getWorkflow(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getWorkflow without error using callback', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()); + client.innerApiCalls.getWorkflow = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getWorkflow( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.v1.IWorkflow|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getWorkflow with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getWorkflow = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getWorkflow(request), expectedError); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createWorkflow', () => { + it('invokes createWorkflow without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.createWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createWorkflow without error using callback', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createWorkflow with call error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createWorkflow(request), expectedError); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createWorkflow with LRO error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateWorkflowProgress without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateWorkflowProgress with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteWorkflow', () => { + it('invokes deleteWorkflow without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteWorkflow without error using callback', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteWorkflow with call error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteWorkflow(request), expectedError); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteWorkflow with LRO error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteWorkflowProgress without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteWorkflowProgress with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateWorkflow', () => { + it('invokes updateWorkflow without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateWorkflow without error using callback', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateWorkflow with call error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateWorkflow(request), expectedError); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateWorkflow with LRO error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateWorkflowProgress without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateWorkflowProgress with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listWorkflows', () => { + it('invokes listWorkflows without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + ]; + client.innerApiCalls.listWorkflows = stubSimpleCall(expectedResponse); + const [response] = await client.listWorkflows(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listWorkflows without error using callback', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + ]; + client.innerApiCalls.listWorkflows = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listWorkflows( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.v1.IWorkflow[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listWorkflows with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listWorkflows = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listWorkflows(request), expectedError); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listWorkflowsStream without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + ]; + client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listWorkflowsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.v1.Workflow[] = []; + stream.on('data', (response: protos.google.cloud.workflows.v1.Workflow) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); + assert.strictEqual( + (client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listWorkflowsStream with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listWorkflowsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.v1.Workflow[] = []; + stream.on('data', (response: protos.google.cloud.workflows.v1.Workflow) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); + assert.strictEqual( + (client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listWorkflows without error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), + ]; + client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.v1.IWorkflow[] = []; + const iterable = client.listWorkflowsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listWorkflows with error', async () => { + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listWorkflowsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.v1.IWorkflow[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new workflowsModule.v1.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto b/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto new file mode 100644 index 0000000..5b03fdf --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto @@ -0,0 +1,252 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.executions.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1beta;executions"; +option java_multiple_files = true; +option java_outer_classname = "ExecutionsProto"; +option java_package = "com.google.cloud.workflows.executions.v1beta"; +option (google.api.resource_definition) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" +}; + +// Executions is used to start and manage running instances of +// [Workflows][google.cloud.workflows.v1beta.Workflow] called executions. +service Executions { + option (google.api.default_host) = "workflowexecutions.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Returns a list of executions which belong to the workflow with + // the given name. The method returns executions of all workflow + // revisions. Returned executions are ordered by their start time (newest + // first). + rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a new execution using the latest revision of the given workflow. + rpc CreateExecution(CreateExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" + body: "execution" + }; + option (google.api.method_signature) = "parent,execution"; + } + + // Returns an execution of the given name. + rpc GetExecution(GetExecutionRequest) returns (Execution) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Cancels an execution of the given name. + rpc CancelExecution(CancelExecutionRequest) returns (Execution) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// A running instance of a [Workflow][google.cloud.workflows.v1beta.Workflow]. +message Execution { + option (google.api.resource) = { + type: "workflowexecutions.googleapis.com/Execution" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" + }; + + // Error describes why the execution was abnormally terminated. + message Error { + // Error payload returned by the execution, represented as a JSON string. + string payload = 1; + + // Human readable error context, helpful for debugging purposes. + string context = 2; + } + + // Describes the current state of the execution. More states may be added + // in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The execution is in progress. + ACTIVE = 1; + + // The execution finished successfully. + SUCCEEDED = 2; + + // The execution failed with an error. + FAILED = 3; + + // The execution was stopped intentionally. + CANCELLED = 4; + } + + // Output only. The resource name of the execution. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the beginning of execution. + google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Marks the end of execution, successful or not. + google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Current state of the execution. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Input parameters of the execution represented as a JSON string. + // The size limit is 32KB. + string argument = 5; + + // Output only. Output of the execution represented as a JSON string. The + // value can only be present if the execution's state is `SUCCEEDED`. + string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The error which caused the execution to finish prematurely. + // The value is only present if the execution's state is `FAILED` + // or `CANCELLED`. + Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Revision of the workflow this execution is using. + string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for the +// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] +// method. +message ListExecutionsRequest { + // Required. Name of the workflow for which the executions should be listed. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Maximum number of executions to return per call. + // Max supported value depends on the selected Execution view: it's 10000 for + // BASIC and 100 for FULL. The default value used if the field is not + // specified is 100, regardless of the selected view. Values greater than + // the max value will be coerced down to it. + int32 page_size = 2; + + // A page token, received from a previous `ListExecutions` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListExecutions` must + // match the call that provided the page token. + string page_token = 3; + + // Optional. A view defining which fields should be filled in the returned executions. + // The API will default to the BASIC view. + ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for the +// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] +// method. +message ListExecutionsResponse { + // The executions which match the request. + repeated Execution executions = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Request for the +// [CreateExecution][google.cloud.workflows.executions.v1beta.Executions.CreateExecution] +// method. +message CreateExecutionRequest { + // Required. Name of the workflow for which an execution should be created. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + // The latest revision of the workflow will be used. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; + + // Required. Execution to be created. + Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [GetExecution][google.cloud.workflows.executions.v1beta.Executions.GetExecution] +// method. +message GetExecutionRequest { + // Required. Name of the execution to be retrieved. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; + + // Optional. A view defining which fields should be filled in the returned execution. + // The API will default to the FULL view. + ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for the +// [CancelExecution][google.cloud.workflows.executions.v1beta.Executions.CancelExecution] +// method. +message CancelExecutionRequest { + // Required. Name of the execution to be cancelled. + // Format: + // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflowexecutions.googleapis.com/Execution" + } + ]; +} + +// Defines possible views for execution resource. +enum ExecutionView { + // The default / unset value. + EXECUTION_VIEW_UNSPECIFIED = 0; + + // Includes only basic metadata about the execution. + // Following fields are returned: name, start_time, end_time, state + // and workflow_revision_id. + BASIC = 1; + + // Includes all data. + FULL = 2; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto b/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto new file mode 100644 index 0000000..5308fa7 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto @@ -0,0 +1,314 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.workflows.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/v1beta;workflows"; +option java_multiple_files = true; +option java_outer_classname = "WorkflowsProto"; +option java_package = "com.google.cloud.workflows.v1beta"; + +// Workflows is used to deploy and execute workflow programs. +// Workflows makes sure the program executes reliably, despite hardware and +// networking interruptions. +service Workflows { + option (google.api.default_host) = "workflows.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists Workflows in a given project and location. + // The default order is not specified. + rpc ListWorkflows(ListWorkflowsRequest) returns (ListWorkflowsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*}/workflows" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets details of a single Workflow. + rpc GetWorkflow(GetWorkflowRequest) returns (Workflow) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/locations/*/workflows/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new workflow. If a workflow with the specified name already + // exists in the specified project and location, the long running operation + // will return [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. + rpc CreateWorkflow(CreateWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*}/workflows" + body: "workflow" + }; + option (google.api.method_signature) = "parent,workflow,workflow_id"; + option (google.longrunning.operation_info) = { + response_type: "Workflow" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a workflow with the specified name. + // This method also cancels and deletes all running executions of the + // workflow. + rpc DeleteWorkflow(DeleteWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/locations/*/workflows/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "OperationMetadata" + }; + } + + // Updates an existing workflow. + // Running this method has no impact on already running executions of the + // workflow. A new revision of the workflow may be created as a result of a + // successful update operation. In that case, such revision will be used + // in new workflow executions. + rpc UpdateWorkflow(UpdateWorkflowRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta/{workflow.name=projects/*/locations/*/workflows/*}" + body: "workflow" + }; + option (google.api.method_signature) = "workflow,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Workflow" + metadata_type: "OperationMetadata" + }; + } +} + +// Workflow program to be executed by Workflows. +message Workflow { + option (google.api.resource) = { + type: "workflows.googleapis.com/Workflow" + pattern: "projects/{project}/locations/{location}/workflows/{workflow}" + }; + + // Describes the current state of workflow deployment. More states may be + // added in the future. + enum State { + // Invalid state. + STATE_UNSPECIFIED = 0; + + // The workflow has been deployed successfully and is serving. + ACTIVE = 1; + } + + // The resource name of the workflow. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1; + + // Description of the workflow provided by the user. + // Must be at most 1000 unicode characters long. + string description = 2; + + // Output only. State of the workflow deployment. + State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The revision of the workflow. + // A new revision of a workflow is created as a result of updating the + // following fields of a workflow: + // - `source_code` + // - `service_account` + // The format is "000001-a4d", where the first 6 characters define + // the zero-padded revision ordinal number. They are followed by a hyphen and + // 3 hexadecimal random characters. + string revision_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp of when the workflow was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last update timestamp of the workflow. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp that the latest revision of the workflow + // was created. + google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Labels associated with this workflow. + // Labels can contain at most 64 entries. Keys and values can be no longer + // than 63 characters and can only contain lowercase letters, numeric + // characters, underscores and dashes. Label keys must start with a letter. + // International characters are allowed. + map labels = 8; + + // Name of the service account associated with the latest workflow version. + // This service account represents the identity of the workflow and determines + // what permissions the workflow has. + // Format: projects/{project}/serviceAccounts/{account} + // + // Using `-` as a wildcard for the `{project}` will infer the project from + // the account. The `{account}` value can be the `email` address or the + // `unique_id` of the service account. + // + // If not provided, workflow will use the project's default service account. + // Modifying this field for an existing workflow results in a new workflow + // revision. + string service_account = 9; + + // Required. Location of the workflow source code. + // Modifying this field for an existing workflow results in a new workflow + // revision. + oneof source_code { + // Workflow code to be executed. The size limit is 32KB. + string source_contents = 10; + } +} + +// Request for the +// [ListWorkflows][google.cloud.workflows.v1beta.Workflows.ListWorkflows] +// method. +message ListWorkflowsRequest { + // Required. Project and location from which the workflows should be listed. + // Format: projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of workflows to return per call. The service may return + // fewer than this value. If the value is not specified, a default value of + // 500 will be used. The maximum permitted value is 1000 and values greater + // than 1000 will be coerced down to 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListWorkflows` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListWorkflows` must + // match the call that provided the page token. + string page_token = 3; + + // Filter to restrict results to specific workflows. + string filter = 4; + + // Comma-separated list of fields that that specify the order of the results. + // Default sorting order for a field is ascending. To specify descending order + // for a field, append a " desc" suffix. + // If not specified, the results will be returned in an unspecified order. + string order_by = 5; +} + +// Response for the +// [ListWorkflows][google.cloud.workflows.v1beta.Workflows.ListWorkflows] +// method. +message ListWorkflowsResponse { + // The workflows which match the request. + repeated Workflow workflows = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; + + // Unreachable resources. + repeated string unreachable = 3; +} + +// Request for the +// [GetWorkflow][google.cloud.workflows.v1beta.Workflows.GetWorkflow] method. +message GetWorkflowRequest { + // Required. Name of the workflow which information should be retrieved. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; +} + +// Request for the +// [CreateWorkflow][google.cloud.workflows.v1beta.Workflows.CreateWorkflow] +// method. +message CreateWorkflowRequest { + // Required. Project and location in which the workflow should be created. + // Format: projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. Workflow to be created. + Workflow workflow = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID of the workflow to be created. It has to fulfill the + // following requirements: + // + // * Must contain only letters, numbers, underscores and hyphens. + // * Must start with a letter. + // * Must be between 1-64 characters. + // * Must end with a number or a letter. + // * Must be unique within the customer project and location. + string workflow_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the +// [DeleteWorkflow][google.cloud.workflows.v1beta.Workflows.DeleteWorkflow] +// method. +message DeleteWorkflowRequest { + // Required. Name of the workflow to be deleted. + // Format: projects/{project}/locations/{location}/workflows/{workflow} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "workflows.googleapis.com/Workflow" + } + ]; +} + +// Request for the +// [UpdateWorkflow][google.cloud.workflows.v1beta.Workflows.UpdateWorkflow] +// method. +message UpdateWorkflowRequest { + // Required. Workflow to be updated. + Workflow workflow = 1 [(google.api.field_behavior) = REQUIRED]; + + // List of fields to be updated. If not present, the entire workflow + // will be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Server-defined resource path for the target of the operation. + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // API version used to start the operation. + string api_version = 5; +} diff --git a/owl-bot-staging/v1beta/src/index.ts b/owl-bot-staging/v1beta/src/index.ts new file mode 100644 index 0000000..0c46b3b --- /dev/null +++ b/owl-bot-staging/v1beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta from './v1beta'; +const WorkflowsClient = v1beta.WorkflowsClient; +type WorkflowsClient = v1beta.WorkflowsClient; +export {v1beta, WorkflowsClient}; +export default {v1beta, WorkflowsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_client.ts b/owl-bot-staging/v1beta/src/v1beta/executions_client.ts new file mode 100644 index 0000000..e9afb3e --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/executions_client.ts @@ -0,0 +1,859 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/executions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './executions_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Executions is used to start and manage running instances of + * {@link google.cloud.workflows.v1beta.Workflow|Workflows} called executions. + * @class + * @memberof v1beta + */ +export class ExecutionsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + executionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExecutionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExecutionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + executionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listExecutions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.executions.v1beta.Executions', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.executionsStub) { + return this.executionsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.executions.v1beta.Executions. + this.executionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1beta.Executions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.executions.v1beta.Executions, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const executionsStubMethods = + ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; + for (const methodName of executionsStubMethods) { + const callPromise = this.executionsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.executionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflowexecutions.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined + ]>; + createExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; + createExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new execution using the latest revision of the given workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which an execution should be created. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * The latest revision of the workflow will be used. + * @param {google.cloud.workflows.executions.v1beta.Execution} request.execution + * Required. Execution to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createExecution(request); + */ + createExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createExecution(request, options, callback); + } + getExecution( + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined + ]>; + getExecution( + request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; + getExecution( + request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be retrieved. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned execution. + * The API will default to the FULL view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getExecution(request); + */ + getExecution( + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getExecution(request, options, callback); + } + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined + ]>; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; + cancelExecution( + request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + callback: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): void; +/** + * Cancels an execution of the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the execution to be cancelled. + * Format: + * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.cancelExecution(request); + */ + cancelExecution( + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution, + protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.cancelExecution(request, options, callback); + } + + listExecutions( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution[], + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse + ]>; + listExecutions( + request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): void; + listExecutions( + request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): void; +/** + * Returns a list of executions which belong to the workflow with + * the given name. The method returns executions of all workflow + * revisions. Returned executions are ordered by their start time (newest + * first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutions( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>, + callback?: PaginationCallback< + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, + protos.google.cloud.workflows.executions.v1beta.IExecution>): + Promise<[ + protos.google.cloud.workflows.executions.v1beta.IExecution[], + protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, + protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listExecutions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExecutionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExecutionsStream( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.createStream( + this.innerApiCalls.listExecutions as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listExecutions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the workflow for which the executions should be listed. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {number} request.pageSize + * Maximum number of executions to return per call. + * Max supported value depends on the selected Execution view: it's 10000 for + * BASIC and 100 for FULL. The default value used if the field is not + * specified is 100, regardless of the selected view. Values greater than + * the max value will be coerced down to it. + * @param {string} request.pageToken + * A page token, received from a previous `ListExecutions` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListExecutions` must + * match the call that provided the page token. + * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] + * Optional. A view defining which fields should be filled in the returned executions. + * The API will default to the BASIC view. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listExecutionsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listExecutionsAsync( + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExecutions.asyncIterate( + this.innerApiCalls['listExecutions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified execution resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @param {string} execution + * @returns {string} Resource name string. + */ + executionPath(project:string,location:string,workflow:string,execution:string) { + return this.pathTemplates.executionPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + execution: execution, + }); + } + + /** + * Parse the project from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).project; + } + + /** + * Parse the location from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).location; + } + + /** + * Parse the workflow from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).workflow; + } + + /** + * Parse the execution from Execution resource. + * + * @param {string} executionName + * A fully-qualified path representing Execution resource. + * @returns {string} A string representing the execution. + */ + matchExecutionFromExecutionName(executionName: string) { + return this.pathTemplates.executionPathTemplate.match(executionName).execution; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.executionsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json b/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json new file mode 100644 index 0000000..bf2692e --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.workflows.executions.v1beta.Executions": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListExecutions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CancelExecution": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json b/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json new file mode 100644 index 0000000..2450667 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/executions/v1beta/executions.proto" +] diff --git a/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 0000000..72f32db --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,77 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.workflows.v1beta", + "libraryPackage": "@google-cloud/workflows", + "services": { + "Workflows": { + "clients": { + "grpc": { + "libraryClient": "WorkflowsClient", + "rpcs": { + "GetWorkflow": { + "methods": [ + "getWorkflow" + ] + }, + "CreateWorkflow": { + "methods": [ + "createWorkflow" + ] + }, + "DeleteWorkflow": { + "methods": [ + "deleteWorkflow" + ] + }, + "UpdateWorkflow": { + "methods": [ + "updateWorkflow" + ] + }, + "ListWorkflows": { + "methods": [ + "listWorkflows", + "listWorkflowsStream", + "listWorkflowsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WorkflowsClient", + "rpcs": { + "GetWorkflow": { + "methods": [ + "getWorkflow" + ] + }, + "CreateWorkflow": { + "methods": [ + "createWorkflow" + ] + }, + "DeleteWorkflow": { + "methods": [ + "deleteWorkflow" + ] + }, + "UpdateWorkflow": { + "methods": [ + "updateWorkflow" + ] + }, + "ListWorkflows": { + "methods": [ + "listWorkflows", + "listWorkflowsStream", + "listWorkflowsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/index.ts b/owl-bot-staging/v1beta/src/v1beta/index.ts new file mode 100644 index 0000000..79adf07 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {WorkflowsClient} from './workflows_client'; diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts b/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts new file mode 100644 index 0000000..9374488 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts @@ -0,0 +1,1038 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/workflows_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './workflows_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Workflows is used to deploy and execute workflow programs. + * Workflows makes sure the program executes reliably, despite hardware and + * networking interruptions. + * @class + * @memberof v1beta + */ +export class WorkflowsClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + workflowsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WorkflowsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WorkflowsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + workflowPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/workflows/{workflow}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listWorkflows: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'workflows') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const createWorkflowResponse = protoFilesRoot.lookup( + '.google.cloud.workflows.v1beta.Workflow') as gax.protobuf.Type; + const createWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; + const deleteWorkflowResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; + const updateWorkflowResponse = protoFilesRoot.lookup( + '.google.cloud.workflows.v1beta.Workflow') as gax.protobuf.Type; + const updateWorkflowMetadata = protoFilesRoot.lookup( + '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createWorkflowResponse.decode.bind(createWorkflowResponse), + createWorkflowMetadata.decode.bind(createWorkflowMetadata)), + deleteWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteWorkflowResponse.decode.bind(deleteWorkflowResponse), + deleteWorkflowMetadata.decode.bind(deleteWorkflowMetadata)), + updateWorkflow: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateWorkflowResponse.decode.bind(updateWorkflowResponse), + updateWorkflowMetadata.decode.bind(updateWorkflowMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.workflows.v1beta.Workflows', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.workflowsStub) { + return this.workflowsStub; + } + + // Put together the "service stub" for + // google.cloud.workflows.v1beta.Workflows. + this.workflowsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.workflows.v1beta.Workflows') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.workflows.v1beta.Workflows, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const workflowsStubMethods = + ['listWorkflows', 'getWorkflow', 'createWorkflow', 'deleteWorkflow', 'updateWorkflow']; + for (const methodName of workflowsStubMethods) { + const callPromise = this.workflowsStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.workflowsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'workflows.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'workflows.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getWorkflow( + request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|undefined, {}|undefined + ]>; + getWorkflow( + request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): void; + getWorkflow( + request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + callback: Callback< + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets details of a single Workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the workflow which information should be retrieved. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getWorkflow(request); + */ + getWorkflow( + request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.workflows.v1beta.IWorkflow, + protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getWorkflow(request, options, callback); + } + + createWorkflow( + request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createWorkflow( + request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createWorkflow( + request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new workflow. If a workflow with the specified name already + * exists in the specified project and location, the long running operation + * will return {@link google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS} error. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location in which the workflow should be created. + * Format: projects/{project}/locations/{location} + * @param {google.cloud.workflows.v1beta.Workflow} request.workflow + * Required. Workflow to be created. + * @param {string} request.workflowId + * Required. The ID of the workflow to be created. It has to fulfill the + * following requirements: + * + * * Must contain only letters, numbers, underscores and hyphens. + * * Must start with a letter. + * * Must be between 1-64 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project and location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.createWorkflow(request); + * const [response] = await operation.promise(); + */ + createWorkflow( + request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkCreateWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkCreateWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + deleteWorkflow( + request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteWorkflow( + request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteWorkflow( + request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Deletes a workflow with the specified name. + * This method also cancels and deletes all running executions of the + * workflow. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the workflow to be deleted. + * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.deleteWorkflow(request); + * const [response] = await operation.promise(); + */ + deleteWorkflow( + request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkDeleteWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkDeleteWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + updateWorkflow( + request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateWorkflow( + request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateWorkflow( + request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Updates an existing workflow. + * Running this method has no impact on already running executions of the + * workflow. A new revision of the workflow may be created as a result of a + * successful update operation. In that case, such revision will be used + * in new workflow executions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.workflows.v1beta.Workflow} request.workflow + * Required. Workflow to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * List of fields to be updated. If not present, the entire workflow + * will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.updateWorkflow(request); + * const [response] = await operation.promise(); + */ + updateWorkflow( + request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'workflow.name': request.workflow!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateWorkflow(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateWorkflow()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkUpdateWorkflowProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkUpdateWorkflowProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateWorkflow, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + listWorkflows( + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.workflows.v1beta.IWorkflow[], + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest|null, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse + ]>; + listWorkflows( + request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1beta.IWorkflow>): void; + listWorkflows( + request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + callback: PaginationCallback< + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1beta.IWorkflow>): void; +/** + * Lists Workflows in a given project and location. + * The default order is not specified. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listWorkflowsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listWorkflows( + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1beta.IWorkflow>, + callback?: PaginationCallback< + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, + protos.google.cloud.workflows.v1beta.IWorkflow>): + Promise<[ + protos.google.cloud.workflows.v1beta.IWorkflow[], + protos.google.cloud.workflows.v1beta.IListWorkflowsRequest|null, + protos.google.cloud.workflows.v1beta.IListWorkflowsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listWorkflows(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Workflow]{@link google.cloud.workflows.v1beta.Workflow} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listWorkflowsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listWorkflowsStream( + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listWorkflows.createStream( + this.innerApiCalls.listWorkflows as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listWorkflows`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Project and location from which the workflows should be listed. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * Maximum number of workflows to return per call. The service may return + * fewer than this value. If the value is not specified, a default value of + * 500 will be used. The maximum permitted value is 1000 and values greater + * than 1000 will be coerced down to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListWorkflows` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListWorkflows` must + * match the call that provided the page token. + * @param {string} request.filter + * Filter to restrict results to specific workflows. + * @param {string} request.orderBy + * Comma-separated list of fields that that specify the order of the results. + * Default sorting order for a field is ascending. To specify descending order + * for a field, append a " desc" suffix. + * If not specified, the results will be returned in an unspecified order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listWorkflowsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listWorkflowsAsync( + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listWorkflows.asyncIterate( + this.innerApiCalls['listWorkflows'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified workflow resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} workflow + * @returns {string} Resource name string. + */ + workflowPath(project:string,location:string,workflow:string) { + return this.pathTemplates.workflowPathTemplate.render({ + project: project, + location: location, + workflow: workflow, + }); + } + + /** + * Parse the project from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the project. + */ + matchProjectFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).project; + } + + /** + * Parse the location from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the location. + */ + matchLocationFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).location; + } + + /** + * Parse the workflow from Workflow resource. + * + * @param {string} workflowName + * A fully-qualified path representing Workflow resource. + * @returns {string} A string representing the workflow. + */ + matchWorkflowFromWorkflowName(workflowName: string) { + return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.workflowsStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json b/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json new file mode 100644 index 0000000..bccc9e1 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.workflows.v1beta.Workflows": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListWorkflows": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateWorkflow": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json b/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json new file mode 100644 index 0000000..c9d0fa6 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/workflows/v1beta/workflows.proto" +] diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..f57e805 --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const workflows = require('@google-cloud/workflows'); + +function main() { + const workflowsClient = new workflows.WorkflowsClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..3aa8565 --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {WorkflowsClient} from '@google-cloud/workflows'; + +// check that the client class type name can be used +function doStuffWithWorkflowsClient(client: WorkflowsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const workflowsClient = new WorkflowsClient(); + doStuffWithWorkflowsClient(workflowsClient); +} + +main(); diff --git a/owl-bot-staging/v1beta/system-test/install.ts b/owl-bot-staging/v1beta/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts b/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts new file mode 100644 index 0000000..725c793 --- /dev/null +++ b/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts @@ -0,0 +1,744 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as executionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.ExecutionsClient', () => { + it('has servicePath', () => { + const servicePath = executionsModule.v1beta.ExecutionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = executionsModule.v1beta.ExecutionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = executionsModule.v1beta.ExecutionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new executionsModule.v1beta.ExecutionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.executionsStub, undefined); + await client.initialize(); + assert(client.executionsStub); + }); + + it('has close method', () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createExecution', () => { + it('invokes createExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); + const [response] = await client.createExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createExecution(request), expectedError); + assert((client.innerApiCalls.createExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getExecution', () => { + it('invokes getExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); + const [response] = await client.getExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getExecution(request), expectedError); + assert((client.innerApiCalls.getExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('cancelExecution', () => { + it('invokes cancelExecution without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); + const [response] = await client.cancelExecution(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes cancelExecution without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); + client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelExecution( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes cancelExecution with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelExecution(request), expectedError); + assert((client.innerApiCalls.cancelExecution as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listExecutions', () => { + it('invokes listExecutions without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); + const [response] = await client.listExecutions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutions without error using callback', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listExecutions( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listExecutions with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listExecutions(request), expectedError); + assert((client.innerApiCalls.listExecutions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listExecutionsStream without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listExecutionsStream with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listExecutionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; + stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); + assert.strictEqual( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions without error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), + ]; + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; + const iterable = client.listExecutionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExecutions with error', async () => { + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExecutionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('execution', () => { + const fakePath = "/rendered/path/execution"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + execution: "executionValue", + }; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.executionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.executionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('executionPath', () => { + const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.executionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExecutionName', () => { + const result = client.matchProjectFromExecutionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExecutionName', () => { + const result = client.matchLocationFromExecutionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromExecutionName', () => { + const result = client.matchWorkflowFromExecutionName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExecutionFromExecutionName', () => { + const result = client.matchExecutionFromExecutionName(fakePath); + assert.strictEqual(result, "executionValue"); + assert((client.pathTemplates.executionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new executionsModule.v1beta.ExecutionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts b/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts new file mode 100644 index 0000000..1550e76 --- /dev/null +++ b/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts @@ -0,0 +1,1012 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as workflowsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.WorkflowsClient', () => { + it('has servicePath', () => { + const servicePath = workflowsModule.v1beta.WorkflowsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = workflowsModule.v1beta.WorkflowsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = workflowsModule.v1beta.WorkflowsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new workflowsModule.v1beta.WorkflowsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowsStub, undefined); + await client.initialize(); + assert(client.workflowsStub); + }); + + it('has close method', () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getWorkflow', () => { + it('invokes getWorkflow without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()); + client.innerApiCalls.getWorkflow = stubSimpleCall(expectedResponse); + const [response] = await client.getWorkflow(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getWorkflow without error using callback', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()); + client.innerApiCalls.getWorkflow = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getWorkflow( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.v1beta.IWorkflow|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getWorkflow with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getWorkflow = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getWorkflow(request), expectedError); + assert((client.innerApiCalls.getWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createWorkflow', () => { + it('invokes createWorkflow without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.createWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createWorkflow without error using callback', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createWorkflow with call error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createWorkflow(request), expectedError); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createWorkflow with LRO error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateWorkflowProgress without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateWorkflowProgress with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteWorkflow', () => { + it('invokes deleteWorkflow without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteWorkflow without error using callback', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteWorkflow with call error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteWorkflow(request), expectedError); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteWorkflow with LRO error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteWorkflowProgress without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteWorkflowProgress with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateWorkflow', () => { + it('invokes updateWorkflow without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateWorkflow(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateWorkflow without error using callback', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateWorkflow = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateWorkflow( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateWorkflow with call error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateWorkflow(request), expectedError); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateWorkflow with LRO error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); + request.workflow = {}; + request.workflow.name = ''; + const expectedHeaderRequestParams = "workflow.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateWorkflow(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateWorkflow as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateWorkflowProgress without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateWorkflowProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateWorkflowProgress with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateWorkflowProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listWorkflows', () => { + it('invokes listWorkflows without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + ]; + client.innerApiCalls.listWorkflows = stubSimpleCall(expectedResponse); + const [response] = await client.listWorkflows(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listWorkflows without error using callback', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + ]; + client.innerApiCalls.listWorkflows = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listWorkflows( + request, + (err?: Error|null, result?: protos.google.cloud.workflows.v1beta.IWorkflow[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listWorkflows with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listWorkflows = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listWorkflows(request), expectedError); + assert((client.innerApiCalls.listWorkflows as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listWorkflowsStream without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + ]; + client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listWorkflowsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.v1beta.Workflow[] = []; + stream.on('data', (response: protos.google.cloud.workflows.v1beta.Workflow) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); + assert.strictEqual( + (client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listWorkflowsStream with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listWorkflowsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.workflows.v1beta.Workflow[] = []; + stream.on('data', (response: protos.google.cloud.workflows.v1beta.Workflow) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); + assert.strictEqual( + (client.descriptors.page.listWorkflows.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listWorkflows without error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), + ]; + client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.workflows.v1beta.IWorkflow[] = []; + const iterable = client.listWorkflowsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listWorkflows with error', async () => { + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listWorkflowsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.workflows.v1beta.IWorkflow[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('workflow', () => { + const fakePath = "/rendered/path/workflow"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + workflow: "workflowValue", + }; + const client = new workflowsModule.v1beta.WorkflowsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.workflowPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.workflowPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('workflowPath', () => { + const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromWorkflowName', () => { + const result = client.matchProjectFromWorkflowName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromWorkflowName', () => { + const result = client.matchLocationFromWorkflowName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchWorkflowFromWorkflowName', () => { + const result = client.matchWorkflowFromWorkflowName(fakePath); + assert.strictEqual(result, "workflowValue"); + assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); From a08d0f7d131d5cae5d4d8088607ca8c3801794c7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 22 Jun 2021 00:42:20 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md --- .../workflows/executions/v1/executions.proto | 253 ---- owl-bot-staging/executions/v1/src/index.ts | 25 - .../executions/v1/src/v1/executions_client.ts | 859 -------------- .../v1/src/v1/executions_client_config.json | 42 - .../v1/src/v1/executions_proto_list.json | 3 - .../executions/v1/src/v1/gapic_metadata.json | 67 -- owl-bot-staging/executions/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../executions/v1/system-test/install.ts | 49 - .../executions/v1/test/gapic_executions_v1.ts | 744 ------------ .../executions/v1beta/executions.proto | 252 ---- .../executions/v1beta/src/index.ts | 25 - .../v1beta/src/v1beta/executions_client.ts | 859 -------------- .../src/v1beta/executions_client_config.json | 42 - .../src/v1beta/executions_proto_list.json | 3 - .../v1beta/src/v1beta/gapic_metadata.json | 67 -- .../executions/v1beta/src/v1beta/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../executions/v1beta/system-test/install.ts | 49 - .../v1beta/test/gapic_executions_v1beta.ts | 744 ------------ .../workflows/executions/v1/executions.proto | 253 ---- .../google/cloud/workflows/v1/workflows.proto | 314 ----- owl-bot-staging/v1/src/index.ts | 25 - .../v1/src/v1/executions_client.ts | 859 -------------- .../v1/src/v1/executions_client_config.json | 42 - .../v1/src/v1/executions_proto_list.json | 3 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 77 -- owl-bot-staging/v1/src/v1/index.ts | 19 - owl-bot-staging/v1/src/v1/workflows_client.ts | 1038 ----------------- .../v1/src/v1/workflows_client_config.json | 46 - .../v1/src/v1/workflows_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_executions_v1.ts | 744 ------------ owl-bot-staging/v1/test/gapic_workflows_v1.ts | 1012 ---------------- .../executions/v1beta/executions.proto | 252 ---- .../cloud/workflows/v1beta/workflows.proto | 314 ----- owl-bot-staging/v1beta/src/index.ts | 25 - .../v1beta/src/v1beta/executions_client.ts | 859 -------------- .../src/v1beta/executions_client_config.json | 42 - .../src/v1beta/executions_proto_list.json | 3 - .../v1beta/src/v1beta/gapic_metadata.json | 77 -- owl-bot-staging/v1beta/src/v1beta/index.ts | 19 - .../v1beta/src/v1beta/workflows_client.ts | 1038 ----------------- .../src/v1beta/workflows_client_config.json | 46 - .../src/v1beta/workflows_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1beta/system-test/install.ts | 49 - .../v1beta/test/gapic_executions_v1beta.ts | 744 ------------ .../v1beta/test/gapic_workflows_v1beta.ts | 1012 ---------------- src/v1/executions_client.ts | 16 +- src/v1/workflows_client.ts | 20 +- src/v1beta/executions_client.ts | 16 +- src/v1beta/workflows_client.ts | 20 +- 58 files changed, 36 insertions(+), 13360 deletions(-) delete mode 100644 owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto delete mode 100644 owl-bot-staging/executions/v1/src/index.ts delete mode 100644 owl-bot-staging/executions/v1/src/v1/executions_client.ts delete mode 100644 owl-bot-staging/executions/v1/src/v1/executions_client_config.json delete mode 100644 owl-bot-staging/executions/v1/src/v1/executions_proto_list.json delete mode 100644 owl-bot-staging/executions/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/executions/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/executions/v1/system-test/install.ts delete mode 100644 owl-bot-staging/executions/v1/test/gapic_executions_v1.ts delete mode 100644 owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto delete mode 100644 owl-bot-staging/executions/v1beta/src/index.ts delete mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts delete mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json delete mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json delete mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json delete mode 100644 owl-bot-staging/executions/v1beta/src/v1beta/index.ts delete mode 100644 owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/executions/v1beta/system-test/install.ts delete mode 100644 owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts delete mode 100644 owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/executions_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/executions_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/executions_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/workflows_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/workflows_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/workflows_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_executions_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_workflows_v1.ts delete mode 100644 owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto delete mode 100644 owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto delete mode 100644 owl-bot-staging/v1beta/src/index.ts delete mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_client.ts delete mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_client_config.json delete mode 100644 owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json delete mode 100644 owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta/src/v1beta/index.ts delete mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_client.ts delete mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json delete mode 100644 owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json delete mode 100644 owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts delete mode 100644 owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts diff --git a/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto b/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto deleted file mode 100644 index 583a5d9..0000000 --- a/owl-bot-staging/executions/v1/protos/google/cloud/workflows/executions/v1/executions.proto +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.executions.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1;executions"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionsProto"; -option java_package = "com.google.cloud.workflows.executions.v1"; -option (google.api.resource_definition) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" -}; - -// Executions is used to start and manage running instances of -// [Workflows][google.cloud.workflows.v1.Workflow] called executions. -service Executions { - option (google.api.default_host) = "workflowexecutions.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Returns a list of executions which belong to the workflow with - // the given name. The method returns executions of all workflow - // revisions. Returned executions are ordered by their start time (newest - // first). - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a new execution using the latest revision of the given workflow. - rpc CreateExecution(CreateExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" - body: "execution" - }; - option (google.api.method_signature) = "parent,execution"; - } - - // Returns an execution of the given name. - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Cancels an execution of the given name. - rpc CancelExecution(CancelExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// A running instance of a -// [Workflow](/workflows/docs/reference/rest/v1/projects.locations.workflows). -message Execution { - option (google.api.resource) = { - type: "workflowexecutions.googleapis.com/Execution" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" - }; - - // Error describes why the execution was abnormally terminated. - message Error { - // Error payload returned by the execution, represented as a JSON string. - string payload = 1; - - // Human readable error context, helpful for debugging purposes. - string context = 2; - } - - // Describes the current state of the execution. More states may be added - // in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The execution is in progress. - ACTIVE = 1; - - // The execution finished successfully. - SUCCEEDED = 2; - - // The execution failed with an error. - FAILED = 3; - - // The execution was stopped intentionally. - CANCELLED = 4; - } - - // Output only. The resource name of the execution. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the beginning of execution. - google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the end of execution, successful or not. - google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Current state of the execution. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input parameters of the execution represented as a JSON string. - // The size limit is 32KB. - string argument = 5; - - // Output only. Output of the execution represented as a JSON string. The - // value can only be present if the execution's state is `SUCCEEDED`. - string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The error which caused the execution to finish prematurely. - // The value is only present if the execution's state is `FAILED` - // or `CANCELLED`. - Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Revision of the workflow this execution is using. - string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for the -// [ListExecutions][] -// method. -message ListExecutionsRequest { - // Required. Name of the workflow for which the executions should be listed. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Maximum number of executions to return per call. - // Max supported value depends on the selected Execution view: it's 10000 for - // BASIC and 100 for FULL. The default value used if the field is not - // specified is 100, regardless of the selected view. Values greater than - // the max value will be coerced down to it. - int32 page_size = 2; - - // A page token, received from a previous `ListExecutions` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListExecutions` must - // match the call that provided the page token. - string page_token = 3; - - // Optional. A view defining which fields should be filled in the returned executions. - // The API will default to the BASIC view. - ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for the -// [ListExecutions][google.cloud.workflows.executions.v1.Executions.ListExecutions] -// method. -message ListExecutionsResponse { - // The executions which match the request. - repeated Execution executions = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Request for the -// [CreateExecution][google.cloud.workflows.executions.v1.Executions.CreateExecution] -// method. -message CreateExecutionRequest { - // Required. Name of the workflow for which an execution should be created. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - // The latest revision of the workflow will be used. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Required. Execution to be created. - Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [GetExecution][google.cloud.workflows.executions.v1.Executions.GetExecution] -// method. -message GetExecutionRequest { - // Required. Name of the execution to be retrieved. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; - - // Optional. A view defining which fields should be filled in the returned execution. - // The API will default to the FULL view. - ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for the -// [CancelExecution][google.cloud.workflows.executions.v1.Executions.CancelExecution] -// method. -message CancelExecutionRequest { - // Required. Name of the execution to be cancelled. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; -} - -// Defines possible views for execution resource. -enum ExecutionView { - // The default / unset value. - EXECUTION_VIEW_UNSPECIFIED = 0; - - // Includes only basic metadata about the execution. - // Following fields are returned: name, start_time, end_time, state - // and workflow_revision_id. - BASIC = 1; - - // Includes all data. - FULL = 2; -} diff --git a/owl-bot-staging/executions/v1/src/index.ts b/owl-bot-staging/executions/v1/src/index.ts deleted file mode 100644 index a593c0e..0000000 --- a/owl-bot-staging/executions/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const ExecutionsClient = v1.ExecutionsClient; -type ExecutionsClient = v1.ExecutionsClient; -export {v1, ExecutionsClient}; -export default {v1, ExecutionsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_client.ts b/owl-bot-staging/executions/v1/src/v1/executions_client.ts deleted file mode 100644 index 1133ca0..0000000 --- a/owl-bot-staging/executions/v1/src/v1/executions_client.ts +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/executions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './executions_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Executions is used to start and manage running instances of - * {@link google.cloud.workflows.v1.Workflow|Workflows} called executions. - * @class - * @memberof v1 - */ -export class ExecutionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - executionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ExecutionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ExecutionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.executions.v1.Executions', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.executionsStub) { - return this.executionsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.executions.v1.Executions. - this.executionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1.Executions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.executions.v1.Executions, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const executionsStubMethods = - ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; - for (const methodName of executionsStubMethods) { - const callPromise = this.executionsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.executionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createExecution( - request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined - ]>; - createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; - createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new execution using the latest revision of the given workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which an execution should be created. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * The latest revision of the workflow will be used. - * @param {google.cloud.workflows.executions.v1.Execution} request.execution - * Required. Execution to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createExecution(request); - */ - createExecution( - request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createExecution(request, options, callback); - } - getExecution( - request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be retrieved. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned execution. - * The API will default to the FULL view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getExecution(request); - */ - getExecution( - request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined - ]>; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Cancels an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be cancelled. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.cancelExecution(request); - */ - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.cancelExecution(request, options, callback); - } - - listExecutions( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution[], - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): void; - listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): void; -/** - * Returns a list of executions which belong to the workflow with - * the given name. The method returns executions of all workflow - * revisions. Returned executions are ordered by their start time (newest - * first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution[], - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Execution]{@link google.cloud.workflows.executions.v1.Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listExecutionsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listExecutionsAsync( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,workflow:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the workflow from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).workflow; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.executionsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_client_config.json b/owl-bot-staging/executions/v1/src/v1/executions_client_config.json deleted file mode 100644 index ea2d78f..0000000 --- a/owl-bot-staging/executions/v1/src/v1/executions_client_config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.executions.v1.Executions": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListExecutions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CancelExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json b/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json deleted file mode 100644 index 3cffd5d..0000000 --- a/owl-bot-staging/executions/v1/src/v1/executions_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/executions/v1/executions.proto" -] diff --git a/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json b/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json deleted file mode 100644 index aea6126..0000000 --- a/owl-bot-staging/executions/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.workflows.executions.v1", - "libraryPackage": "@google-cloud/workflow-executions", - "services": { - "Executions": { - "clients": { - "grpc": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CancelExecution": { - "methods": [ - "cancelExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CancelExecution": { - "methods": [ - "cancelExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/executions/v1/src/v1/index.ts b/owl-bot-staging/executions/v1/src/v1/index.ts deleted file mode 100644 index beee77e..0000000 --- a/owl-bot-staging/executions/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {ExecutionsClient} from './executions_client'; diff --git a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index b7ac36b..0000000 --- a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const executions = require('@google-cloud/workflow-executions'); - -function main() { - const executionsClient = new executions.ExecutionsClient(); -} - -main(); diff --git a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 125bbdb..0000000 --- a/owl-bot-staging/executions/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {ExecutionsClient} from '@google-cloud/workflow-executions'; - -// check that the client class type name can be used -function doStuffWithExecutionsClient(client: ExecutionsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const executionsClient = new ExecutionsClient(); - doStuffWithExecutionsClient(executionsClient); -} - -main(); diff --git a/owl-bot-staging/executions/v1/system-test/install.ts b/owl-bot-staging/executions/v1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/executions/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts b/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts deleted file mode 100644 index 2093e36..0000000 --- a/owl-bot-staging/executions/v1/test/gapic_executions_v1.ts +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as executionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ExecutionsClient', () => { - it('has servicePath', () => { - const servicePath = executionsModule.v1.ExecutionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = executionsModule.v1.ExecutionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = executionsModule.v1.ExecutionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new executionsModule.v1.ExecutionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new executionsModule.v1.ExecutionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - await client.initialize(); - assert(client.executionsStub); - }); - - it('has close method', () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); - const [response] = await client.createExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('cancelExecution', () => { - it('invokes cancelExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); - const [response] = await client.cancelExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes cancelExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes cancelExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelExecution(request), expectedError); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listExecutions with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - execution: "executionValue", - }; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromExecutionName', () => { - const result = client.matchWorkflowFromExecutionName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto b/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto deleted file mode 100644 index 5b03fdf..0000000 --- a/owl-bot-staging/executions/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.executions.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1beta;executions"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionsProto"; -option java_package = "com.google.cloud.workflows.executions.v1beta"; -option (google.api.resource_definition) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" -}; - -// Executions is used to start and manage running instances of -// [Workflows][google.cloud.workflows.v1beta.Workflow] called executions. -service Executions { - option (google.api.default_host) = "workflowexecutions.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Returns a list of executions which belong to the workflow with - // the given name. The method returns executions of all workflow - // revisions. Returned executions are ordered by their start time (newest - // first). - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a new execution using the latest revision of the given workflow. - rpc CreateExecution(CreateExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" - body: "execution" - }; - option (google.api.method_signature) = "parent,execution"; - } - - // Returns an execution of the given name. - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Cancels an execution of the given name. - rpc CancelExecution(CancelExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// A running instance of a [Workflow][google.cloud.workflows.v1beta.Workflow]. -message Execution { - option (google.api.resource) = { - type: "workflowexecutions.googleapis.com/Execution" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" - }; - - // Error describes why the execution was abnormally terminated. - message Error { - // Error payload returned by the execution, represented as a JSON string. - string payload = 1; - - // Human readable error context, helpful for debugging purposes. - string context = 2; - } - - // Describes the current state of the execution. More states may be added - // in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The execution is in progress. - ACTIVE = 1; - - // The execution finished successfully. - SUCCEEDED = 2; - - // The execution failed with an error. - FAILED = 3; - - // The execution was stopped intentionally. - CANCELLED = 4; - } - - // Output only. The resource name of the execution. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the beginning of execution. - google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the end of execution, successful or not. - google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Current state of the execution. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input parameters of the execution represented as a JSON string. - // The size limit is 32KB. - string argument = 5; - - // Output only. Output of the execution represented as a JSON string. The - // value can only be present if the execution's state is `SUCCEEDED`. - string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The error which caused the execution to finish prematurely. - // The value is only present if the execution's state is `FAILED` - // or `CANCELLED`. - Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Revision of the workflow this execution is using. - string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for the -// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] -// method. -message ListExecutionsRequest { - // Required. Name of the workflow for which the executions should be listed. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Maximum number of executions to return per call. - // Max supported value depends on the selected Execution view: it's 10000 for - // BASIC and 100 for FULL. The default value used if the field is not - // specified is 100, regardless of the selected view. Values greater than - // the max value will be coerced down to it. - int32 page_size = 2; - - // A page token, received from a previous `ListExecutions` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListExecutions` must - // match the call that provided the page token. - string page_token = 3; - - // Optional. A view defining which fields should be filled in the returned executions. - // The API will default to the BASIC view. - ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for the -// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] -// method. -message ListExecutionsResponse { - // The executions which match the request. - repeated Execution executions = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Request for the -// [CreateExecution][google.cloud.workflows.executions.v1beta.Executions.CreateExecution] -// method. -message CreateExecutionRequest { - // Required. Name of the workflow for which an execution should be created. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - // The latest revision of the workflow will be used. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Required. Execution to be created. - Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [GetExecution][google.cloud.workflows.executions.v1beta.Executions.GetExecution] -// method. -message GetExecutionRequest { - // Required. Name of the execution to be retrieved. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; - - // Optional. A view defining which fields should be filled in the returned execution. - // The API will default to the FULL view. - ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for the -// [CancelExecution][google.cloud.workflows.executions.v1beta.Executions.CancelExecution] -// method. -message CancelExecutionRequest { - // Required. Name of the execution to be cancelled. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; -} - -// Defines possible views for execution resource. -enum ExecutionView { - // The default / unset value. - EXECUTION_VIEW_UNSPECIFIED = 0; - - // Includes only basic metadata about the execution. - // Following fields are returned: name, start_time, end_time, state - // and workflow_revision_id. - BASIC = 1; - - // Includes all data. - FULL = 2; -} diff --git a/owl-bot-staging/executions/v1beta/src/index.ts b/owl-bot-staging/executions/v1beta/src/index.ts deleted file mode 100644 index f4dfeed..0000000 --- a/owl-bot-staging/executions/v1beta/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta from './v1beta'; -const ExecutionsClient = v1beta.ExecutionsClient; -type ExecutionsClient = v1beta.ExecutionsClient; -export {v1beta, ExecutionsClient}; -export default {v1beta, ExecutionsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts deleted file mode 100644 index e9afb3e..0000000 --- a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client.ts +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/executions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './executions_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Executions is used to start and manage running instances of - * {@link google.cloud.workflows.v1beta.Workflow|Workflows} called executions. - * @class - * @memberof v1beta - */ -export class ExecutionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - executionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ExecutionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ExecutionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.executions.v1beta.Executions', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.executionsStub) { - return this.executionsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.executions.v1beta.Executions. - this.executionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1beta.Executions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.executions.v1beta.Executions, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const executionsStubMethods = - ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; - for (const methodName of executionsStubMethods) { - const callPromise = this.executionsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.executionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined - ]>; - createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; - createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new execution using the latest revision of the given workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which an execution should be created. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * The latest revision of the workflow will be used. - * @param {google.cloud.workflows.executions.v1beta.Execution} request.execution - * Required. Execution to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createExecution(request); - */ - createExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createExecution(request, options, callback); - } - getExecution( - request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be retrieved. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned execution. - * The API will default to the FULL view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getExecution(request); - */ - getExecution( - request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined - ]>; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Cancels an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be cancelled. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.cancelExecution(request); - */ - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.cancelExecution(request, options, callback); - } - - listExecutions( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution[], - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): void; - listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): void; -/** - * Returns a list of executions which belong to the workflow with - * the given name. The method returns executions of all workflow - * revisions. Returned executions are ordered by their start time (newest - * first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution[], - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listExecutionsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listExecutionsAsync( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,workflow:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the workflow from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).workflow; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.executionsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json b/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json deleted file mode 100644 index bf2692e..0000000 --- a/owl-bot-staging/executions/v1beta/src/v1beta/executions_client_config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.executions.v1beta.Executions": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListExecutions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CancelExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json b/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json deleted file mode 100644 index 2450667..0000000 --- a/owl-bot-staging/executions/v1beta/src/v1beta/executions_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/executions/v1beta/executions.proto" -] diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json deleted file mode 100644 index 254e6e2..0000000 --- a/owl-bot-staging/executions/v1beta/src/v1beta/gapic_metadata.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.workflows.executions.v1beta", - "libraryPackage": "@google-cloud/workflows-executions", - "services": { - "Executions": { - "clients": { - "grpc": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CancelExecution": { - "methods": [ - "cancelExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ExecutionsClient", - "rpcs": { - "CreateExecution": { - "methods": [ - "createExecution" - ] - }, - "GetExecution": { - "methods": [ - "getExecution" - ] - }, - "CancelExecution": { - "methods": [ - "cancelExecution" - ] - }, - "ListExecutions": { - "methods": [ - "listExecutions", - "listExecutionsStream", - "listExecutionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/executions/v1beta/src/v1beta/index.ts b/owl-bot-staging/executions/v1beta/src/v1beta/index.ts deleted file mode 100644 index beee77e..0000000 --- a/owl-bot-staging/executions/v1beta/src/v1beta/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {ExecutionsClient} from './executions_client'; diff --git a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 12ccbfa..0000000 --- a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const executions = require('@google-cloud/workflows-executions'); - -function main() { - const executionsClient = new executions.ExecutionsClient(); -} - -main(); diff --git a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index e7cf00f..0000000 --- a/owl-bot-staging/executions/v1beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {ExecutionsClient} from '@google-cloud/workflows-executions'; - -// check that the client class type name can be used -function doStuffWithExecutionsClient(client: ExecutionsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const executionsClient = new ExecutionsClient(); - doStuffWithExecutionsClient(executionsClient); -} - -main(); diff --git a/owl-bot-staging/executions/v1beta/system-test/install.ts b/owl-bot-staging/executions/v1beta/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/executions/v1beta/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts b/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts deleted file mode 100644 index 725c793..0000000 --- a/owl-bot-staging/executions/v1beta/test/gapic_executions_v1beta.ts +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as executionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.ExecutionsClient', () => { - it('has servicePath', () => { - const servicePath = executionsModule.v1beta.ExecutionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = executionsModule.v1beta.ExecutionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = executionsModule.v1beta.ExecutionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new executionsModule.v1beta.ExecutionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - await client.initialize(); - assert(client.executionsStub); - }); - - it('has close method', () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); - const [response] = await client.createExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('cancelExecution', () => { - it('invokes cancelExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); - const [response] = await client.cancelExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes cancelExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes cancelExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelExecution(request), expectedError); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listExecutions with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - execution: "executionValue", - }; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromExecutionName', () => { - const result = client.matchWorkflowFromExecutionName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto b/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto deleted file mode 100644 index 583a5d9..0000000 --- a/owl-bot-staging/v1/protos/google/cloud/workflows/executions/v1/executions.proto +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.executions.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1;executions"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionsProto"; -option java_package = "com.google.cloud.workflows.executions.v1"; -option (google.api.resource_definition) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" -}; - -// Executions is used to start and manage running instances of -// [Workflows][google.cloud.workflows.v1.Workflow] called executions. -service Executions { - option (google.api.default_host) = "workflowexecutions.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Returns a list of executions which belong to the workflow with - // the given name. The method returns executions of all workflow - // revisions. Returned executions are ordered by their start time (newest - // first). - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a new execution using the latest revision of the given workflow. - rpc CreateExecution(CreateExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/workflows/*}/executions" - body: "execution" - }; - option (google.api.method_signature) = "parent,execution"; - } - - // Returns an execution of the given name. - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Cancels an execution of the given name. - rpc CancelExecution(CancelExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// A running instance of a -// [Workflow](/workflows/docs/reference/rest/v1/projects.locations.workflows). -message Execution { - option (google.api.resource) = { - type: "workflowexecutions.googleapis.com/Execution" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" - }; - - // Error describes why the execution was abnormally terminated. - message Error { - // Error payload returned by the execution, represented as a JSON string. - string payload = 1; - - // Human readable error context, helpful for debugging purposes. - string context = 2; - } - - // Describes the current state of the execution. More states may be added - // in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The execution is in progress. - ACTIVE = 1; - - // The execution finished successfully. - SUCCEEDED = 2; - - // The execution failed with an error. - FAILED = 3; - - // The execution was stopped intentionally. - CANCELLED = 4; - } - - // Output only. The resource name of the execution. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the beginning of execution. - google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the end of execution, successful or not. - google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Current state of the execution. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input parameters of the execution represented as a JSON string. - // The size limit is 32KB. - string argument = 5; - - // Output only. Output of the execution represented as a JSON string. The - // value can only be present if the execution's state is `SUCCEEDED`. - string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The error which caused the execution to finish prematurely. - // The value is only present if the execution's state is `FAILED` - // or `CANCELLED`. - Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Revision of the workflow this execution is using. - string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for the -// [ListExecutions][] -// method. -message ListExecutionsRequest { - // Required. Name of the workflow for which the executions should be listed. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Maximum number of executions to return per call. - // Max supported value depends on the selected Execution view: it's 10000 for - // BASIC and 100 for FULL. The default value used if the field is not - // specified is 100, regardless of the selected view. Values greater than - // the max value will be coerced down to it. - int32 page_size = 2; - - // A page token, received from a previous `ListExecutions` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListExecutions` must - // match the call that provided the page token. - string page_token = 3; - - // Optional. A view defining which fields should be filled in the returned executions. - // The API will default to the BASIC view. - ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for the -// [ListExecutions][google.cloud.workflows.executions.v1.Executions.ListExecutions] -// method. -message ListExecutionsResponse { - // The executions which match the request. - repeated Execution executions = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Request for the -// [CreateExecution][google.cloud.workflows.executions.v1.Executions.CreateExecution] -// method. -message CreateExecutionRequest { - // Required. Name of the workflow for which an execution should be created. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - // The latest revision of the workflow will be used. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Required. Execution to be created. - Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [GetExecution][google.cloud.workflows.executions.v1.Executions.GetExecution] -// method. -message GetExecutionRequest { - // Required. Name of the execution to be retrieved. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; - - // Optional. A view defining which fields should be filled in the returned execution. - // The API will default to the FULL view. - ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for the -// [CancelExecution][google.cloud.workflows.executions.v1.Executions.CancelExecution] -// method. -message CancelExecutionRequest { - // Required. Name of the execution to be cancelled. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; -} - -// Defines possible views for execution resource. -enum ExecutionView { - // The default / unset value. - EXECUTION_VIEW_UNSPECIFIED = 0; - - // Includes only basic metadata about the execution. - // Following fields are returned: name, start_time, end_time, state - // and workflow_revision_id. - BASIC = 1; - - // Includes all data. - FULL = 2; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto b/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto deleted file mode 100644 index 7e46c2f..0000000 --- a/owl-bot-staging/v1/protos/google/cloud/workflows/v1/workflows.proto +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/v1;workflows"; -option java_multiple_files = true; -option java_outer_classname = "WorkflowsProto"; -option java_package = "com.google.cloud.workflows.v1"; - -// Workflows is used to deploy and execute workflow programs. -// Workflows makes sure the program executes reliably, despite hardware and -// networking interruptions. -service Workflows { - option (google.api.default_host) = "workflows.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists Workflows in a given project and location. - // The default order is not specified. - rpc ListWorkflows(ListWorkflowsRequest) returns (ListWorkflowsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/workflows" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Workflow. - rpc GetWorkflow(GetWorkflowRequest) returns (Workflow) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/workflows/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new workflow. If a workflow with the specified name already - // exists in the specified project and location, the long running operation - // will return [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. - rpc CreateWorkflow(CreateWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/workflows" - body: "workflow" - }; - option (google.api.method_signature) = "parent,workflow,workflow_id"; - option (google.longrunning.operation_info) = { - response_type: "Workflow" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a workflow with the specified name. - // This method also cancels and deletes all running executions of the - // workflow. - rpc DeleteWorkflow(DeleteWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/workflows/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Updates an existing workflow. - // Running this method has no impact on already running executions of the - // workflow. A new revision of the workflow may be created as a result of a - // successful update operation. In that case, such revision will be used - // in new workflow executions. - rpc UpdateWorkflow(UpdateWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{workflow.name=projects/*/locations/*/workflows/*}" - body: "workflow" - }; - option (google.api.method_signature) = "workflow,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Workflow" - metadata_type: "OperationMetadata" - }; - } -} - -// Workflow program to be executed by Workflows. -message Workflow { - option (google.api.resource) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" - }; - - // Describes the current state of workflow deployment. More states may be - // added in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The workflow has been deployed successfully and is serving. - ACTIVE = 1; - } - - // The resource name of the workflow. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1; - - // Description of the workflow provided by the user. - // Must be at most 1000 unicode characters long. - string description = 2; - - // Output only. State of the workflow deployment. - State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The revision of the workflow. - // A new revision of a workflow is created as a result of updating the - // following fields of a workflow: - // - `source_code` - // - `service_account` - // The format is "000001-a4d", where the first 6 characters define - // the zero-padded revision ordinal number. They are followed by a hyphen and - // 3 hexadecimal random characters. - string revision_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp of when the workflow was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last update timestamp of the workflow. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp that the latest revision of the workflow - // was created. - google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Labels associated with this workflow. - // Labels can contain at most 64 entries. Keys and values can be no longer - // than 63 characters and can only contain lowercase letters, numeric - // characters, underscores and dashes. Label keys must start with a letter. - // International characters are allowed. - map labels = 8; - - // Name of the service account associated with the latest workflow version. - // This service account represents the identity of the workflow and determines - // what permissions the workflow has. - // Format: projects/{project}/serviceAccounts/{account} - // - // Using `-` as a wildcard for the `{project}` will infer the project from - // the account. The `{account}` value can be the `email` address or the - // `unique_id` of the service account. - // - // If not provided, workflow will use the project's default service account. - // Modifying this field for an existing workflow results in a new workflow - // revision. - string service_account = 9; - - // Required. Location of the workflow source code. - // Modifying this field for an existing workflow results in a new workflow - // revision. - oneof source_code { - // Workflow code to be executed. The size limit is 32KB. - string source_contents = 10; - } -} - -// Request for the -// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows] -// method. -message ListWorkflowsRequest { - // Required. Project and location from which the workflows should be listed. - // Format: projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of workflows to return per call. The service may return - // fewer than this value. If the value is not specified, a default value of - // 500 will be used. The maximum permitted value is 1000 and values greater - // than 1000 will be coerced down to 1000. - int32 page_size = 2; - - // A page token, received from a previous `ListWorkflows` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListWorkflows` must - // match the call that provided the page token. - string page_token = 3; - - // Filter to restrict results to specific workflows. - string filter = 4; - - // Comma-separated list of fields that that specify the order of the results. - // Default sorting order for a field is ascending. To specify descending order - // for a field, append a " desc" suffix. - // If not specified, the results will be returned in an unspecified order. - string order_by = 5; -} - -// Response for the -// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows] -// method. -message ListWorkflowsResponse { - // The workflows which match the request. - repeated Workflow workflows = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; - - // Unreachable resources. - repeated string unreachable = 3; -} - -// Request for the -// [GetWorkflow][google.cloud.workflows.v1.Workflows.GetWorkflow] method. -message GetWorkflowRequest { - // Required. Name of the workflow which information should be retrieved. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; -} - -// Request for the -// [CreateWorkflow][google.cloud.workflows.v1.Workflows.CreateWorkflow] -// method. -message CreateWorkflowRequest { - // Required. Project and location in which the workflow should be created. - // Format: projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. Workflow to be created. - Workflow workflow = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID of the workflow to be created. It has to fulfill the - // following requirements: - // - // * Must contain only letters, numbers, underscores and hyphens. - // * Must start with a letter. - // * Must be between 1-64 characters. - // * Must end with a number or a letter. - // * Must be unique within the customer project and location. - string workflow_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [DeleteWorkflow][google.cloud.workflows.v1.Workflows.DeleteWorkflow] -// method. -message DeleteWorkflowRequest { - // Required. Name of the workflow to be deleted. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; -} - -// Request for the -// [UpdateWorkflow][google.cloud.workflows.v1.Workflows.UpdateWorkflow] -// method. -message UpdateWorkflowRequest { - // Required. Workflow to be updated. - Workflow workflow = 1 [(google.api.field_behavior) = REQUIRED]; - - // List of fields to be updated. If not present, the entire workflow - // will be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Server-defined resource path for the target of the operation. - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // API version used to start the operation. - string api_version = 5; -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 5616212..0000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const WorkflowsClient = v1.WorkflowsClient; -type WorkflowsClient = v1.WorkflowsClient; -export {v1, WorkflowsClient}; -export default {v1, WorkflowsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/executions_client.ts b/owl-bot-staging/v1/src/v1/executions_client.ts deleted file mode 100644 index 1133ca0..0000000 --- a/owl-bot-staging/v1/src/v1/executions_client.ts +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/executions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './executions_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Executions is used to start and manage running instances of - * {@link google.cloud.workflows.v1.Workflow|Workflows} called executions. - * @class - * @memberof v1 - */ -export class ExecutionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - executionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ExecutionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ExecutionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.executions.v1.Executions', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.executionsStub) { - return this.executionsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.executions.v1.Executions. - this.executionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1.Executions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.executions.v1.Executions, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const executionsStubMethods = - ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; - for (const methodName of executionsStubMethods) { - const callPromise = this.executionsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.executionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createExecution( - request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined - ]>; - createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; - createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new execution using the latest revision of the given workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which an execution should be created. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * The latest revision of the workflow will be used. - * @param {google.cloud.workflows.executions.v1.Execution} request.execution - * Required. Execution to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createExecution(request); - */ - createExecution( - request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createExecution(request, options, callback); - } - getExecution( - request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be retrieved. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned execution. - * The API will default to the FULL view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getExecution(request); - */ - getExecution( - request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined - ]>; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Cancels an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be cancelled. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.cancelExecution(request); - */ - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution, - protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.cancelExecution(request, options, callback); - } - - listExecutions( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution[], - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): void; - listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): void; -/** - * Returns a list of executions which belong to the workflow with - * the given name. The method returns executions of all workflow - * revisions. Returned executions are ordered by their start time (newest - * first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1.Execution}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1.IExecution>): - Promise<[ - protos.google.cloud.workflows.executions.v1.IExecution[], - protos.google.cloud.workflows.executions.v1.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1.Execution} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Execution]{@link google.cloud.workflows.executions.v1.Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listExecutionsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listExecutionsAsync( - request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,workflow:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the workflow from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).workflow; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.executionsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/executions_client_config.json b/owl-bot-staging/v1/src/v1/executions_client_config.json deleted file mode 100644 index ea2d78f..0000000 --- a/owl-bot-staging/v1/src/v1/executions_client_config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.executions.v1.Executions": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListExecutions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CancelExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/executions_proto_list.json b/owl-bot-staging/v1/src/v1/executions_proto_list.json deleted file mode 100644 index 3cffd5d..0000000 --- a/owl-bot-staging/v1/src/v1/executions_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/executions/v1/executions.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 4beac11..0000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.workflows.v1", - "libraryPackage": "@google-cloud/workflows", - "services": { - "Workflows": { - "clients": { - "grpc": { - "libraryClient": "WorkflowsClient", - "rpcs": { - "GetWorkflow": { - "methods": [ - "getWorkflow" - ] - }, - "CreateWorkflow": { - "methods": [ - "createWorkflow" - ] - }, - "DeleteWorkflow": { - "methods": [ - "deleteWorkflow" - ] - }, - "UpdateWorkflow": { - "methods": [ - "updateWorkflow" - ] - }, - "ListWorkflows": { - "methods": [ - "listWorkflows", - "listWorkflowsStream", - "listWorkflowsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "WorkflowsClient", - "rpcs": { - "GetWorkflow": { - "methods": [ - "getWorkflow" - ] - }, - "CreateWorkflow": { - "methods": [ - "createWorkflow" - ] - }, - "DeleteWorkflow": { - "methods": [ - "deleteWorkflow" - ] - }, - "UpdateWorkflow": { - "methods": [ - "updateWorkflow" - ] - }, - "ListWorkflows": { - "methods": [ - "listWorkflows", - "listWorkflowsStream", - "listWorkflowsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 79adf07..0000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {WorkflowsClient} from './workflows_client'; diff --git a/owl-bot-staging/v1/src/v1/workflows_client.ts b/owl-bot-staging/v1/src/v1/workflows_client.ts deleted file mode 100644 index d23eec3..0000000 --- a/owl-bot-staging/v1/src/v1/workflows_client.ts +++ /dev/null @@ -1,1038 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/workflows_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './workflows_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Workflows is used to deploy and execute workflow programs. - * Workflows makes sure the program executes reliably, despite hardware and - * networking interruptions. - * @class - * @memberof v1 - */ -export class WorkflowsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - workflowsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of WorkflowsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof WorkflowsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listWorkflows: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'workflows') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const createWorkflowResponse = protoFilesRoot.lookup( - '.google.cloud.workflows.v1.Workflow') as gax.protobuf.Type; - const createWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; - const deleteWorkflowResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; - const updateWorkflowResponse = protoFilesRoot.lookup( - '.google.cloud.workflows.v1.Workflow') as gax.protobuf.Type; - const updateWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createWorkflowResponse.decode.bind(createWorkflowResponse), - createWorkflowMetadata.decode.bind(createWorkflowMetadata)), - deleteWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteWorkflowResponse.decode.bind(deleteWorkflowResponse), - deleteWorkflowMetadata.decode.bind(deleteWorkflowMetadata)), - updateWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateWorkflowResponse.decode.bind(updateWorkflowResponse), - updateWorkflowMetadata.decode.bind(updateWorkflowMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.v1.Workflows', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.workflowsStub) { - return this.workflowsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.v1.Workflows. - this.workflowsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.v1.Workflows') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.v1.Workflows, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const workflowsStubMethods = - ['listWorkflows', 'getWorkflow', 'createWorkflow', 'deleteWorkflow', 'updateWorkflow']; - for (const methodName of workflowsStubMethods) { - const callPromise = this.workflowsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.workflowsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflows.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflows.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getWorkflow( - request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|undefined, {}|undefined - ]>; - getWorkflow( - request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): void; - getWorkflow( - request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, - callback: Callback< - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets details of a single Workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the workflow which information should be retrieved. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Workflow]{@link google.cloud.workflows.v1.Workflow}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getWorkflow(request); - */ - getWorkflow( - request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.v1.IWorkflow, - protos.google.cloud.workflows.v1.IGetWorkflowRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getWorkflow(request, options, callback); - } - - createWorkflow( - request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createWorkflow( - request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createWorkflow( - request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new workflow. If a workflow with the specified name already - * exists in the specified project and location, the long running operation - * will return {@link google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS} error. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location in which the workflow should be created. - * Format: projects/{project}/locations/{location} - * @param {google.cloud.workflows.v1.Workflow} request.workflow - * Required. Workflow to be created. - * @param {string} request.workflowId - * Required. The ID of the workflow to be created. It has to fulfill the - * following requirements: - * - * * Must contain only letters, numbers, underscores and hyphens. - * * Must start with a letter. - * * Must be between 1-64 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project and location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.createWorkflow(request); - * const [response] = await operation.promise(); - */ - createWorkflow( - request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkCreateWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkCreateWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - deleteWorkflow( - request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteWorkflow( - request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteWorkflow( - request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Deletes a workflow with the specified name. - * This method also cancels and deletes all running executions of the - * workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the workflow to be deleted. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.deleteWorkflow(request); - * const [response] = await operation.promise(); - */ - deleteWorkflow( - request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkDeleteWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkDeleteWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - updateWorkflow( - request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateWorkflow( - request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateWorkflow( - request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Updates an existing workflow. - * Running this method has no impact on already running executions of the - * workflow. A new revision of the workflow may be created as a result of a - * successful update operation. In that case, such revision will be used - * in new workflow executions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.workflows.v1.Workflow} request.workflow - * Required. Workflow to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * List of fields to be updated. If not present, the entire workflow - * will be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.updateWorkflow(request); - * const [response] = await operation.promise(); - */ - updateWorkflow( - request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'workflow.name': request.workflow!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkUpdateWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkUpdateWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - listWorkflows( - request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.v1.IWorkflow[], - protos.google.cloud.workflows.v1.IListWorkflowsRequest|null, - protos.google.cloud.workflows.v1.IListWorkflowsResponse - ]>; - listWorkflows( - request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.v1.IListWorkflowsRequest, - protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1.IWorkflow>): void; - listWorkflows( - request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.v1.IListWorkflowsRequest, - protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1.IWorkflow>): void; -/** - * Lists Workflows in a given project and location. - * The default order is not specified. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Workflow]{@link google.cloud.workflows.v1.Workflow}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listWorkflowsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listWorkflows( - request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.v1.IListWorkflowsRequest, - protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1.IWorkflow>, - callback?: PaginationCallback< - protos.google.cloud.workflows.v1.IListWorkflowsRequest, - protos.google.cloud.workflows.v1.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1.IWorkflow>): - Promise<[ - protos.google.cloud.workflows.v1.IWorkflow[], - protos.google.cloud.workflows.v1.IListWorkflowsRequest|null, - protos.google.cloud.workflows.v1.IListWorkflowsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listWorkflows(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Workflow]{@link google.cloud.workflows.v1.Workflow} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listWorkflowsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listWorkflowsStream( - request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listWorkflows.createStream( - this.innerApiCalls.listWorkflows as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listWorkflows`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Workflow]{@link google.cloud.workflows.v1.Workflow}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listWorkflowsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listWorkflowsAsync( - request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listWorkflows.asyncIterate( - this.innerApiCalls['listWorkflows'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.workflowsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/workflows_client_config.json b/owl-bot-staging/v1/src/v1/workflows_client_config.json deleted file mode 100644 index 02f67fc..0000000 --- a/owl-bot-staging/v1/src/v1/workflows_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.v1.Workflows": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListWorkflows": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/workflows_proto_list.json b/owl-bot-staging/v1/src/v1/workflows_proto_list.json deleted file mode 100644 index 46c65a9..0000000 --- a/owl-bot-staging/v1/src/v1/workflows_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/v1/workflows.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f57e805..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const workflows = require('@google-cloud/workflows'); - -function main() { - const workflowsClient = new workflows.WorkflowsClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 3aa8565..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {WorkflowsClient} from '@google-cloud/workflows'; - -// check that the client class type name can be used -function doStuffWithWorkflowsClient(client: WorkflowsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const workflowsClient = new WorkflowsClient(); - doStuffWithWorkflowsClient(workflowsClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_executions_v1.ts b/owl-bot-staging/v1/test/gapic_executions_v1.ts deleted file mode 100644 index 2093e36..0000000 --- a/owl-bot-staging/v1/test/gapic_executions_v1.ts +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as executionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ExecutionsClient', () => { - it('has servicePath', () => { - const servicePath = executionsModule.v1.ExecutionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = executionsModule.v1.ExecutionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = executionsModule.v1.ExecutionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new executionsModule.v1.ExecutionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new executionsModule.v1.ExecutionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - await client.initialize(); - assert(client.executionsStub); - }); - - it('has close method', () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); - const [response] = await client.createExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('cancelExecution', () => { - it('invokes cancelExecution without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); - const [response] = await client.cancelExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes cancelExecution without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes cancelExecution with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelExecution(request), expectedError); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listExecutions with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.executions.v1.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - execution: "executionValue", - }; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromExecutionName', () => { - const result = client.matchWorkflowFromExecutionName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new executionsModule.v1.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_workflows_v1.ts b/owl-bot-staging/v1/test/gapic_workflows_v1.ts deleted file mode 100644 index dba0a6b..0000000 --- a/owl-bot-staging/v1/test/gapic_workflows_v1.ts +++ /dev/null @@ -1,1012 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as workflowsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.WorkflowsClient', () => { - it('has servicePath', () => { - const servicePath = workflowsModule.v1.WorkflowsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = workflowsModule.v1.WorkflowsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = workflowsModule.v1.WorkflowsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new workflowsModule.v1.WorkflowsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new workflowsModule.v1.WorkflowsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.workflowsStub, undefined); - await client.initialize(); - assert(client.workflowsStub); - }); - - it('has close method', () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getWorkflow', () => { - it('invokes getWorkflow without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()); - client.innerApiCalls.getWorkflow = stubSimpleCall(expectedResponse); - const [response] = await client.getWorkflow(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getWorkflow without error using callback', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()); - client.innerApiCalls.getWorkflow = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getWorkflow( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.v1.IWorkflow|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getWorkflow with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getWorkflow = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getWorkflow(request), expectedError); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createWorkflow', () => { - it('invokes createWorkflow without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.createWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createWorkflow without error using callback', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createWorkflow with call error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createWorkflow(request), expectedError); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createWorkflow with LRO error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateWorkflowProgress without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateWorkflowProgress with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteWorkflow', () => { - it('invokes deleteWorkflow without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteWorkflow without error using callback', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteWorkflow with call error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteWorkflow(request), expectedError); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteWorkflow with LRO error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteWorkflowProgress without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteWorkflowProgress with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateWorkflow', () => { - it('invokes updateWorkflow without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateWorkflow without error using callback', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateWorkflow with call error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateWorkflow(request), expectedError); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateWorkflow with LRO error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateWorkflowProgress without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateWorkflowProgress with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listWorkflows', () => { - it('invokes listWorkflows without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - ]; - client.innerApiCalls.listWorkflows = stubSimpleCall(expectedResponse); - const [response] = await client.listWorkflows(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listWorkflows without error using callback', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - ]; - client.innerApiCalls.listWorkflows = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listWorkflows( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.v1.IWorkflow[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listWorkflows with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listWorkflows = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listWorkflows(request), expectedError); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listWorkflowsStream without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - ]; - client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listWorkflowsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.v1.Workflow[] = []; - stream.on('data', (response: protos.google.cloud.workflows.v1.Workflow) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); - assert.strictEqual( - (client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listWorkflowsStream with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listWorkflowsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.v1.Workflow[] = []; - stream.on('data', (response: protos.google.cloud.workflows.v1.Workflow) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); - assert.strictEqual( - (client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listWorkflows without error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1.Workflow()), - ]; - client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.v1.IWorkflow[] = []; - const iterable = client.listWorkflowsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listWorkflows with error', async () => { - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listWorkflowsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.v1.IWorkflow[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new workflowsModule.v1.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto b/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto deleted file mode 100644 index 5b03fdf..0000000 --- a/owl-bot-staging/v1beta/protos/google/cloud/workflows/executions/v1beta/executions.proto +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.executions.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/executions/v1beta;executions"; -option java_multiple_files = true; -option java_outer_classname = "ExecutionsProto"; -option java_package = "com.google.cloud.workflows.executions.v1beta"; -option (google.api.resource_definition) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" -}; - -// Executions is used to start and manage running instances of -// [Workflows][google.cloud.workflows.v1beta.Workflow] called executions. -service Executions { - option (google.api.default_host) = "workflowexecutions.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Returns a list of executions which belong to the workflow with - // the given name. The method returns executions of all workflow - // revisions. Returned executions are ordered by their start time (newest - // first). - rpc ListExecutions(ListExecutionsRequest) returns (ListExecutionsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a new execution using the latest revision of the given workflow. - rpc CreateExecution(CreateExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions" - body: "execution" - }; - option (google.api.method_signature) = "parent,execution"; - } - - // Returns an execution of the given name. - rpc GetExecution(GetExecutionRequest) returns (Execution) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Cancels an execution of the given name. - rpc CancelExecution(CancelExecutionRequest) returns (Execution) { - option (google.api.http) = { - post: "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// A running instance of a [Workflow][google.cloud.workflows.v1beta.Workflow]. -message Execution { - option (google.api.resource) = { - type: "workflowexecutions.googleapis.com/Execution" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}" - }; - - // Error describes why the execution was abnormally terminated. - message Error { - // Error payload returned by the execution, represented as a JSON string. - string payload = 1; - - // Human readable error context, helpful for debugging purposes. - string context = 2; - } - - // Describes the current state of the execution. More states may be added - // in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The execution is in progress. - ACTIVE = 1; - - // The execution finished successfully. - SUCCEEDED = 2; - - // The execution failed with an error. - FAILED = 3; - - // The execution was stopped intentionally. - CANCELLED = 4; - } - - // Output only. The resource name of the execution. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the beginning of execution. - google.protobuf.Timestamp start_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Marks the end of execution, successful or not. - google.protobuf.Timestamp end_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Current state of the execution. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Input parameters of the execution represented as a JSON string. - // The size limit is 32KB. - string argument = 5; - - // Output only. Output of the execution represented as a JSON string. The - // value can only be present if the execution's state is `SUCCEEDED`. - string result = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The error which caused the execution to finish prematurely. - // The value is only present if the execution's state is `FAILED` - // or `CANCELLED`. - Error error = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Revision of the workflow this execution is using. - string workflow_revision_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for the -// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] -// method. -message ListExecutionsRequest { - // Required. Name of the workflow for which the executions should be listed. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Maximum number of executions to return per call. - // Max supported value depends on the selected Execution view: it's 10000 for - // BASIC and 100 for FULL. The default value used if the field is not - // specified is 100, regardless of the selected view. Values greater than - // the max value will be coerced down to it. - int32 page_size = 2; - - // A page token, received from a previous `ListExecutions` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListExecutions` must - // match the call that provided the page token. - string page_token = 3; - - // Optional. A view defining which fields should be filled in the returned executions. - // The API will default to the BASIC view. - ExecutionView view = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response for the -// [ListExecutions][google.cloud.workflows.executions.v1beta.Executions.ListExecutions] -// method. -message ListExecutionsResponse { - // The executions which match the request. - repeated Execution executions = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Request for the -// [CreateExecution][google.cloud.workflows.executions.v1beta.Executions.CreateExecution] -// method. -message CreateExecutionRequest { - // Required. Name of the workflow for which an execution should be created. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - // The latest revision of the workflow will be used. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; - - // Required. Execution to be created. - Execution execution = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [GetExecution][google.cloud.workflows.executions.v1beta.Executions.GetExecution] -// method. -message GetExecutionRequest { - // Required. Name of the execution to be retrieved. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; - - // Optional. A view defining which fields should be filled in the returned execution. - // The API will default to the FULL view. - ExecutionView view = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for the -// [CancelExecution][google.cloud.workflows.executions.v1beta.Executions.CancelExecution] -// method. -message CancelExecutionRequest { - // Required. Name of the execution to be cancelled. - // Format: - // projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflowexecutions.googleapis.com/Execution" - } - ]; -} - -// Defines possible views for execution resource. -enum ExecutionView { - // The default / unset value. - EXECUTION_VIEW_UNSPECIFIED = 0; - - // Includes only basic metadata about the execution. - // Following fields are returned: name, start_time, end_time, state - // and workflow_revision_id. - BASIC = 1; - - // Includes all data. - FULL = 2; -} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto b/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto deleted file mode 100644 index 5308fa7..0000000 --- a/owl-bot-staging/v1beta/protos/google/cloud/workflows/v1beta/workflows.proto +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.workflows.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/workflows/v1beta;workflows"; -option java_multiple_files = true; -option java_outer_classname = "WorkflowsProto"; -option java_package = "com.google.cloud.workflows.v1beta"; - -// Workflows is used to deploy and execute workflow programs. -// Workflows makes sure the program executes reliably, despite hardware and -// networking interruptions. -service Workflows { - option (google.api.default_host) = "workflows.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists Workflows in a given project and location. - // The default order is not specified. - rpc ListWorkflows(ListWorkflowsRequest) returns (ListWorkflowsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*}/workflows" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets details of a single Workflow. - rpc GetWorkflow(GetWorkflowRequest) returns (Workflow) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/locations/*/workflows/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new workflow. If a workflow with the specified name already - // exists in the specified project and location, the long running operation - // will return [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. - rpc CreateWorkflow(CreateWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*}/workflows" - body: "workflow" - }; - option (google.api.method_signature) = "parent,workflow,workflow_id"; - option (google.longrunning.operation_info) = { - response_type: "Workflow" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a workflow with the specified name. - // This method also cancels and deletes all running executions of the - // workflow. - rpc DeleteWorkflow(DeleteWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta/{name=projects/*/locations/*/workflows/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "OperationMetadata" - }; - } - - // Updates an existing workflow. - // Running this method has no impact on already running executions of the - // workflow. A new revision of the workflow may be created as a result of a - // successful update operation. In that case, such revision will be used - // in new workflow executions. - rpc UpdateWorkflow(UpdateWorkflowRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta/{workflow.name=projects/*/locations/*/workflows/*}" - body: "workflow" - }; - option (google.api.method_signature) = "workflow,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Workflow" - metadata_type: "OperationMetadata" - }; - } -} - -// Workflow program to be executed by Workflows. -message Workflow { - option (google.api.resource) = { - type: "workflows.googleapis.com/Workflow" - pattern: "projects/{project}/locations/{location}/workflows/{workflow}" - }; - - // Describes the current state of workflow deployment. More states may be - // added in the future. - enum State { - // Invalid state. - STATE_UNSPECIFIED = 0; - - // The workflow has been deployed successfully and is serving. - ACTIVE = 1; - } - - // The resource name of the workflow. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1; - - // Description of the workflow provided by the user. - // Must be at most 1000 unicode characters long. - string description = 2; - - // Output only. State of the workflow deployment. - State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The revision of the workflow. - // A new revision of a workflow is created as a result of updating the - // following fields of a workflow: - // - `source_code` - // - `service_account` - // The format is "000001-a4d", where the first 6 characters define - // the zero-padded revision ordinal number. They are followed by a hyphen and - // 3 hexadecimal random characters. - string revision_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp of when the workflow was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last update timestamp of the workflow. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The timestamp that the latest revision of the workflow - // was created. - google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Labels associated with this workflow. - // Labels can contain at most 64 entries. Keys and values can be no longer - // than 63 characters and can only contain lowercase letters, numeric - // characters, underscores and dashes. Label keys must start with a letter. - // International characters are allowed. - map labels = 8; - - // Name of the service account associated with the latest workflow version. - // This service account represents the identity of the workflow and determines - // what permissions the workflow has. - // Format: projects/{project}/serviceAccounts/{account} - // - // Using `-` as a wildcard for the `{project}` will infer the project from - // the account. The `{account}` value can be the `email` address or the - // `unique_id` of the service account. - // - // If not provided, workflow will use the project's default service account. - // Modifying this field for an existing workflow results in a new workflow - // revision. - string service_account = 9; - - // Required. Location of the workflow source code. - // Modifying this field for an existing workflow results in a new workflow - // revision. - oneof source_code { - // Workflow code to be executed. The size limit is 32KB. - string source_contents = 10; - } -} - -// Request for the -// [ListWorkflows][google.cloud.workflows.v1beta.Workflows.ListWorkflows] -// method. -message ListWorkflowsRequest { - // Required. Project and location from which the workflows should be listed. - // Format: projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Maximum number of workflows to return per call. The service may return - // fewer than this value. If the value is not specified, a default value of - // 500 will be used. The maximum permitted value is 1000 and values greater - // than 1000 will be coerced down to 1000. - int32 page_size = 2; - - // A page token, received from a previous `ListWorkflows` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListWorkflows` must - // match the call that provided the page token. - string page_token = 3; - - // Filter to restrict results to specific workflows. - string filter = 4; - - // Comma-separated list of fields that that specify the order of the results. - // Default sorting order for a field is ascending. To specify descending order - // for a field, append a " desc" suffix. - // If not specified, the results will be returned in an unspecified order. - string order_by = 5; -} - -// Response for the -// [ListWorkflows][google.cloud.workflows.v1beta.Workflows.ListWorkflows] -// method. -message ListWorkflowsResponse { - // The workflows which match the request. - repeated Workflow workflows = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; - - // Unreachable resources. - repeated string unreachable = 3; -} - -// Request for the -// [GetWorkflow][google.cloud.workflows.v1beta.Workflows.GetWorkflow] method. -message GetWorkflowRequest { - // Required. Name of the workflow which information should be retrieved. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; -} - -// Request for the -// [CreateWorkflow][google.cloud.workflows.v1beta.Workflows.CreateWorkflow] -// method. -message CreateWorkflowRequest { - // Required. Project and location in which the workflow should be created. - // Format: projects/{project}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. Workflow to be created. - Workflow workflow = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID of the workflow to be created. It has to fulfill the - // following requirements: - // - // * Must contain only letters, numbers, underscores and hyphens. - // * Must start with a letter. - // * Must be between 1-64 characters. - // * Must end with a number or a letter. - // * Must be unique within the customer project and location. - string workflow_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for the -// [DeleteWorkflow][google.cloud.workflows.v1beta.Workflows.DeleteWorkflow] -// method. -message DeleteWorkflowRequest { - // Required. Name of the workflow to be deleted. - // Format: projects/{project}/locations/{location}/workflows/{workflow} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "workflows.googleapis.com/Workflow" - } - ]; -} - -// Request for the -// [UpdateWorkflow][google.cloud.workflows.v1beta.Workflows.UpdateWorkflow] -// method. -message UpdateWorkflowRequest { - // Required. Workflow to be updated. - Workflow workflow = 1 [(google.api.field_behavior) = REQUIRED]; - - // List of fields to be updated. If not present, the entire workflow - // will be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Server-defined resource path for the target of the operation. - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // API version used to start the operation. - string api_version = 5; -} diff --git a/owl-bot-staging/v1beta/src/index.ts b/owl-bot-staging/v1beta/src/index.ts deleted file mode 100644 index 0c46b3b..0000000 --- a/owl-bot-staging/v1beta/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta from './v1beta'; -const WorkflowsClient = v1beta.WorkflowsClient; -type WorkflowsClient = v1beta.WorkflowsClient; -export {v1beta, WorkflowsClient}; -export default {v1beta, WorkflowsClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_client.ts b/owl-bot-staging/v1beta/src/v1beta/executions_client.ts deleted file mode 100644 index e9afb3e..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/executions_client.ts +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/executions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './executions_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Executions is used to start and manage running instances of - * {@link google.cloud.workflows.v1beta.Workflow|Workflows} called executions. - * @class - * @memberof v1beta - */ -export class ExecutionsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - executionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ExecutionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ExecutionsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - executionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listExecutions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'executions') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.executions.v1beta.Executions', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.executionsStub) { - return this.executionsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.executions.v1beta.Executions. - this.executionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.executions.v1beta.Executions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.executions.v1beta.Executions, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const executionsStubMethods = - ['listExecutions', 'createExecution', 'getExecution', 'cancelExecution']; - for (const methodName of executionsStubMethods) { - const callPromise = this.executionsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.executionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflowexecutions.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined - ]>; - createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; - createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new execution using the latest revision of the given workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which an execution should be created. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * The latest revision of the workflow will be used. - * @param {google.cloud.workflows.executions.v1beta.Execution} request.execution - * Required. Execution to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createExecution(request); - */ - createExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createExecution(request, options, callback); - } - getExecution( - request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined - ]>; - getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; - getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be retrieved. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned execution. - * The API will default to the FULL view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getExecution(request); - */ - getExecution( - request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getExecution(request, options, callback); - } - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined - ]>; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; - cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - callback: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): void; -/** - * Cancels an execution of the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the execution to be cancelled. - * Format: - * projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.cancelExecution(request); - */ - cancelExecution( - request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution, - protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.cancelExecution(request, options, callback); - } - - listExecutions( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution[], - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse - ]>; - listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): void; - listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): void; -/** - * Returns a list of executions which belong to the workflow with - * the given name. The method returns executions of all workflow - * revisions. Returned executions are ordered by their start time (newest - * first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutions( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>, - callback?: PaginationCallback< - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse|null|undefined, - protos.google.cloud.workflows.executions.v1beta.IExecution>): - Promise<[ - protos.google.cloud.workflows.executions.v1beta.IExecution[], - protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest|null, - protos.google.cloud.workflows.executions.v1beta.IListExecutionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listExecutions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Execution]{@link google.cloud.workflows.executions.v1beta.Execution} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listExecutionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listExecutionsStream( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.createStream( - this.innerApiCalls.listExecutions as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listExecutions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the workflow for which the executions should be listed. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {number} request.pageSize - * Maximum number of executions to return per call. - * Max supported value depends on the selected Execution view: it's 10000 for - * BASIC and 100 for FULL. The default value used if the field is not - * specified is 100, regardless of the selected view. Values greater than - * the max value will be coerced down to it. - * @param {string} request.pageToken - * A page token, received from a previous `ListExecutions` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListExecutions` must - * match the call that provided the page token. - * @param {google.cloud.workflows.executions.v1beta.ExecutionView} [request.view] - * Optional. A view defining which fields should be filled in the returned executions. - * The API will default to the BASIC view. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Execution]{@link google.cloud.workflows.executions.v1beta.Execution}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listExecutionsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listExecutionsAsync( - request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listExecutions.asyncIterate( - this.innerApiCalls['listExecutions'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified execution resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @param {string} execution - * @returns {string} Resource name string. - */ - executionPath(project:string,location:string,workflow:string,execution:string) { - return this.pathTemplates.executionPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - execution: execution, - }); - } - - /** - * Parse the project from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).project; - } - - /** - * Parse the location from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).location; - } - - /** - * Parse the workflow from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).workflow; - } - - /** - * Parse the execution from Execution resource. - * - * @param {string} executionName - * A fully-qualified path representing Execution resource. - * @returns {string} A string representing the execution. - */ - matchExecutionFromExecutionName(executionName: string) { - return this.pathTemplates.executionPathTemplate.match(executionName).execution; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.executionsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json b/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json deleted file mode 100644 index bf2692e..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/executions_client_config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.executions.v1beta.Executions": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListExecutions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CancelExecution": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json b/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json deleted file mode 100644 index 2450667..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/executions_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/executions/v1beta/executions.proto" -] diff --git a/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json deleted file mode 100644 index 72f32db..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.workflows.v1beta", - "libraryPackage": "@google-cloud/workflows", - "services": { - "Workflows": { - "clients": { - "grpc": { - "libraryClient": "WorkflowsClient", - "rpcs": { - "GetWorkflow": { - "methods": [ - "getWorkflow" - ] - }, - "CreateWorkflow": { - "methods": [ - "createWorkflow" - ] - }, - "DeleteWorkflow": { - "methods": [ - "deleteWorkflow" - ] - }, - "UpdateWorkflow": { - "methods": [ - "updateWorkflow" - ] - }, - "ListWorkflows": { - "methods": [ - "listWorkflows", - "listWorkflowsStream", - "listWorkflowsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "WorkflowsClient", - "rpcs": { - "GetWorkflow": { - "methods": [ - "getWorkflow" - ] - }, - "CreateWorkflow": { - "methods": [ - "createWorkflow" - ] - }, - "DeleteWorkflow": { - "methods": [ - "deleteWorkflow" - ] - }, - "UpdateWorkflow": { - "methods": [ - "updateWorkflow" - ] - }, - "ListWorkflows": { - "methods": [ - "listWorkflows", - "listWorkflowsStream", - "listWorkflowsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta/src/v1beta/index.ts b/owl-bot-staging/v1beta/src/v1beta/index.ts deleted file mode 100644 index 79adf07..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {WorkflowsClient} from './workflows_client'; diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts b/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts deleted file mode 100644 index 9374488..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/workflows_client.ts +++ /dev/null @@ -1,1038 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/workflows_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './workflows_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Workflows is used to deploy and execute workflow programs. - * Workflows makes sure the program executes reliably, despite hardware and - * networking interruptions. - * @class - * @memberof v1beta - */ -export class WorkflowsClient { - private _terminated = false; - private _opts: ClientOptions; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - workflowsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of WorkflowsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof WorkflowsClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - workflowPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/workflows/{workflow}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listWorkflows: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'workflows') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const createWorkflowResponse = protoFilesRoot.lookup( - '.google.cloud.workflows.v1beta.Workflow') as gax.protobuf.Type; - const createWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; - const deleteWorkflowResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; - const updateWorkflowResponse = protoFilesRoot.lookup( - '.google.cloud.workflows.v1beta.Workflow') as gax.protobuf.Type; - const updateWorkflowMetadata = protoFilesRoot.lookup( - '.google.cloud.workflows.v1beta.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createWorkflowResponse.decode.bind(createWorkflowResponse), - createWorkflowMetadata.decode.bind(createWorkflowMetadata)), - deleteWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteWorkflowResponse.decode.bind(deleteWorkflowResponse), - deleteWorkflowMetadata.decode.bind(deleteWorkflowMetadata)), - updateWorkflow: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateWorkflowResponse.decode.bind(updateWorkflowResponse), - updateWorkflowMetadata.decode.bind(updateWorkflowMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.workflows.v1beta.Workflows', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.workflowsStub) { - return this.workflowsStub; - } - - // Put together the "service stub" for - // google.cloud.workflows.v1beta.Workflows. - this.workflowsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.workflows.v1beta.Workflows') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.workflows.v1beta.Workflows, - this._opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const workflowsStubMethods = - ['listWorkflows', 'getWorkflow', 'createWorkflow', 'deleteWorkflow', 'updateWorkflow']; - for (const methodName of workflowsStubMethods) { - const callPromise = this.workflowsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.workflowsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'workflows.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'workflows.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getWorkflow( - request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|undefined, {}|undefined - ]>; - getWorkflow( - request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): void; - getWorkflow( - request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, - callback: Callback< - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets details of a single Workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the workflow which information should be retrieved. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getWorkflow(request); - */ - getWorkflow( - request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.workflows.v1beta.IWorkflow, - protos.google.cloud.workflows.v1beta.IGetWorkflowRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getWorkflow(request, options, callback); - } - - createWorkflow( - request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createWorkflow( - request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createWorkflow( - request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new workflow. If a workflow with the specified name already - * exists in the specified project and location, the long running operation - * will return {@link google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS} error. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location in which the workflow should be created. - * Format: projects/{project}/locations/{location} - * @param {google.cloud.workflows.v1beta.Workflow} request.workflow - * Required. Workflow to be created. - * @param {string} request.workflowId - * Required. The ID of the workflow to be created. It has to fulfill the - * following requirements: - * - * * Must contain only letters, numbers, underscores and hyphens. - * * Must start with a letter. - * * Must be between 1-64 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project and location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.createWorkflow(request); - * const [response] = await operation.promise(); - */ - createWorkflow( - request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkCreateWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkCreateWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - deleteWorkflow( - request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteWorkflow( - request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteWorkflow( - request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Deletes a workflow with the specified name. - * This method also cancels and deletes all running executions of the - * workflow. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the workflow to be deleted. - * Format: projects/{project}/locations/{location}/workflows/{workflow} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.deleteWorkflow(request); - * const [response] = await operation.promise(); - */ - deleteWorkflow( - request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkDeleteWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkDeleteWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - updateWorkflow( - request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateWorkflow( - request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateWorkflow( - request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Updates an existing workflow. - * Running this method has no impact on already running executions of the - * workflow. A new revision of the workflow may be created as a result of a - * successful update operation. In that case, such revision will be used - * in new workflow executions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.workflows.v1beta.Workflow} request.workflow - * Required. Workflow to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * List of fields to be updated. If not present, the entire workflow - * will be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.updateWorkflow(request); - * const [response] = await operation.promise(); - */ - updateWorkflow( - request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'workflow.name': request.workflow!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateWorkflow(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateWorkflow()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkUpdateWorkflowProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkUpdateWorkflowProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateWorkflow, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - listWorkflows( - request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.workflows.v1beta.IWorkflow[], - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest|null, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse - ]>; - listWorkflows( - request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1beta.IWorkflow>): void; - listWorkflows( - request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - callback: PaginationCallback< - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1beta.IWorkflow>): void; -/** - * Lists Workflows in a given project and location. - * The default order is not specified. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listWorkflowsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listWorkflows( - request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1beta.IWorkflow>, - callback?: PaginationCallback< - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse|null|undefined, - protos.google.cloud.workflows.v1beta.IWorkflow>): - Promise<[ - protos.google.cloud.workflows.v1beta.IWorkflow[], - protos.google.cloud.workflows.v1beta.IListWorkflowsRequest|null, - protos.google.cloud.workflows.v1beta.IListWorkflowsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listWorkflows(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Workflow]{@link google.cloud.workflows.v1beta.Workflow} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listWorkflowsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listWorkflowsStream( - request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listWorkflows.createStream( - this.innerApiCalls.listWorkflows as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listWorkflows`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Project and location from which the workflows should be listed. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * Maximum number of workflows to return per call. The service may return - * fewer than this value. If the value is not specified, a default value of - * 500 will be used. The maximum permitted value is 1000 and values greater - * than 1000 will be coerced down to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListWorkflows` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListWorkflows` must - * match the call that provided the page token. - * @param {string} request.filter - * Filter to restrict results to specific workflows. - * @param {string} request.orderBy - * Comma-separated list of fields that that specify the order of the results. - * Default sorting order for a field is ascending. To specify descending order - * for a field, append a " desc" suffix. - * If not specified, the results will be returned in an unspecified order. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Workflow]{@link google.cloud.workflows.v1beta.Workflow}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listWorkflowsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listWorkflowsAsync( - request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listWorkflows.asyncIterate( - this.innerApiCalls['listWorkflows'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified workflow resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} workflow - * @returns {string} Resource name string. - */ - workflowPath(project:string,location:string,workflow:string) { - return this.pathTemplates.workflowPathTemplate.render({ - project: project, - location: location, - workflow: workflow, - }); - } - - /** - * Parse the project from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the project. - */ - matchProjectFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).project; - } - - /** - * Parse the location from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the location. - */ - matchLocationFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).location; - } - - /** - * Parse the workflow from Workflow resource. - * - * @param {string} workflowName - * A fully-qualified path representing Workflow resource. - * @returns {string} A string representing the workflow. - */ - matchWorkflowFromWorkflowName(workflowName: string) { - return this.pathTemplates.workflowPathTemplate.match(workflowName).workflow; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.workflowsStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json b/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json deleted file mode 100644 index bccc9e1..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/workflows_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.workflows.v1beta.Workflows": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListWorkflows": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateWorkflow": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json b/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json deleted file mode 100644 index c9d0fa6..0000000 --- a/owl-bot-staging/v1beta/src/v1beta/workflows_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/workflows/v1beta/workflows.proto" -] diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f57e805..0000000 --- a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const workflows = require('@google-cloud/workflows'); - -function main() { - const workflowsClient = new workflows.WorkflowsClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 3aa8565..0000000 --- a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {WorkflowsClient} from '@google-cloud/workflows'; - -// check that the client class type name can be used -function doStuffWithWorkflowsClient(client: WorkflowsClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const workflowsClient = new WorkflowsClient(); - doStuffWithWorkflowsClient(workflowsClient); -} - -main(); diff --git a/owl-bot-staging/v1beta/system-test/install.ts b/owl-bot-staging/v1beta/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1beta/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts b/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts deleted file mode 100644 index 725c793..0000000 --- a/owl-bot-staging/v1beta/test/gapic_executions_v1beta.ts +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as executionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.ExecutionsClient', () => { - it('has servicePath', () => { - const servicePath = executionsModule.v1beta.ExecutionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = executionsModule.v1beta.ExecutionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = executionsModule.v1beta.ExecutionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new executionsModule.v1beta.ExecutionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.executionsStub, undefined); - await client.initialize(); - assert(client.executionsStub); - }); - - it('has close method', () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createExecution', () => { - it('invokes createExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); - const [response] = await client.createExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.createExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CreateExecutionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createExecution(request), expectedError); - assert((client.innerApiCalls.createExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getExecution', () => { - it('invokes getExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); - const [response] = await client.getExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.getExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.GetExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getExecution(request), expectedError); - assert((client.innerApiCalls.getExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('cancelExecution', () => { - it('invokes cancelExecution without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCall(expectedResponse); - const [response] = await client.cancelExecution(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes cancelExecution without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()); - client.innerApiCalls.cancelExecution = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelExecution( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes cancelExecution with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.CancelExecutionRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelExecution = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelExecution(request), expectedError); - assert((client.innerApiCalls.cancelExecution as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listExecutions', () => { - it('invokes listExecutions without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); - const [response] = await client.listExecutions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutions without error using callback', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.innerApiCalls.listExecutions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listExecutions( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.executions.v1beta.IExecution[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listExecutions with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listExecutions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listExecutions(request), expectedError); - assert((client.innerApiCalls.listExecutions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listExecutionsStream without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listExecutionsStream with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listExecutionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.executions.v1beta.Execution[] = []; - stream.on('data', (response: protos.google.cloud.workflows.executions.v1beta.Execution) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listExecutions, request)); - assert.strictEqual( - (client.descriptors.page.listExecutions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions without error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.Execution()), - ]; - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; - const iterable = client.listExecutionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listExecutions with error', async () => { - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.executions.v1beta.ListExecutionsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listExecutionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.executions.v1beta.IExecution[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listExecutions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('execution', () => { - const fakePath = "/rendered/path/execution"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - execution: "executionValue", - }; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.executionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.executionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('executionPath', () => { - const result = client.executionPath("projectValue", "locationValue", "workflowValue", "executionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.executionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExecutionName', () => { - const result = client.matchProjectFromExecutionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExecutionName', () => { - const result = client.matchLocationFromExecutionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromExecutionName', () => { - const result = client.matchWorkflowFromExecutionName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExecutionFromExecutionName', () => { - const result = client.matchExecutionFromExecutionName(fakePath); - assert.strictEqual(result, "executionValue"); - assert((client.pathTemplates.executionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new executionsModule.v1beta.ExecutionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts b/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts deleted file mode 100644 index 1550e76..0000000 --- a/owl-bot-staging/v1beta/test/gapic_workflows_v1beta.ts +++ /dev/null @@ -1,1012 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as workflowsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.WorkflowsClient', () => { - it('has servicePath', () => { - const servicePath = workflowsModule.v1beta.WorkflowsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = workflowsModule.v1beta.WorkflowsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = workflowsModule.v1beta.WorkflowsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new workflowsModule.v1beta.WorkflowsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.workflowsStub, undefined); - await client.initialize(); - assert(client.workflowsStub); - }); - - it('has close method', () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getWorkflow', () => { - it('invokes getWorkflow without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()); - client.innerApiCalls.getWorkflow = stubSimpleCall(expectedResponse); - const [response] = await client.getWorkflow(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getWorkflow without error using callback', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()); - client.innerApiCalls.getWorkflow = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getWorkflow( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.v1beta.IWorkflow|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getWorkflow with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.GetWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getWorkflow = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getWorkflow(request), expectedError); - assert((client.innerApiCalls.getWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createWorkflow', () => { - it('invokes createWorkflow without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.createWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createWorkflow without error using callback', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createWorkflow with call error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createWorkflow(request), expectedError); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createWorkflow with LRO error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.CreateWorkflowRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateWorkflowProgress without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateWorkflowProgress with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteWorkflow', () => { - it('invokes deleteWorkflow without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteWorkflow without error using callback', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteWorkflow with call error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteWorkflow(request), expectedError); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteWorkflow with LRO error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.DeleteWorkflowRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteWorkflowProgress without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteWorkflowProgress with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateWorkflow', () => { - it('invokes updateWorkflow without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateWorkflow(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateWorkflow without error using callback', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateWorkflow = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateWorkflow( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateWorkflow with call error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateWorkflow(request), expectedError); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateWorkflow with LRO error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.UpdateWorkflowRequest()); - request.workflow = {}; - request.workflow.name = ''; - const expectedHeaderRequestParams = "workflow.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateWorkflow = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateWorkflow(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateWorkflow as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateWorkflowProgress without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateWorkflowProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateWorkflowProgress with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateWorkflowProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listWorkflows', () => { - it('invokes listWorkflows without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - ]; - client.innerApiCalls.listWorkflows = stubSimpleCall(expectedResponse); - const [response] = await client.listWorkflows(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listWorkflows without error using callback', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - ]; - client.innerApiCalls.listWorkflows = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listWorkflows( - request, - (err?: Error|null, result?: protos.google.cloud.workflows.v1beta.IWorkflow[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listWorkflows with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listWorkflows = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listWorkflows(request), expectedError); - assert((client.innerApiCalls.listWorkflows as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listWorkflowsStream without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - ]; - client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listWorkflowsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.v1beta.Workflow[] = []; - stream.on('data', (response: protos.google.cloud.workflows.v1beta.Workflow) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); - assert.strictEqual( - (client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listWorkflowsStream with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listWorkflowsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.workflows.v1beta.Workflow[] = []; - stream.on('data', (response: protos.google.cloud.workflows.v1beta.Workflow) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listWorkflows, request)); - assert.strictEqual( - (client.descriptors.page.listWorkflows.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listWorkflows without error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - generateSampleMessage(new protos.google.cloud.workflows.v1beta.Workflow()), - ]; - client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.workflows.v1beta.IWorkflow[] = []; - const iterable = client.listWorkflowsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listWorkflows with error', async () => { - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.workflows.v1beta.ListWorkflowsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listWorkflowsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.workflows.v1beta.IWorkflow[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listWorkflows.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('workflow', () => { - const fakePath = "/rendered/path/workflow"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - workflow: "workflowValue", - }; - const client = new workflowsModule.v1beta.WorkflowsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.workflowPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.workflowPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('workflowPath', () => { - const result = client.workflowPath("projectValue", "locationValue", "workflowValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.workflowPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromWorkflowName', () => { - const result = client.matchProjectFromWorkflowName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromWorkflowName', () => { - const result = client.matchLocationFromWorkflowName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchWorkflowFromWorkflowName', () => { - const result = client.matchWorkflowFromWorkflowName(fakePath); - assert.strictEqual(result, "workflowValue"); - assert((client.pathTemplates.workflowPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/src/v1/executions_client.ts b/src/v1/executions_client.ts index a28aef9..3c74c9f 100644 --- a/src/v1/executions_client.ts +++ b/src/v1/executions_client.ts @@ -306,7 +306,7 @@ export class ExecutionsClient { // -- Service calls -- // ------------------- createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, options?: CallOptions ): Promise< [ @@ -361,7 +361,7 @@ export class ExecutionsClient { * const [response] = await client.createExecution(request); */ createExecution( - request: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.ICreateExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -407,7 +407,7 @@ export class ExecutionsClient { return this.innerApiCalls.createExecution(request, options, callback); } getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, options?: CallOptions ): Promise< [ @@ -463,7 +463,7 @@ export class ExecutionsClient { * const [response] = await client.getExecution(request); */ getExecution( - request: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.IGetExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -509,7 +509,7 @@ export class ExecutionsClient { return this.innerApiCalls.getExecution(request, options, callback); } cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, options?: CallOptions ): Promise< [ @@ -562,7 +562,7 @@ export class ExecutionsClient { * const [response] = await client.cancelExecution(request); */ cancelExecution( - request: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1.ICancelExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -609,7 +609,7 @@ export class ExecutionsClient { } listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, options?: CallOptions ): Promise< [ @@ -679,7 +679,7 @@ export class ExecutionsClient { * for more details and examples. */ listExecutions( - request: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, + request?: protos.google.cloud.workflows.executions.v1.IListExecutionsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/src/v1/workflows_client.ts b/src/v1/workflows_client.ts index 19add64..1240f30 100644 --- a/src/v1/workflows_client.ts +++ b/src/v1/workflows_client.ts @@ -362,7 +362,7 @@ export class WorkflowsClient { // -- Service calls -- // ------------------- getWorkflow( - request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, options?: CallOptions ): Promise< [ @@ -407,7 +407,7 @@ export class WorkflowsClient { * const [response] = await client.getWorkflow(request); */ getWorkflow( - request: protos.google.cloud.workflows.v1.IGetWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IGetWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -449,7 +449,7 @@ export class WorkflowsClient { } createWorkflow( - request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, options?: CallOptions ): Promise< [ @@ -519,7 +519,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ createWorkflow( - request: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, + request?: protos.google.cloud.workflows.v1.ICreateWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -604,7 +604,7 @@ export class WorkflowsClient { >; } deleteWorkflow( - request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, options?: CallOptions ): Promise< [ @@ -663,7 +663,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ deleteWorkflow( - request: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IDeleteWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -748,7 +748,7 @@ export class WorkflowsClient { >; } updateWorkflow( - request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, options?: CallOptions ): Promise< [ @@ -811,7 +811,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ updateWorkflow( - request: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, + request?: protos.google.cloud.workflows.v1.IUpdateWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -896,7 +896,7 @@ export class WorkflowsClient { >; } listWorkflows( - request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, options?: CallOptions ): Promise< [ @@ -967,7 +967,7 @@ export class WorkflowsClient { * for more details and examples. */ listWorkflows( - request: protos.google.cloud.workflows.v1.IListWorkflowsRequest, + request?: protos.google.cloud.workflows.v1.IListWorkflowsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/src/v1beta/executions_client.ts b/src/v1beta/executions_client.ts index 723eda8..6febca6 100644 --- a/src/v1beta/executions_client.ts +++ b/src/v1beta/executions_client.ts @@ -307,7 +307,7 @@ export class ExecutionsClient { // -- Service calls -- // ------------------- createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, options?: CallOptions ): Promise< [ @@ -362,7 +362,7 @@ export class ExecutionsClient { * const [response] = await client.createExecution(request); */ createExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.ICreateExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -408,7 +408,7 @@ export class ExecutionsClient { return this.innerApiCalls.createExecution(request, options, callback); } getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, options?: CallOptions ): Promise< [ @@ -464,7 +464,7 @@ export class ExecutionsClient { * const [response] = await client.getExecution(request); */ getExecution( - request: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.IGetExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -510,7 +510,7 @@ export class ExecutionsClient { return this.innerApiCalls.getExecution(request, options, callback); } cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, options?: CallOptions ): Promise< [ @@ -563,7 +563,7 @@ export class ExecutionsClient { * const [response] = await client.cancelExecution(request); */ cancelExecution( - request: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, + request?: protos.google.cloud.workflows.executions.v1beta.ICancelExecutionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -610,7 +610,7 @@ export class ExecutionsClient { } listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, options?: CallOptions ): Promise< [ @@ -680,7 +680,7 @@ export class ExecutionsClient { * for more details and examples. */ listExecutions( - request: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, + request?: protos.google.cloud.workflows.executions.v1beta.IListExecutionsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/src/v1beta/workflows_client.ts b/src/v1beta/workflows_client.ts index 5f1ba0f..7bf7dea 100644 --- a/src/v1beta/workflows_client.ts +++ b/src/v1beta/workflows_client.ts @@ -362,7 +362,7 @@ export class WorkflowsClient { // -- Service calls -- // ------------------- getWorkflow( - request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, options?: CallOptions ): Promise< [ @@ -411,7 +411,7 @@ export class WorkflowsClient { * const [response] = await client.getWorkflow(request); */ getWorkflow( - request: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IGetWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -455,7 +455,7 @@ export class WorkflowsClient { } createWorkflow( - request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, options?: CallOptions ): Promise< [ @@ -525,7 +525,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ createWorkflow( - request: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.ICreateWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -610,7 +610,7 @@ export class WorkflowsClient { >; } deleteWorkflow( - request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, options?: CallOptions ): Promise< [ @@ -669,7 +669,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ deleteWorkflow( - request: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IDeleteWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -754,7 +754,7 @@ export class WorkflowsClient { >; } updateWorkflow( - request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, options?: CallOptions ): Promise< [ @@ -817,7 +817,7 @@ export class WorkflowsClient { * const [response] = await operation.promise(); */ updateWorkflow( - request: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, + request?: protos.google.cloud.workflows.v1beta.IUpdateWorkflowRequest, optionsOrCallback?: | CallOptions | Callback< @@ -902,7 +902,7 @@ export class WorkflowsClient { >; } listWorkflows( - request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, options?: CallOptions ): Promise< [ @@ -973,7 +973,7 @@ export class WorkflowsClient { * for more details and examples. */ listWorkflows( - request: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, + request?: protos.google.cloud.workflows.v1beta.IListWorkflowsRequest, optionsOrCallback?: | CallOptions | PaginationCallback<