diff --git a/Workflows/metadata/V1/Workflows.php b/Workflows/metadata/V1/Workflows.php index 1b7c9b31db7d..69a34d200c3b 100644 Binary files a/Workflows/metadata/V1/Workflows.php and b/Workflows/metadata/V1/Workflows.php differ diff --git a/Workflows/samples/V1/WorkflowsClient/create_workflow.php b/Workflows/samples/V1/WorkflowsClient/create_workflow.php index a0b8b09183f0..f24d7ea3d11d 100644 --- a/Workflows/samples/V1/WorkflowsClient/create_workflow.php +++ b/Workflows/samples/V1/WorkflowsClient/create_workflow.php @@ -33,7 +33,7 @@ /** * 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. + * returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * * @param string $formattedParent Project and location in which the workflow should be created. * Format: projects/{project}/locations/{location} diff --git a/Workflows/samples/V1/WorkflowsClient/get_location.php b/Workflows/samples/V1/WorkflowsClient/get_location.php new file mode 100644 index 000000000000..6080669fa709 --- /dev/null +++ b/Workflows/samples/V1/WorkflowsClient/get_location.php @@ -0,0 +1,57 @@ +getLocation($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END workflows_v1_generated_Workflows_GetLocation_sync] diff --git a/Workflows/samples/V1/WorkflowsClient/get_workflow.php b/Workflows/samples/V1/WorkflowsClient/get_workflow.php index 5581ac35b162..64742ab2b7a9 100644 --- a/Workflows/samples/V1/WorkflowsClient/get_workflow.php +++ b/Workflows/samples/V1/WorkflowsClient/get_workflow.php @@ -29,9 +29,9 @@ use Google\Cloud\Workflows\V1\Workflow; /** - * Gets details of a single Workflow. + * Gets details of a single workflow. * - * @param string $formattedName Name of the workflow which information should be retrieved. + * @param string $formattedName Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} * Please see {@see WorkflowsClient::workflowName()} for help formatting this field. */ diff --git a/Workflows/samples/V1/WorkflowsClient/list_locations.php b/Workflows/samples/V1/WorkflowsClient/list_locations.php new file mode 100644 index 000000000000..72d2c6aa8c5e --- /dev/null +++ b/Workflows/samples/V1/WorkflowsClient/list_locations.php @@ -0,0 +1,62 @@ +listLocations($request); + + /** @var Location $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END workflows_v1_generated_Workflows_ListLocations_sync] diff --git a/Workflows/samples/V1/WorkflowsClient/list_workflows.php b/Workflows/samples/V1/WorkflowsClient/list_workflows.php index d7b273fec6e5..9c1267dd7883 100644 --- a/Workflows/samples/V1/WorkflowsClient/list_workflows.php +++ b/Workflows/samples/V1/WorkflowsClient/list_workflows.php @@ -30,7 +30,7 @@ use Google\Cloud\Workflows\V1\Workflow; /** - * Lists Workflows in a given project and location. + * Lists workflows in a given project and location. * The default order is not specified. * * @param string $formattedParent Project and location from which the workflows should be listed. diff --git a/Workflows/samples/V1/WorkflowsClient/update_workflow.php b/Workflows/samples/V1/WorkflowsClient/update_workflow.php index 58597c6f10b7..69de724a7404 100644 --- a/Workflows/samples/V1/WorkflowsClient/update_workflow.php +++ b/Workflows/samples/V1/WorkflowsClient/update_workflow.php @@ -33,8 +33,8 @@ /** * 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 + * workflow. A new revision of the workflow might be created as a result of a + * successful update operation. In that case, the new revision is used * in new workflow executions. * * This sample has been automatically generated and should be regarded as a code diff --git a/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php b/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php index 3c8aa0279ba5..0a3f2525cbca 100644 --- a/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php +++ b/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php @@ -35,6 +35,9 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; use Google\Cloud\Workflows\V1\CreateWorkflowRequest; use Google\Cloud\Workflows\V1\DeleteWorkflowRequest; use Google\Cloud\Workflows\V1\GetWorkflowRequest; @@ -68,6 +71,8 @@ * @method PromiseInterface getWorkflowAsync(GetWorkflowRequest $request, array $optionalArgs = []) * @method PromiseInterface listWorkflowsAsync(ListWorkflowsRequest $request, array $optionalArgs = []) * @method PromiseInterface updateWorkflowAsync(UpdateWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ abstract class WorkflowsBaseClient { @@ -141,6 +146,27 @@ public function resumeOperation($operationName, $methodName = null) return $operation; } + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'keyRing' => $keyRing, + 'cryptoKey' => $cryptoKey, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a location * resource. @@ -181,6 +207,7 @@ public static function workflowName(string $project, string $location, string $w * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} * - location: projects/{project}/locations/{location} * - workflow: projects/{project}/locations/{location}/workflows/{workflow} * @@ -277,7 +304,7 @@ public function __call($method, $args) /** * 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. + * returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * * The async variant is {@see self::createWorkflowAsync()} . * @@ -331,7 +358,7 @@ public function deleteWorkflow(DeleteWorkflowRequest $request, array $callOption } /** - * Gets details of a single Workflow. + * Gets details of a single workflow. * * The async variant is {@see self::getWorkflowAsync()} . * @@ -357,7 +384,7 @@ public function getWorkflow(GetWorkflowRequest $request, array $callOptions = [] } /** - * Lists Workflows in a given project and location. + * Lists workflows in a given project and location. * The default order is not specified. * * The async variant is {@see self::listWorkflowsAsync()} . @@ -386,8 +413,8 @@ public function listWorkflows(ListWorkflowsRequest $request, array $callOptions /** * 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 + * workflow. A new revision of the workflow might be created as a result of a + * successful update operation. In that case, the new revision is used * in new workflow executions. * * The async variant is {@see self::updateWorkflowAsync()} . @@ -412,4 +439,56 @@ public function updateWorkflow(UpdateWorkflowRequest $request, array $callOption { return $this->startApiCall('UpdateWorkflow', $request, $callOptions)->wait(); } + + /** + * Gets information about a location. + * + * The async variant is {@see self::getLocationAsync()} . + * + * @example samples/V1/WorkflowsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see self::listLocationsAsync()} . + * + * @example samples/V1/WorkflowsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Workflows/src/V1/GetWorkflowRequest.php b/Workflows/src/V1/GetWorkflowRequest.php index b753ea85c1eb..a0fdb618e342 100644 --- a/Workflows/src/V1/GetWorkflowRequest.php +++ b/Workflows/src/V1/GetWorkflowRequest.php @@ -17,15 +17,25 @@ class GetWorkflowRequest extends \Google\Protobuf\Internal\Message { /** - * Required. Name of the workflow which information should be retrieved. + * Required. Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $name = ''; + /** + * Optional. The revision of the workflow to retrieve. If the revision_id is + * empty, the latest revision is retrieved. + * The format is "000001-a4d", where the first six characters define + * the zero-padded decimal revision number. They are followed by a hyphen and + * three hexadecimal characters. + * + * Generated from protobuf field string revision_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $revision_id = ''; /** - * @param string $name Required. Name of the workflow which information should be retrieved. + * @param string $name Required. Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} * Please see {@see WorkflowsClient::workflowName()} for help formatting this field. * @@ -46,8 +56,14 @@ public static function build(string $name): self * Optional. Data for populating the Message object. * * @type string $name - * Required. Name of the workflow which information should be retrieved. + * Required. Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} + * @type string $revision_id + * Optional. The revision of the workflow to retrieve. If the revision_id is + * empty, the latest revision is retrieved. + * The format is "000001-a4d", where the first six characters define + * the zero-padded decimal revision number. They are followed by a hyphen and + * three hexadecimal characters. * } */ public function __construct($data = NULL) { @@ -56,7 +72,7 @@ public function __construct($data = NULL) { } /** - * Required. Name of the workflow which information should be retrieved. + * Required. Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -68,7 +84,7 @@ public function getName() } /** - * Required. Name of the workflow which information should be retrieved. + * Required. Name of the workflow for which information should be retrieved. * Format: projects/{project}/locations/{location}/workflows/{workflow} * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -83,5 +99,39 @@ public function setName($var) return $this; } + /** + * Optional. The revision of the workflow to retrieve. If the revision_id is + * empty, the latest revision is retrieved. + * The format is "000001-a4d", where the first six characters define + * the zero-padded decimal revision number. They are followed by a hyphen and + * three hexadecimal characters. + * + * Generated from protobuf field string revision_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getRevisionId() + { + return $this->revision_id; + } + + /** + * Optional. The revision of the workflow to retrieve. If the revision_id is + * empty, the latest revision is retrieved. + * The format is "000001-a4d", where the first six characters define + * the zero-padded decimal revision number. They are followed by a hyphen and + * three hexadecimal characters. + * + * Generated from protobuf field string revision_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setRevisionId($var) + { + GPBUtil::checkString($var, True); + $this->revision_id = $var; + + return $this; + } + } diff --git a/Workflows/src/V1/ListWorkflowsRequest.php b/Workflows/src/V1/ListWorkflowsRequest.php index 046a79a70120..810d2ea51231 100644 --- a/Workflows/src/V1/ListWorkflowsRequest.php +++ b/Workflows/src/V1/ListWorkflowsRequest.php @@ -25,10 +25,10 @@ class ListWorkflowsRequest extends \Google\Protobuf\Internal\Message */ private $parent = ''; /** - * 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. + * Maximum number of workflows to return per call. The service might return + * fewer than this value even if not at the end of the collection. If a value + * is not specified, a default value of 500 is used. The maximum permitted + * value is 1000 and values greater than 1000 are coerced down to 1000. * * Generated from protobuf field int32 page_size = 2; */ @@ -49,10 +49,10 @@ class ListWorkflowsRequest extends \Google\Protobuf\Internal\Message */ private $filter = ''; /** - * Comma-separated list of fields that that specify the order of the results. + * Comma-separated list of fields 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. + * for a field, append a "desc" suffix. + * If not specified, the results are returned in an unspecified order. * * Generated from protobuf field string order_by = 5; */ @@ -83,10 +83,10 @@ public static function build(string $parent): self * Required. Project and location from which the workflows should be listed. * Format: projects/{project}/locations/{location} * @type int $page_size - * 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. + * Maximum number of workflows to return per call. The service might return + * fewer than this value even if not at the end of the collection. If a value + * is not specified, a default value of 500 is used. The maximum permitted + * value is 1000 and values greater than 1000 are coerced down to 1000. * @type string $page_token * A page token, received from a previous `ListWorkflows` call. * Provide this to retrieve the subsequent page. @@ -95,10 +95,10 @@ public static function build(string $parent): self * @type string $filter * Filter to restrict results to specific workflows. * @type string $order_by - * Comma-separated list of fields that that specify the order of the results. + * Comma-separated list of fields 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. + * for a field, append a "desc" suffix. + * If not specified, the results are returned in an unspecified order. * } */ public function __construct($data = NULL) { @@ -135,10 +135,10 @@ public function setParent($var) } /** - * 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. + * Maximum number of workflows to return per call. The service might return + * fewer than this value even if not at the end of the collection. If a value + * is not specified, a default value of 500 is used. The maximum permitted + * value is 1000 and values greater than 1000 are coerced down to 1000. * * Generated from protobuf field int32 page_size = 2; * @return int @@ -149,10 +149,10 @@ public function getPageSize() } /** - * 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. + * Maximum number of workflows to return per call. The service might return + * fewer than this value even if not at the end of the collection. If a value + * is not specified, a default value of 500 is used. The maximum permitted + * value is 1000 and values greater than 1000 are coerced down to 1000. * * Generated from protobuf field int32 page_size = 2; * @param int $var @@ -225,10 +225,10 @@ public function setFilter($var) } /** - * Comma-separated list of fields that that specify the order of the results. + * Comma-separated list of fields 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. + * for a field, append a "desc" suffix. + * If not specified, the results are returned in an unspecified order. * * Generated from protobuf field string order_by = 5; * @return string @@ -239,10 +239,10 @@ public function getOrderBy() } /** - * Comma-separated list of fields that that specify the order of the results. + * Comma-separated list of fields 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. + * for a field, append a "desc" suffix. + * If not specified, the results are returned in an unspecified order. * * Generated from protobuf field string order_by = 5; * @param string $var diff --git a/Workflows/src/V1/ListWorkflowsResponse.php b/Workflows/src/V1/ListWorkflowsResponse.php index 434b32999503..cea619e3ad18 100644 --- a/Workflows/src/V1/ListWorkflowsResponse.php +++ b/Workflows/src/V1/ListWorkflowsResponse.php @@ -18,7 +18,7 @@ class ListWorkflowsResponse extends \Google\Protobuf\Internal\Message { /** - * The workflows which match the request. + * The workflows that match the request. * * Generated from protobuf field repeated .google.cloud.workflows.v1.Workflow workflows = 1; */ @@ -44,7 +44,7 @@ class ListWorkflowsResponse extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type array<\Google\Cloud\Workflows\V1\Workflow>|\Google\Protobuf\Internal\RepeatedField $workflows - * The workflows which match the request. + * The workflows that match the request. * @type string $next_page_token * A token, which can be sent as `page_token` to retrieve the next page. * If this field is omitted, there are no subsequent pages. @@ -58,7 +58,7 @@ public function __construct($data = NULL) { } /** - * The workflows which match the request. + * The workflows that match the request. * * Generated from protobuf field repeated .google.cloud.workflows.v1.Workflow workflows = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -69,7 +69,7 @@ public function getWorkflows() } /** - * The workflows which match the request. + * The workflows that match the request. * * Generated from protobuf field repeated .google.cloud.workflows.v1.Workflow workflows = 1; * @param array<\Google\Cloud\Workflows\V1\Workflow>|\Google\Protobuf\Internal\RepeatedField $var diff --git a/Workflows/src/V1/Workflow.php b/Workflows/src/V1/Workflow.php index 549a42c38467..b18e4d69f959 100644 --- a/Workflows/src/V1/Workflow.php +++ b/Workflows/src/V1/Workflow.php @@ -40,29 +40,30 @@ class Workflow extends \Google\Protobuf\Internal\Message * A new revision of a workflow is created as a result of updating the * following properties of a workflow: * - [Service account][google.cloud.workflows.v1.Workflow.service_account] - * - [Workflow code to be executed][google.cloud.workflows.v1.Workflow.source_contents] - * The format is "000001-a4d", where the first 6 characters define + * - [Workflow code to be + * executed][google.cloud.workflows.v1.Workflow.source_contents] + * The format is "000001-a4d", where the first six characters define * the zero-padded revision ordinal number. They are followed by a hyphen and - * 3 hexadecimal random characters. + * three hexadecimal random characters. * * Generated from protobuf field string revision_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $revision_id = ''; /** - * Output only. The timestamp of when the workflow was created. + * Output only. The timestamp for when the workflow was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $create_time = null; /** - * Output only. The last update timestamp of the workflow. + * Output only. The timestamp for when the workflow was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $update_time = null; /** - * Output only. The timestamp that the latest revision of the workflow - * was created. + * Output only. The timestamp for the latest revision of the workflow's + * creation. * * Generated from protobuf field .google.protobuf.Timestamp revision_create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -71,7 +72,7 @@ class Workflow extends \Google\Protobuf\Internal\Message * 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. + * characters, underscores, and dashes. Label keys must start with a letter. * International characters are allowed. * * Generated from protobuf field map labels = 8; @@ -92,6 +93,45 @@ class Workflow extends \Google\Protobuf\Internal\Message * Generated from protobuf field string service_account = 9; */ private $service_account = ''; + /** + * Optional. The resource name of a KMS crypto key used to encrypt or decrypt + * the data associated with the workflow. + * Format: + * projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} + * Using `-` as a wildcard for the `{project}` or not providing one at all + * will infer the project from the account. + * If not provided, data associated with the workflow will not be + * CMEK-encrypted. + * + * Generated from protobuf field string crypto_key_name = 11 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $crypto_key_name = ''; + /** + * Output only. Error regarding the state of the workflow. For example, this + * field will have error details if the execution data is unavailable due to + * revoked KMS key permissions. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError state_error = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $state_error = null; + /** + * Optional. Describes the level of platform logging to apply to calls and + * call responses during executions of this workflow. If both the workflow and + * the execution specify a logging level, the execution level takes + * precedence. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.CallLogLevel call_log_level = 13 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $call_log_level = 0; + /** + * Optional. User-defined environment variables associated with this workflow + * revision. This map has a maximum length of 20. Each string can take up to + * 40KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or + * “WORKFLOWS". + * + * Generated from protobuf field map user_env_vars = 14 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $user_env_vars; protected $source_code; /** @@ -113,22 +153,23 @@ class Workflow extends \Google\Protobuf\Internal\Message * A new revision of a workflow is created as a result of updating the * following properties of a workflow: * - [Service account][google.cloud.workflows.v1.Workflow.service_account] - * - [Workflow code to be executed][google.cloud.workflows.v1.Workflow.source_contents] - * The format is "000001-a4d", where the first 6 characters define + * - [Workflow code to be + * executed][google.cloud.workflows.v1.Workflow.source_contents] + * The format is "000001-a4d", where the first six characters define * the zero-padded revision ordinal number. They are followed by a hyphen and - * 3 hexadecimal random characters. + * three hexadecimal random characters. * @type \Google\Protobuf\Timestamp $create_time - * Output only. The timestamp of when the workflow was created. + * Output only. The timestamp for when the workflow was created. * @type \Google\Protobuf\Timestamp $update_time - * Output only. The last update timestamp of the workflow. + * Output only. The timestamp for when the workflow was last updated. * @type \Google\Protobuf\Timestamp $revision_create_time - * Output only. The timestamp that the latest revision of the workflow - * was created. + * Output only. The timestamp for the latest revision of the workflow's + * creation. * @type array|\Google\Protobuf\Internal\MapField $labels * 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. + * characters, underscores, and dashes. Label keys must start with a letter. * International characters are allowed. * @type string $service_account * The service account associated with the latest workflow version. @@ -143,6 +184,29 @@ class Workflow extends \Google\Protobuf\Internal\Message * revision. * @type string $source_contents * Workflow code to be executed. The size limit is 128KB. + * @type string $crypto_key_name + * Optional. The resource name of a KMS crypto key used to encrypt or decrypt + * the data associated with the workflow. + * Format: + * projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} + * Using `-` as a wildcard for the `{project}` or not providing one at all + * will infer the project from the account. + * If not provided, data associated with the workflow will not be + * CMEK-encrypted. + * @type \Google\Cloud\Workflows\V1\Workflow\StateError $state_error + * Output only. Error regarding the state of the workflow. For example, this + * field will have error details if the execution data is unavailable due to + * revoked KMS key permissions. + * @type int $call_log_level + * Optional. Describes the level of platform logging to apply to calls and + * call responses during executions of this workflow. If both the workflow and + * the execution specify a logging level, the execution level takes + * precedence. + * @type array|\Google\Protobuf\Internal\MapField $user_env_vars + * Optional. User-defined environment variables associated with this workflow + * revision. This map has a maximum length of 20. Each string can take up to + * 40KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or + * “WORKFLOWS". * } */ public function __construct($data = NULL) { @@ -237,10 +301,11 @@ public function setState($var) * A new revision of a workflow is created as a result of updating the * following properties of a workflow: * - [Service account][google.cloud.workflows.v1.Workflow.service_account] - * - [Workflow code to be executed][google.cloud.workflows.v1.Workflow.source_contents] - * The format is "000001-a4d", where the first 6 characters define + * - [Workflow code to be + * executed][google.cloud.workflows.v1.Workflow.source_contents] + * The format is "000001-a4d", where the first six characters define * the zero-padded revision ordinal number. They are followed by a hyphen and - * 3 hexadecimal random characters. + * three hexadecimal random characters. * * Generated from protobuf field string revision_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string @@ -255,10 +320,11 @@ public function getRevisionId() * A new revision of a workflow is created as a result of updating the * following properties of a workflow: * - [Service account][google.cloud.workflows.v1.Workflow.service_account] - * - [Workflow code to be executed][google.cloud.workflows.v1.Workflow.source_contents] - * The format is "000001-a4d", where the first 6 characters define + * - [Workflow code to be + * executed][google.cloud.workflows.v1.Workflow.source_contents] + * The format is "000001-a4d", where the first six characters define * the zero-padded revision ordinal number. They are followed by a hyphen and - * 3 hexadecimal random characters. + * three hexadecimal random characters. * * Generated from protobuf field string revision_id = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var @@ -273,7 +339,7 @@ public function setRevisionId($var) } /** - * Output only. The timestamp of when the workflow was created. + * Output only. The timestamp for when the workflow was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -294,7 +360,7 @@ public function clearCreateTime() } /** - * Output only. The timestamp of when the workflow was created. + * Output only. The timestamp for when the workflow was created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var @@ -309,7 +375,7 @@ public function setCreateTime($var) } /** - * Output only. The last update timestamp of the workflow. + * Output only. The timestamp for when the workflow was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -330,7 +396,7 @@ public function clearUpdateTime() } /** - * Output only. The last update timestamp of the workflow. + * Output only. The timestamp for when the workflow was last updated. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var @@ -345,8 +411,8 @@ public function setUpdateTime($var) } /** - * Output only. The timestamp that the latest revision of the workflow - * was created. + * Output only. The timestamp for the latest revision of the workflow's + * creation. * * Generated from protobuf field .google.protobuf.Timestamp revision_create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -367,8 +433,8 @@ public function clearRevisionCreateTime() } /** - * Output only. The timestamp that the latest revision of the workflow - * was created. + * Output only. The timestamp for the latest revision of the workflow's + * creation. * * Generated from protobuf field .google.protobuf.Timestamp revision_create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var @@ -386,7 +452,7 @@ public function setRevisionCreateTime($var) * 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. + * characters, underscores, and dashes. Label keys must start with a letter. * International characters are allowed. * * Generated from protobuf field map labels = 8; @@ -401,7 +467,7 @@ public function getLabels() * 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. + * characters, underscores, and dashes. Label keys must start with a letter. * International characters are allowed. * * Generated from protobuf field map labels = 8; @@ -491,6 +557,150 @@ public function setSourceContents($var) return $this; } + /** + * Optional. The resource name of a KMS crypto key used to encrypt or decrypt + * the data associated with the workflow. + * Format: + * projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} + * Using `-` as a wildcard for the `{project}` or not providing one at all + * will infer the project from the account. + * If not provided, data associated with the workflow will not be + * CMEK-encrypted. + * + * Generated from protobuf field string crypto_key_name = 11 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return string + */ + public function getCryptoKeyName() + { + return $this->crypto_key_name; + } + + /** + * Optional. The resource name of a KMS crypto key used to encrypt or decrypt + * the data associated with the workflow. + * Format: + * projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} + * Using `-` as a wildcard for the `{project}` or not providing one at all + * will infer the project from the account. + * If not provided, data associated with the workflow will not be + * CMEK-encrypted. + * + * Generated from protobuf field string crypto_key_name = 11 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setCryptoKeyName($var) + { + GPBUtil::checkString($var, True); + $this->crypto_key_name = $var; + + return $this; + } + + /** + * Output only. Error regarding the state of the workflow. For example, this + * field will have error details if the execution data is unavailable due to + * revoked KMS key permissions. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError state_error = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Workflows\V1\Workflow\StateError|null + */ + public function getStateError() + { + return $this->state_error; + } + + public function hasStateError() + { + return isset($this->state_error); + } + + public function clearStateError() + { + unset($this->state_error); + } + + /** + * Output only. Error regarding the state of the workflow. For example, this + * field will have error details if the execution data is unavailable due to + * revoked KMS key permissions. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError state_error = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Workflows\V1\Workflow\StateError $var + * @return $this + */ + public function setStateError($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Workflows\V1\Workflow\StateError::class); + $this->state_error = $var; + + return $this; + } + + /** + * Optional. Describes the level of platform logging to apply to calls and + * call responses during executions of this workflow. If both the workflow and + * the execution specify a logging level, the execution level takes + * precedence. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.CallLogLevel call_log_level = 13 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getCallLogLevel() + { + return $this->call_log_level; + } + + /** + * Optional. Describes the level of platform logging to apply to calls and + * call responses during executions of this workflow. If both the workflow and + * the execution specify a logging level, the execution level takes + * precedence. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.CallLogLevel call_log_level = 13 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setCallLogLevel($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Workflows\V1\Workflow\CallLogLevel::class); + $this->call_log_level = $var; + + return $this; + } + + /** + * Optional. User-defined environment variables associated with this workflow + * revision. This map has a maximum length of 20. Each string can take up to + * 40KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or + * “WORKFLOWS". + * + * Generated from protobuf field map user_env_vars = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\MapField + */ + public function getUserEnvVars() + { + return $this->user_env_vars; + } + + /** + * Optional. User-defined environment variables associated with this workflow + * revision. This map has a maximum length of 20. Each string can take up to + * 40KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or + * “WORKFLOWS". + * + * Generated from protobuf field map user_env_vars = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setUserEnvVars($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->user_env_vars = $arr; + + return $this; + } + /** * @return string */ diff --git a/Workflows/src/V1/Workflow/CallLogLevel.php b/Workflows/src/V1/Workflow/CallLogLevel.php new file mode 100644 index 000000000000..6499a6acb148 --- /dev/null +++ b/Workflows/src/V1/Workflow/CallLogLevel.php @@ -0,0 +1,71 @@ +google.cloud.workflows.v1.Workflow.CallLogLevel + */ +class CallLogLevel +{ + /** + * No call logging level specified. + * + * Generated from protobuf enum CALL_LOG_LEVEL_UNSPECIFIED = 0; + */ + const CALL_LOG_LEVEL_UNSPECIFIED = 0; + /** + * Log all call steps within workflows, all call returns, and all exceptions + * raised. + * + * Generated from protobuf enum LOG_ALL_CALLS = 1; + */ + const LOG_ALL_CALLS = 1; + /** + * Log only exceptions that are raised from call steps within workflows. + * + * Generated from protobuf enum LOG_ERRORS_ONLY = 2; + */ + const LOG_ERRORS_ONLY = 2; + /** + * Explicitly log nothing. + * + * Generated from protobuf enum LOG_NONE = 3; + */ + const LOG_NONE = 3; + + private static $valueToName = [ + self::CALL_LOG_LEVEL_UNSPECIFIED => 'CALL_LOG_LEVEL_UNSPECIFIED', + self::LOG_ALL_CALLS => 'LOG_ALL_CALLS', + self::LOG_ERRORS_ONLY => 'LOG_ERRORS_ONLY', + self::LOG_NONE => 'LOG_NONE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Workflows/src/V1/Workflow/State.php b/Workflows/src/V1/Workflow/State.php index 6cf2a24430e2..892fe268d856 100644 --- a/Workflows/src/V1/Workflow/State.php +++ b/Workflows/src/V1/Workflow/State.php @@ -7,8 +7,7 @@ use UnexpectedValueException; /** - * Describes the current state of workflow deployment. More states may be - * added in the future. + * Describes the current state of workflow deployment. * * Protobuf type google.cloud.workflows.v1.Workflow.State */ @@ -26,10 +25,17 @@ class State * Generated from protobuf enum ACTIVE = 1; */ const ACTIVE = 1; + /** + * Workflow data is unavailable. See the `state_error` field. + * + * Generated from protobuf enum UNAVAILABLE = 2; + */ + const UNAVAILABLE = 2; private static $valueToName = [ self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', self::ACTIVE => 'ACTIVE', + self::UNAVAILABLE => 'UNAVAILABLE', ]; public static function name($value) diff --git a/Workflows/src/V1/Workflow/StateError.php b/Workflows/src/V1/Workflow/StateError.php new file mode 100644 index 000000000000..f2cc3fdbf788 --- /dev/null +++ b/Workflows/src/V1/Workflow/StateError.php @@ -0,0 +1,102 @@ +google.cloud.workflows.v1.Workflow.StateError + */ +class StateError extends \Google\Protobuf\Internal\Message +{ + /** + * Provides specifics about the error. + * + * Generated from protobuf field string details = 1; + */ + private $details = ''; + /** + * The type of this state error. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError.Type type = 2; + */ + private $type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $details + * Provides specifics about the error. + * @type int $type + * The type of this state error. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Workflows\V1\Workflows::initOnce(); + parent::__construct($data); + } + + /** + * Provides specifics about the error. + * + * Generated from protobuf field string details = 1; + * @return string + */ + public function getDetails() + { + return $this->details; + } + + /** + * Provides specifics about the error. + * + * Generated from protobuf field string details = 1; + * @param string $var + * @return $this + */ + public function setDetails($var) + { + GPBUtil::checkString($var, True); + $this->details = $var; + + return $this; + } + + /** + * The type of this state error. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError.Type type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * The type of this state error. + * + * Generated from protobuf field .google.cloud.workflows.v1.Workflow.StateError.Type type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Workflows\V1\Workflow\StateError\Type::class); + $this->type = $var; + + return $this; + } + +} + + diff --git a/Workflows/src/V1/Workflow/StateError/Type.php b/Workflows/src/V1/Workflow/StateError/Type.php new file mode 100644 index 000000000000..6dd581320b4b --- /dev/null +++ b/Workflows/src/V1/Workflow/StateError/Type.php @@ -0,0 +1,55 @@ +google.cloud.workflows.v1.Workflow.StateError.Type + */ +class Type +{ + /** + * No type specified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Caused by an issue with KMS. + * + * Generated from protobuf enum KMS_ERROR = 1; + */ + const KMS_ERROR = 1; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::KMS_ERROR => 'KMS_ERROR', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Workflows/src/V1/gapic_metadata.json b/Workflows/src/V1/gapic_metadata.json index 3950c517ecb8..01b0ddf71a12 100644 --- a/Workflows/src/V1/gapic_metadata.json +++ b/Workflows/src/V1/gapic_metadata.json @@ -34,6 +34,16 @@ "methods": [ "updateWorkflow" ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] } } } diff --git a/Workflows/src/V1/resources/workflows_client_config.json b/Workflows/src/V1/resources/workflows_client_config.json index bc6e91da052e..cceb37628336 100644 --- a/Workflows/src/V1/resources/workflows_client_config.json +++ b/Workflows/src/V1/resources/workflows_client_config.json @@ -40,6 +40,16 @@ "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" + }, + "GetLocation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListLocations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" } } } diff --git a/Workflows/src/V1/resources/workflows_descriptor_config.php b/Workflows/src/V1/resources/workflows_descriptor_config.php index 8f7f762476bb..c4b42c207514 100644 --- a/Workflows/src/V1/resources/workflows_descriptor_config.php +++ b/Workflows/src/V1/resources/workflows_descriptor_config.php @@ -93,7 +93,42 @@ ], ], ], + 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'ListLocations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLocations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], 'templateMap' => [ + 'cryptoKey' => 'projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}', 'location' => 'projects/{project}/locations/{location}', 'workflow' => 'projects/{project}/locations/{location}/workflows/{workflow}', ], diff --git a/Workflows/tests/Unit/V1/Client/WorkflowsClientTest.php b/Workflows/tests/Unit/V1/Client/WorkflowsClientTest.php index 50e00357dd57..2171345be81d 100644 --- a/Workflows/tests/Unit/V1/Client/WorkflowsClientTest.php +++ b/Workflows/tests/Unit/V1/Client/WorkflowsClientTest.php @@ -27,6 +27,10 @@ use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\ListLocationsResponse; +use Google\Cloud\Location\Location; use Google\Cloud\Workflows\V1\Client\WorkflowsClient; use Google\Cloud\Workflows\V1\CreateWorkflowRequest; use Google\Cloud\Workflows\V1\DeleteWorkflowRequest; @@ -96,12 +100,14 @@ public function createWorkflowTest() $revisionId = 'revisionId513861631'; $serviceAccount = 'serviceAccount-1948028253'; $sourceContents = 'sourceContents-1799875906'; + $cryptoKeyName = 'cryptoKeyName-184663511'; $expectedResponse = new Workflow(); $expectedResponse->setName($name); $expectedResponse->setDescription($description); $expectedResponse->setRevisionId($revisionId); $expectedResponse->setServiceAccount($serviceAccount); $expectedResponse->setSourceContents($sourceContents); + $expectedResponse->setCryptoKeyName($cryptoKeyName); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -345,15 +351,17 @@ public function getWorkflowTest() // Mock response $name2 = 'name2-1052831874'; $description = 'description-1724546052'; - $revisionId = 'revisionId513861631'; + $revisionId2 = 'revisionId2-100208654'; $serviceAccount = 'serviceAccount-1948028253'; $sourceContents = 'sourceContents-1799875906'; + $cryptoKeyName = 'cryptoKeyName-184663511'; $expectedResponse = new Workflow(); $expectedResponse->setName($name2); $expectedResponse->setDescription($description); - $expectedResponse->setRevisionId($revisionId); + $expectedResponse->setRevisionId($revisionId2); $expectedResponse->setServiceAccount($serviceAccount); $expectedResponse->setSourceContents($sourceContents); + $expectedResponse->setCryptoKeyName($cryptoKeyName); $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->workflowName('[PROJECT]', '[LOCATION]', '[WORKFLOW]'); @@ -504,12 +512,14 @@ public function updateWorkflowTest() $revisionId = 'revisionId513861631'; $serviceAccount = 'serviceAccount-1948028253'; $sourceContents = 'sourceContents-1799875906'; + $cryptoKeyName = 'cryptoKeyName-184663511'; $expectedResponse = new Workflow(); $expectedResponse->setName($name); $expectedResponse->setDescription($description); $expectedResponse->setRevisionId($revisionId); $expectedResponse->setServiceAccount($serviceAccount); $expectedResponse->setSourceContents($sourceContents); + $expectedResponse->setCryptoKeyName($cryptoKeyName); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -609,6 +619,130 @@ public function updateWorkflowExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function getLocationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $locationId = 'locationId552319461'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Location(); + $expectedResponse->setName($name2); + $expectedResponse->setLocationId($locationId); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + $request = new GetLocationRequest(); + try { + $gapicClient->getLocation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $locationsElement = new Location(); + $locations = [ + $locationsElement, + ]; + $expectedResponse = new ListLocationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocations($locations); + $transport->addResponse($expectedResponse); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); + try { + $gapicClient->listLocations($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function createWorkflowAsyncTest() { @@ -635,12 +769,14 @@ public function createWorkflowAsyncTest() $revisionId = 'revisionId513861631'; $serviceAccount = 'serviceAccount-1948028253'; $sourceContents = 'sourceContents-1799875906'; + $cryptoKeyName = 'cryptoKeyName-184663511'; $expectedResponse = new Workflow(); $expectedResponse->setName($name); $expectedResponse->setDescription($description); $expectedResponse->setRevisionId($revisionId); $expectedResponse->setServiceAccount($serviceAccount); $expectedResponse->setSourceContents($sourceContents); + $expectedResponse->setCryptoKeyName($cryptoKeyName); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation();