diff --git a/LifeSciences/owlbot.py b/LifeSciences/owlbot.py index c23e85728675..2c42d19dd481 100644 --- a/LifeSciences/owlbot.py +++ b/LifeSciences/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,34 +32,25 @@ php.owlbot_main(src=src, dest=dest) -# Change the wording for the deprecation warning. +# remove class_alias code s.replace( - 'src/*/*_*.php', - r'will be removed in the next major release', - 'will be removed in a future release') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') + +# format generated clients +subprocess.run([ + 'npm', + 'exec', + '--yes', + '--package=@prettier/plugin-php@^0.16', + '--', + 'prettier', + '**/Client/*', + '--write', + '--parser=php', + '--single-quote', + '--print-width=120']) diff --git a/LifeSciences/src/V2beta/Accelerator.php b/LifeSciences/src/V2beta/Accelerator.php index f990044b83c4..8c0183794ffe 100644 --- a/LifeSciences/src/V2beta/Accelerator.php +++ b/LifeSciences/src/V2beta/Accelerator.php @@ -26,13 +26,13 @@ class Accelerator extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type = 1; */ - private $type = ''; + protected $type = ''; /** * How many accelerators of this type to attach. * * Generated from protobuf field int64 count = 2; */ - private $count = 0; + protected $count = 0; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Action.php b/LifeSciences/src/V2beta/Action.php index 7d57f5bdea46..60946413bcf1 100644 --- a/LifeSciences/src/V2beta/Action.php +++ b/LifeSciences/src/V2beta/Action.php @@ -23,7 +23,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string container_name = 1; */ - private $container_name = ''; + protected $container_name = ''; /** * Required. The URI to pull the container image from. Note that all images * referenced by actions in the pipeline are pulled before the first action @@ -41,7 +41,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string image_uri = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $image_uri = ''; + protected $image_uri = ''; /** * If specified, overrides the `CMD` specified in the container. If the * container also has an `ENTRYPOINT` the values are used as entrypoint @@ -56,7 +56,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string entrypoint = 4; */ - private $entrypoint = ''; + protected $entrypoint = ''; /** * The environment to pass into the container. This environment is merged * with values specified in the @@ -88,7 +88,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Secret encrypted_environment = 21; */ - private $encrypted_environment = null; + protected $encrypted_environment = null; /** * An optional identifier for a PID namespace to run the action inside. * Multiple actions should use the same string to share a namespace. If @@ -96,7 +96,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pid_namespace = 6; */ - private $pid_namespace = ''; + protected $pid_namespace = ''; /** * A map of containers to host port mappings for this container. If the * container already specifies exposed ports, use the @@ -146,7 +146,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Secret credentials = 11; */ - private $credentials = null; + protected $credentials = null; /** * The maximum amount of time to give the action to complete. If the action * fails to complete before the timeout, it will be terminated and the exit @@ -155,14 +155,14 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration timeout = 12; */ - private $timeout = null; + protected $timeout = null; /** * Normally, a non-zero exit status causes the pipeline to fail. This flag * allows execution of other actions to continue instead. * * Generated from protobuf field bool ignore_exit_status = 13; */ - private $ignore_exit_status = false; + protected $ignore_exit_status = false; /** * This flag allows an action to continue running in the background while * executing subsequent actions. This is useful to provide services to @@ -170,7 +170,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool run_in_background = 14; */ - private $run_in_background = false; + protected $run_in_background = false; /** * By default, after an action fails, no further actions are run. This flag * indicates that this action must be run even if the pipeline has already @@ -180,7 +180,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool always_run = 15; */ - private $always_run = false; + protected $always_run = false; /** * Enable access to the FUSE device for this action. Filesystems can then * be mounted into disks shared with other actions. The other actions do @@ -191,7 +191,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_fuse = 16; */ - private $enable_fuse = false; + protected $enable_fuse = false; /** * Exposes all ports specified by `EXPOSE` statements in the container. To * discover the host side port numbers, consult the `ACTION_STARTED` event @@ -199,7 +199,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool publish_exposed_ports = 17; */ - private $publish_exposed_ports = false; + protected $publish_exposed_ports = false; /** * All container images are typically downloaded before any actions are * executed. This helps prevent typos in URIs or issues like lack of disk @@ -209,7 +209,7 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool disable_image_prefetch = 18; */ - private $disable_image_prefetch = false; + protected $disable_image_prefetch = false; /** * A small portion of the container's standard error stream is typically * captured and returned inside the `ContainerStoppedEvent`. Setting this @@ -217,13 +217,13 @@ class Action extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool disable_standard_error_capture = 19; */ - private $disable_standard_error_capture = false; + protected $disable_standard_error_capture = false; /** * Prevents the container from accessing the external network. * * Generated from protobuf field bool block_external_network = 20; */ - private $block_external_network = false; + protected $block_external_network = false; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php b/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php index eb9346946c1b..ce401711e29c 100644 --- a/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php +++ b/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php @@ -1,6 +1,6 @@ [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/workflows_service_v2_beta_rest_client_config.php', ], ], ]; @@ -135,12 +133,33 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Constructor. * @@ -191,9 +210,6 @@ public function resumeOperation($operationName, $methodName = null) * @type callable $clientCertSource * A callable which returns the client cert as a string. This can be used to * provide a certificate and private key to the transport layer for mTLS. - * @type false|LoggerInterface $logger - * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the - * 'GOOGLE_SDK_PHP_LOGGING' environment flag * } * * @throws ValidationException diff --git a/LifeSciences/src/V2beta/ContainerKilledEvent.php b/LifeSciences/src/V2beta/ContainerKilledEvent.php index 5e7f61f40cde..cbaa3430b815 100644 --- a/LifeSciences/src/V2beta/ContainerKilledEvent.php +++ b/LifeSciences/src/V2beta/ContainerKilledEvent.php @@ -22,7 +22,7 @@ class ContainerKilledEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 action_id = 1; */ - private $action_id = 0; + protected $action_id = 0; /** * Constructor. diff --git a/LifeSciences/src/V2beta/ContainerStartedEvent.php b/LifeSciences/src/V2beta/ContainerStartedEvent.php index fdb97f3e518c..9fcce69db437 100644 --- a/LifeSciences/src/V2beta/ContainerStartedEvent.php +++ b/LifeSciences/src/V2beta/ContainerStartedEvent.php @@ -20,7 +20,7 @@ class ContainerStartedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 action_id = 1; */ - private $action_id = 0; + protected $action_id = 0; /** * The container-to-host port mappings installed for this container. This * set will contain any ports exposed using the `PUBLISH_EXPOSED_PORTS` flag @@ -37,7 +37,7 @@ class ContainerStartedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string ip_address = 3; */ - private $ip_address = ''; + protected $ip_address = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/ContainerStoppedEvent.php b/LifeSciences/src/V2beta/ContainerStoppedEvent.php index 2564a5d82a2a..faf44a387a52 100644 --- a/LifeSciences/src/V2beta/ContainerStoppedEvent.php +++ b/LifeSciences/src/V2beta/ContainerStoppedEvent.php @@ -20,13 +20,13 @@ class ContainerStoppedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 action_id = 1; */ - private $action_id = 0; + protected $action_id = 0; /** * The exit status of the container. * * Generated from protobuf field int32 exit_status = 2; */ - private $exit_status = 0; + protected $exit_status = 0; /** * The tail end of any content written to standard error by the container. * If the content emits large amounts of debugging noise or contains @@ -38,7 +38,7 @@ class ContainerStoppedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string stderr = 3; */ - private $stderr = ''; + protected $stderr = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/DelayedEvent.php b/LifeSciences/src/V2beta/DelayedEvent.php index c39bb2cc7a62..48021f37b2c7 100644 --- a/LifeSciences/src/V2beta/DelayedEvent.php +++ b/LifeSciences/src/V2beta/DelayedEvent.php @@ -23,7 +23,7 @@ class DelayedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cause = 1; */ - private $cause = ''; + protected $cause = ''; /** * If the delay was caused by a resource shortage, this field lists the * Compute Engine metrics that are preventing this operation from running diff --git a/LifeSciences/src/V2beta/Disk.php b/LifeSciences/src/V2beta/Disk.php index 57c7b3a04b14..9f92bf51df25 100644 --- a/LifeSciences/src/V2beta/Disk.php +++ b/LifeSciences/src/V2beta/Disk.php @@ -26,7 +26,7 @@ class Disk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The size, in GB, of the disk to attach. If the size is not * specified, a default is chosen to ensure reasonable I/O performance. @@ -37,19 +37,19 @@ class Disk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 size_gb = 2; */ - private $size_gb = 0; + protected $size_gb = 0; /** * The Compute Engine disk type. If unspecified, `pd-standard` is used. * * Generated from protobuf field string type = 3; */ - private $type = ''; + protected $type = ''; /** * An optional image to put on the disk before attaching it to the VM. * * Generated from protobuf field string source_image = 4; */ - private $source_image = ''; + protected $source_image = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Event.php b/LifeSciences/src/V2beta/Event.php index 90b3253d038a..3fd47e78473f 100644 --- a/LifeSciences/src/V2beta/Event.php +++ b/LifeSciences/src/V2beta/Event.php @@ -20,7 +20,7 @@ class Event extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp timestamp = 1; */ - private $timestamp = null; + protected $timestamp = null; /** * A human-readable description of the event. Note that these strings can * change at any time without notice. Any application logic must use the @@ -28,7 +28,7 @@ class Event extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; protected $details; /** diff --git a/LifeSciences/src/V2beta/ExistingDisk.php b/LifeSciences/src/V2beta/ExistingDisk.php index 87d8889570d0..31e65479b79b 100644 --- a/LifeSciences/src/V2beta/ExistingDisk.php +++ b/LifeSciences/src/V2beta/ExistingDisk.php @@ -28,7 +28,7 @@ class ExistingDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string disk = 1; */ - private $disk = ''; + protected $disk = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/FailedEvent.php b/LifeSciences/src/V2beta/FailedEvent.php index 536b3ba62497..c92baa2e6650 100644 --- a/LifeSciences/src/V2beta/FailedEvent.php +++ b/LifeSciences/src/V2beta/FailedEvent.php @@ -21,13 +21,13 @@ class FailedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.Code code = 1; */ - private $code = 0; + protected $code = 0; /** * The human-readable description of the cause of the failure. * * Generated from protobuf field string cause = 2; */ - private $cause = ''; + protected $cause = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Gapic/WorkflowsServiceV2BetaGapicClient.php b/LifeSciences/src/V2beta/Gapic/WorkflowsServiceV2BetaGapicClient.php deleted file mode 100644 index 96fa99521701..000000000000 --- a/LifeSciences/src/V2beta/Gapic/WorkflowsServiceV2BetaGapicClient.php +++ /dev/null @@ -1,471 +0,0 @@ -runPipeline($pipeline); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $workflowsServiceV2BetaClient->runPipeline($pipeline); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $workflowsServiceV2BetaClient->resumeOperation($operationName, 'runPipeline'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $workflowsServiceV2BetaClient->close(); - * } - * ``` - * - * @experimental - * - * @deprecated Please use the new service client {@see \Google\Cloud\LifeSciences\V2beta\Client\WorkflowsServiceV2BetaClient}. - */ -class WorkflowsServiceV2BetaGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'lifesciences.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'lifesciences.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/workflows_service_v2_beta_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'lifesciences.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Runs a pipeline. The returned Operation's [metadata] - * [google.longrunning.Operation.metadata] field will contain a - * [google.cloud.lifesciences.v2beta.Metadata][google.cloud.lifesciences.v2beta.Metadata] - * object describing the status of the pipeline execution. The - * [response][google.longrunning.Operation.response] field will contain a - * [google.cloud.lifesciences.v2beta.RunPipelineResponse][google.cloud.lifesciences.v2beta.RunPipelineResponse] - * object if the pipeline completes successfully. - * - * **Note:** Before you can use this method, the *Life Sciences Service Agent* - * must have access to your project. This is done automatically when the - * Cloud Life Sciences API is first enabled, but if you delete this permission - * you must disable and re-enable the API to grant the Life Sciences - * Service Agent the required permissions. - * Authorization requires the following [Google - * IAM](https://cloud.google.com/iam/) permission: - * - * * `lifesciences.workflows.run` - * - * Sample code: - * ``` - * $workflowsServiceV2BetaClient = new WorkflowsServiceV2BetaClient(); - * try { - * $pipeline = new Pipeline(); - * $operationResponse = $workflowsServiceV2BetaClient->runPipeline($pipeline); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $workflowsServiceV2BetaClient->runPipeline($pipeline); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $workflowsServiceV2BetaClient->resumeOperation($operationName, 'runPipeline'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $workflowsServiceV2BetaClient->close(); - * } - * ``` - * - * @param Pipeline $pipeline Required. The description of the pipeline to run. - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * The project and location that this request should be executed against. - * @type array $labels - * User-defined labels to associate with the returned operation. These - * labels are not propagated to any Google Cloud Platform resources used by - * the operation, and can be modified at any time. - * - * To associate labels with resources created while executing the operation, - * see the appropriate resource message (for example, `VirtualMachine`). - * @type string $pubSubTopic - * The name of an existing Pub/Sub topic. The server will publish - * messages to this topic whenever the status of the operation changes. - * The Life Sciences Service Agent account must have publisher permissions to - * the specified topic or notifications will not be sent. - * @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 \Google\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function runPipeline($pipeline, array $optionalArgs = []) - { - $request = new RunPipelineRequest(); - $requestParamHeaders = []; - $request->setPipeline($pipeline); - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['labels'])) { - $request->setLabels($optionalArgs['labels']); - } - - if (isset($optionalArgs['pubSubTopic'])) { - $request->setPubSubTopic($optionalArgs['pubSubTopic']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RunPipeline', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $workflowsServiceV2BetaClient = new WorkflowsServiceV2BetaClient(); - * try { - * $response = $workflowsServiceV2BetaClient->getLocation(); - * } finally { - * $workflowsServiceV2BetaClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @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 \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetLocation', Location::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.cloud.location.Locations')->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $workflowsServiceV2BetaClient = new WorkflowsServiceV2BetaClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $workflowsServiceV2BetaClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $workflowsServiceV2BetaClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $workflowsServiceV2BetaClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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 \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListLocations', $optionalArgs, ListLocationsResponse::class, $request, 'google.cloud.location.Locations'); - } -} diff --git a/LifeSciences/src/V2beta/Metadata.php b/LifeSciences/src/V2beta/Metadata.php index db615b052b45..a06a77dc22d2 100644 --- a/LifeSciences/src/V2beta/Metadata.php +++ b/LifeSciences/src/V2beta/Metadata.php @@ -21,7 +21,7 @@ class Metadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Pipeline pipeline = 1; */ - private $pipeline = null; + protected $pipeline = null; /** * The user-defined labels associated with this operation. * @@ -40,26 +40,26 @@ class Metadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4; */ - private $create_time = null; + protected $create_time = null; /** * The first time at which resources were allocated to execute the pipeline. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 5; */ - private $start_time = null; + protected $start_time = null; /** * The time at which execution was completed and resources were cleaned up. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 6; */ - private $end_time = null; + protected $end_time = null; /** * The name of the Cloud Pub/Sub topic where notifications of operation status * changes are sent. * * Generated from protobuf field string pub_sub_topic = 7; */ - private $pub_sub_topic = ''; + protected $pub_sub_topic = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Mount.php b/LifeSciences/src/V2beta/Mount.php index 11580628273c..8832f77a319a 100644 --- a/LifeSciences/src/V2beta/Mount.php +++ b/LifeSciences/src/V2beta/Mount.php @@ -20,19 +20,19 @@ class Mount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string disk = 1; */ - private $disk = ''; + protected $disk = ''; /** * The path to mount the disk inside the container. * * Generated from protobuf field string path = 2; */ - private $path = ''; + protected $path = ''; /** * If true, the disk is mounted read-only inside the container. * * Generated from protobuf field bool read_only = 3; */ - private $read_only = false; + protected $read_only = false; /** * Constructor. diff --git a/LifeSciences/src/V2beta/NFSMount.php b/LifeSciences/src/V2beta/NFSMount.php index c7fe5a56994a..4c3c5cd37013 100644 --- a/LifeSciences/src/V2beta/NFSMount.php +++ b/LifeSciences/src/V2beta/NFSMount.php @@ -20,7 +20,7 @@ class NFSMount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string target = 1; */ - private $target = ''; + protected $target = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Network.php b/LifeSciences/src/V2beta/Network.php index 67182b0b6995..e0663ecc2d38 100644 --- a/LifeSciences/src/V2beta/Network.php +++ b/LifeSciences/src/V2beta/Network.php @@ -23,7 +23,7 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network = 1; */ - private $network = ''; + protected $network = ''; /** * If set to true, do not attach a public IP address to the VM. Note that * without a public IP address, additional configuration is required to @@ -33,7 +33,7 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool use_private_address = 2; */ - private $use_private_address = false; + protected $use_private_address = false; /** * If the specified network is configured for custom subnet creation, the * name of the subnetwork to attach the instance to must be specified here. @@ -45,7 +45,7 @@ class Network extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string subnetwork = 3; */ - private $subnetwork = ''; + protected $subnetwork = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/PersistentDisk.php b/LifeSciences/src/V2beta/PersistentDisk.php index 01e93398be27..985feaa1b929 100644 --- a/LifeSciences/src/V2beta/PersistentDisk.php +++ b/LifeSciences/src/V2beta/PersistentDisk.php @@ -27,19 +27,19 @@ class PersistentDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 size_gb = 1; */ - private $size_gb = 0; + protected $size_gb = 0; /** * The Compute Engine disk type. If unspecified, `pd-standard` is used. * * Generated from protobuf field string type = 2; */ - private $type = ''; + protected $type = ''; /** * An image to put on the disk before attaching it to the VM. * * Generated from protobuf field string source_image = 3; */ - private $source_image = ''; + protected $source_image = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Pipeline.php b/LifeSciences/src/V2beta/Pipeline.php index 9058ea3671c4..6351d430b2b7 100644 --- a/LifeSciences/src/V2beta/Pipeline.php +++ b/LifeSciences/src/V2beta/Pipeline.php @@ -26,7 +26,7 @@ class Pipeline extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Resources resources = 2; */ - private $resources = null; + protected $resources = null; /** * The environment to pass into every action. Each action can also specify * additional environment variables but cannot delete an entry from this map @@ -45,7 +45,7 @@ class Pipeline extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Secret encrypted_environment = 5; */ - private $encrypted_environment = null; + protected $encrypted_environment = null; /** * The maximum amount of time to give the pipeline to complete. This includes * the time spent waiting for a worker to be allocated. If the pipeline fails @@ -55,7 +55,7 @@ class Pipeline extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration timeout = 4; */ - private $timeout = null; + protected $timeout = null; /** * Constructor. diff --git a/LifeSciences/src/V2beta/PullStartedEvent.php b/LifeSciences/src/V2beta/PullStartedEvent.php index e9a3a778856a..295409c26ba0 100644 --- a/LifeSciences/src/V2beta/PullStartedEvent.php +++ b/LifeSciences/src/V2beta/PullStartedEvent.php @@ -20,7 +20,7 @@ class PullStartedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string image_uri = 1; */ - private $image_uri = ''; + protected $image_uri = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/PullStoppedEvent.php b/LifeSciences/src/V2beta/PullStoppedEvent.php index b666c8d9ddd8..35ce70556057 100644 --- a/LifeSciences/src/V2beta/PullStoppedEvent.php +++ b/LifeSciences/src/V2beta/PullStoppedEvent.php @@ -20,7 +20,7 @@ class PullStoppedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string image_uri = 1; */ - private $image_uri = ''; + protected $image_uri = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Resources.php b/LifeSciences/src/V2beta/Resources.php index f08321446694..df892573ebc4 100644 --- a/LifeSciences/src/V2beta/Resources.php +++ b/LifeSciences/src/V2beta/Resources.php @@ -35,7 +35,7 @@ class Resources extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.VirtualMachine virtual_machine = 4; */ - private $virtual_machine = null; + protected $virtual_machine = null; /** * Constructor. diff --git a/LifeSciences/src/V2beta/RunPipelineRequest.php b/LifeSciences/src/V2beta/RunPipelineRequest.php index 23304b67ab49..3d7634c4f03e 100644 --- a/LifeSciences/src/V2beta/RunPipelineRequest.php +++ b/LifeSciences/src/V2beta/RunPipelineRequest.php @@ -22,13 +22,13 @@ class RunPipelineRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 4; */ - private $parent = ''; + protected $parent = ''; /** * Required. The description of the pipeline to run. * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $pipeline = null; + protected $pipeline = null; /** * User-defined labels to associate with the returned operation. These * labels are not propagated to any Google Cloud Platform resources used by @@ -47,7 +47,7 @@ class RunPipelineRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pub_sub_topic = 3; */ - private $pub_sub_topic = ''; + protected $pub_sub_topic = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Secret.php b/LifeSciences/src/V2beta/Secret.php index 07d304e2906f..8e7db4eeb4bc 100644 --- a/LifeSciences/src/V2beta/Secret.php +++ b/LifeSciences/src/V2beta/Secret.php @@ -23,14 +23,14 @@ class Secret extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string key_name = 1; */ - private $key_name = ''; + protected $key_name = ''; /** * The value of the cipherText response from the `encrypt` method. This field * is intentionally unaudited. * * Generated from protobuf field string cipher_text = 2; */ - private $cipher_text = ''; + protected $cipher_text = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/ServiceAccount.php b/LifeSciences/src/V2beta/ServiceAccount.php index e45803032650..cbe399edea64 100644 --- a/LifeSciences/src/V2beta/ServiceAccount.php +++ b/LifeSciences/src/V2beta/ServiceAccount.php @@ -21,7 +21,7 @@ class ServiceAccount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string email = 1; */ - private $email = ''; + protected $email = ''; /** * List of scopes to be enabled for this service account on the VM, in * addition to the cloud-platform API scope that will be added by default. diff --git a/LifeSciences/src/V2beta/UnexpectedExitStatusEvent.php b/LifeSciences/src/V2beta/UnexpectedExitStatusEvent.php index c4c2e4bd6c32..a2e5307b0de0 100644 --- a/LifeSciences/src/V2beta/UnexpectedExitStatusEvent.php +++ b/LifeSciences/src/V2beta/UnexpectedExitStatusEvent.php @@ -23,13 +23,13 @@ class UnexpectedExitStatusEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 action_id = 1; */ - private $action_id = 0; + protected $action_id = 0; /** * The exit status of the container. * * Generated from protobuf field int32 exit_status = 2; */ - private $exit_status = 0; + protected $exit_status = 0; /** * Constructor. diff --git a/LifeSciences/src/V2beta/VirtualMachine.php b/LifeSciences/src/V2beta/VirtualMachine.php index b698ce34da49..5b9fa04cfbb4 100644 --- a/LifeSciences/src/V2beta/VirtualMachine.php +++ b/LifeSciences/src/V2beta/VirtualMachine.php @@ -26,13 +26,13 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $machine_type = ''; + protected $machine_type = ''; /** * If true, allocate a preemptible VM. * * Generated from protobuf field bool preemptible = 2; */ - private $preemptible = false; + protected $preemptible = false; /** * Optional set of labels to apply to the VM and any attached disk resources. * These labels must adhere to the [name and value @@ -57,7 +57,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.Network network = 5; */ - private $network = null; + protected $network = null; /** * The list of accelerators to attach to the VM. * @@ -70,7 +70,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.lifesciences.v2beta.ServiceAccount service_account = 7; */ - private $service_account = null; + protected $service_account = null; /** * The size of the boot disk, in GB. The boot disk must be large * enough to accommodate all of the Docker images from each action in the @@ -79,7 +79,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 boot_disk_size_gb = 8; */ - private $boot_disk_size_gb = 0; + protected $boot_disk_size_gb = 0; /** * The CPU platform to request. An instance based on a newer platform can be * allocated, but never one with fewer capabilities. The value of this @@ -91,7 +91,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cpu_platform = 9; */ - private $cpu_platform = ''; + protected $cpu_platform = ''; /** * The host operating system image to use. * Currently, only Container-Optimized OS images can be used. @@ -105,7 +105,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string boot_image = 10; */ - private $boot_image = ''; + protected $boot_image = ''; /** * The NVIDIA driver version to use when attaching an NVIDIA GPU accelerator. * The version specified here must be compatible with the GPU libraries @@ -121,7 +121,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_stackdriver_monitoring = 12; */ - private $enable_stackdriver_monitoring = false; + protected $enable_stackdriver_monitoring = false; /** * The Compute Engine Disk Images to use as a Docker cache. The disks will be * mounted into the Docker folder in a way that the images present in the @@ -149,7 +149,7 @@ class VirtualMachine extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string reservation = 15; */ - private $reservation = ''; + protected $reservation = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/Volume.php b/LifeSciences/src/V2beta/Volume.php index a96031aa26c6..9b2da83dfeb1 100644 --- a/LifeSciences/src/V2beta/Volume.php +++ b/LifeSciences/src/V2beta/Volume.php @@ -25,7 +25,7 @@ class Volume extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string volume = 1; */ - private $volume = ''; + protected $volume = ''; protected $storage; /** diff --git a/LifeSciences/src/V2beta/WorkerAssignedEvent.php b/LifeSciences/src/V2beta/WorkerAssignedEvent.php index 15cc0d6d6666..59739bb1f03d 100644 --- a/LifeSciences/src/V2beta/WorkerAssignedEvent.php +++ b/LifeSciences/src/V2beta/WorkerAssignedEvent.php @@ -21,19 +21,19 @@ class WorkerAssignedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string zone = 1; */ - private $zone = ''; + protected $zone = ''; /** * The worker's instance name. * * Generated from protobuf field string instance = 2; */ - private $instance = ''; + protected $instance = ''; /** * The machine type that was assigned for the worker. * * Generated from protobuf field string machine_type = 3; */ - private $machine_type = ''; + protected $machine_type = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/WorkerReleasedEvent.php b/LifeSciences/src/V2beta/WorkerReleasedEvent.php index f9baadf70a41..8cc7ed6a39bc 100644 --- a/LifeSciences/src/V2beta/WorkerReleasedEvent.php +++ b/LifeSciences/src/V2beta/WorkerReleasedEvent.php @@ -21,13 +21,13 @@ class WorkerReleasedEvent extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string zone = 1; */ - private $zone = ''; + protected $zone = ''; /** * The worker's instance name. * * Generated from protobuf field string instance = 2; */ - private $instance = ''; + protected $instance = ''; /** * Constructor. diff --git a/LifeSciences/src/V2beta/WorkflowsServiceV2BetaClient.php b/LifeSciences/src/V2beta/WorkflowsServiceV2BetaClient.php deleted file mode 100644 index ce4a84a40ca4..000000000000 --- a/LifeSciences/src/V2beta/WorkflowsServiceV2BetaClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta/RunPipeline', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/LifeSciences/tests/Unit/V2beta/Client/WorkflowsServiceV2BetaClientTest.php b/LifeSciences/tests/Unit/V2beta/Client/WorkflowsServiceV2BetaClientTest.php index c37de65ffa7f..38990f3d06c4 100644 --- a/LifeSciences/tests/Unit/V2beta/Client/WorkflowsServiceV2BetaClientTest.php +++ b/LifeSciences/tests/Unit/V2beta/Client/WorkflowsServiceV2BetaClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return WorkflowsServiceV2BetaClient */ @@ -100,8 +102,7 @@ public function runPipelineTest() $operationsTransport->addResponse($completeOperation); // Mock request $pipeline = new Pipeline(); - $request = (new RunPipelineRequest()) - ->setPipeline($pipeline); + $request = (new RunPipelineRequest())->setPipeline($pipeline); $response = $gapicClient->runPipeline($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -157,17 +158,19 @@ public function runPipelineExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $pipeline = new Pipeline(); - $request = (new RunPipelineRequest()) - ->setPipeline($pipeline); + $request = (new RunPipelineRequest())->setPipeline($pipeline); $response = $gapicClient->runPipeline($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -229,12 +232,15 @@ public function getLocationExceptionTest() $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); + $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 { @@ -261,9 +267,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -293,12 +297,15 @@ public function listLocationsExceptionTest() $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); + $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 { @@ -345,8 +352,7 @@ public function runPipelineAsyncTest() $operationsTransport->addResponse($completeOperation); // Mock request $pipeline = new Pipeline(); - $request = (new RunPipelineRequest()) - ->setPipeline($pipeline); + $request = (new RunPipelineRequest())->setPipeline($pipeline); $response = $gapicClient->runPipelineAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); diff --git a/LifeSciences/tests/Unit/V2beta/WorkflowsServiceV2BetaClientTest.php b/LifeSciences/tests/Unit/V2beta/WorkflowsServiceV2BetaClientTest.php deleted file mode 100644 index 1c76410f21b0..000000000000 --- a/LifeSciences/tests/Unit/V2beta/WorkflowsServiceV2BetaClientTest.php +++ /dev/null @@ -1,305 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return WorkflowsServiceV2BetaClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new WorkflowsServiceV2BetaClient($options); - } - - /** @test */ - public function runPipelineTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/runPipelineTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new RunPipelineResponse(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/runPipelineTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $pipeline = new Pipeline(); - $response = $gapicClient->runPipeline($pipeline); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta/RunPipeline', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getPipeline(); - $this->assertProtobufEquals($pipeline, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/runPipelineTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function runPipelineExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/runPipelineTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $pipeline = new Pipeline(); - $response = $gapicClient->runPipeline($pipeline); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/runPipelineTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $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); - $response = $gapicClient->getLocation(); - $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); - try { - $gapicClient->getLocation(); - // 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); - $response = $gapicClient->listLocations(); - $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); - try { - $gapicClient->listLocations(); - // 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()); - } -}