diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json
index 49b3491111d7..1bb41055e4f9 100644
--- a/.repo-metadata-full.json
+++ b/.repo-metadata-full.json
@@ -462,7 +462,7 @@
"DataFusion": {
"language": "php",
"distribution_name": "google/cloud-data-fusion",
- "release_level": "preview",
+ "release_level": "stable",
"client_documentation": "https://cloud.google.com/php/docs/reference/cloud-data-fusion/latest",
"library_type": "GAPIC_AUTO",
"api_shortname": "datafusion"
diff --git a/DataFusion/README.md b/DataFusion/README.md
index e3df73bb21bb..450c83b2a85f 100644
--- a/DataFusion/README.md
+++ b/DataFusion/README.md
@@ -30,9 +30,8 @@ on authenticating your client. Once authenticated, you'll be ready to start maki
### Version
-This component is considered beta. As such, it should be expected to be mostly
-stable and we're working towards a release candidate. We will address issues
-and requests with a higher priority.
+This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in
+any minor or patch releases. We will address issues and requests with the highest priority.
### Next Steps
diff --git a/DataFusion/owlbot.py b/DataFusion/owlbot.py
index 70be311fb188..09b12d8f7dcd 100644
--- a/DataFusion/owlbot.py
+++ b/DataFusion/owlbot.py
@@ -1,4 +1,4 @@
-# Copyright 2021 Google LLC
+# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
src=src,
dest=dest,
copy_excludes=[
- src / "**/[A-Z]*_*.php"
+ src / "**/[A-Z]*_*.php",
]
)
@@ -47,32 +47,6 @@
+ "\n",
'')
-### [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)"
-)
-
# format generated clients
subprocess.run([
'npm',
@@ -81,8 +55,8 @@
'--package=@prettier/plugin-php@^0.16',
'--',
'prettier',
- '**/Gapic/*',
+ '**/Client/*',
'--write',
'--parser=php',
'--single-quote',
- '--print-width=80'])
+ '--print-width=120'])
diff --git a/DataFusion/samples/V1/DataFusionClient/create_instance.php b/DataFusion/samples/V1/DataFusionClient/create_instance.php
index 6cc9fad762bc..79d4efea1cc9 100644
--- a/DataFusion/samples/V1/DataFusionClient/create_instance.php
+++ b/DataFusion/samples/V1/DataFusionClient/create_instance.php
@@ -1,6 +1,6 @@
.google.cloud.datafusion.v1.Accelerator.AcceleratorType accelerator_type = 1;
*/
- private $accelerator_type = 0;
+ protected $accelerator_type = 0;
/**
* The state of the accelerator
*
* Generated from protobuf field .google.cloud.datafusion.v1.Accelerator.State state = 2;
*/
- private $state = 0;
+ protected $state = 0;
/**
* Constructor.
diff --git a/DataFusion/src/V1/Client/DataFusionClient.php b/DataFusion/src/V1/Client/DataFusionClient.php
index 412deff52520..85c30581700d 100644
--- a/DataFusion/src/V1/Client/DataFusionClient.php
+++ b/DataFusion/src/V1/Client/DataFusionClient.php
@@ -1,6 +1,6 @@
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);
+ }
+
/**
* Formats a string containing the fully-qualified path to represent a crypto_key
* resource.
@@ -401,8 +420,10 @@ public function getInstance(GetInstanceRequest $request, array $callOptions = []
*
* @throws ApiException Thrown if the API call fails.
*/
- public function listAvailableVersions(ListAvailableVersionsRequest $request, array $callOptions = []): PagedListResponse
- {
+ public function listAvailableVersions(
+ ListAvailableVersionsRequest $request,
+ array $callOptions = []
+ ): PagedListResponse {
return $this->startApiCall('ListAvailableVersions', $request, $callOptions);
}
diff --git a/DataFusion/src/V1/CreateInstanceRequest.php b/DataFusion/src/V1/CreateInstanceRequest.php
index a24b04e5e3a0..ba09ee2de958 100644
--- a/DataFusion/src/V1/CreateInstanceRequest.php
+++ b/DataFusion/src/V1/CreateInstanceRequest.php
@@ -21,19 +21,19 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* Required. The name of the instance to create.
*
* Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $instance_id = '';
+ protected $instance_id = '';
/**
* An instance resource.
*
* Generated from protobuf field .google.cloud.datafusion.v1.Instance instance = 3;
*/
- private $instance = null;
+ protected $instance = null;
/**
* @param string $parent Required. The instance's project and location in the format
diff --git a/DataFusion/src/V1/CryptoKeyConfig.php b/DataFusion/src/V1/CryptoKeyConfig.php
index d6a6c33bfba3..8b36d565ce86 100644
--- a/DataFusion/src/V1/CryptoKeyConfig.php
+++ b/DataFusion/src/V1/CryptoKeyConfig.php
@@ -23,7 +23,7 @@ class CryptoKeyConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string key_reference = 1 [(.google.api.resource_reference) = {
*/
- private $key_reference = '';
+ protected $key_reference = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/DataFusionClient.php b/DataFusion/src/V1/DataFusionClient.php
deleted file mode 100644
index 0fa786d4e3f7..000000000000
--- a/DataFusion/src/V1/DataFusionClient.php
+++ /dev/null
@@ -1,34 +0,0 @@
-_simpleRequest('/google.cloud.datafusion.v1.DataFusion/ListAvailableVersions',
- $argument,
- ['\Google\Cloud\DataFusion\V1\ListAvailableVersionsResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Lists Data Fusion instances in the specified project and location.
- * @param \Google\Cloud\DataFusion\V1\ListInstancesRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ListInstances(\Google\Cloud\DataFusion\V1\ListInstancesRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/ListInstances',
- $argument,
- ['\Google\Cloud\DataFusion\V1\ListInstancesResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Gets details of a single Data Fusion instance.
- * @param \Google\Cloud\DataFusion\V1\GetInstanceRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function GetInstance(\Google\Cloud\DataFusion\V1\GetInstanceRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/GetInstance',
- $argument,
- ['\Google\Cloud\DataFusion\V1\Instance', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Creates a new Data Fusion instance in the specified project and location.
- * @param \Google\Cloud\DataFusion\V1\CreateInstanceRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function CreateInstance(\Google\Cloud\DataFusion\V1\CreateInstanceRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/CreateInstance',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Deletes a single Date Fusion instance.
- * @param \Google\Cloud\DataFusion\V1\DeleteInstanceRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function DeleteInstance(\Google\Cloud\DataFusion\V1\DeleteInstanceRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/DeleteInstance',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Updates a single Data Fusion instance.
- * @param \Google\Cloud\DataFusion\V1\UpdateInstanceRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function UpdateInstance(\Google\Cloud\DataFusion\V1\UpdateInstanceRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/UpdateInstance',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Restart a single Data Fusion instance.
- * At the end of an operation instance is fully restarted.
- * @param \Google\Cloud\DataFusion\V1\RestartInstanceRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function RestartInstance(\Google\Cloud\DataFusion\V1\RestartInstanceRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.datafusion.v1.DataFusion/RestartInstance',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/DataFusion/src/V1/DeleteInstanceRequest.php b/DataFusion/src/V1/DeleteInstanceRequest.php
index 41eb160a0659..323b13f57fd0 100644
--- a/DataFusion/src/V1/DeleteInstanceRequest.php
+++ b/DataFusion/src/V1/DeleteInstanceRequest.php
@@ -21,7 +21,7 @@ class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. The instance resource name in the format
diff --git a/DataFusion/src/V1/Gapic/DataFusionGapicClient.php b/DataFusion/src/V1/Gapic/DataFusionGapicClient.php
deleted file mode 100644
index 8ed2351b03c7..000000000000
--- a/DataFusion/src/V1/Gapic/DataFusionGapicClient.php
+++ /dev/null
@@ -1,961 +0,0 @@
-locationName('[PROJECT]', '[LOCATION]');
- * $instanceId = 'instance_id';
- * $operationResponse = $dataFusionClient->createInstance($formattedParent, $instanceId);
- * $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 = $dataFusionClient->createInstance($formattedParent, $instanceId);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $dataFusionClient->resumeOperation($operationName, 'createInstance');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * Many parameters require resource names to be formatted in a particular way. To
- * assist with these names, this class includes a format method for each type of
- * name, and additionally a parseName method to extract the individual identifiers
- * contained within formatted names that are returned by the API.
- *
- * @deprecated Please use the new service client {@see \Google\Cloud\DataFusion\V1\Client\DataFusionClient}.
- */
-class DataFusionGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.datafusion.v1.DataFusion';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'datafusion.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'datafusion.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 static $cryptoKeyNameTemplate;
-
- private static $instanceNameTemplate;
-
- private static $locationNameTemplate;
-
- private static $pathTemplateMap;
-
- private $operationsClient;
-
- private static function getClientDefaults()
- {
- return [
- 'serviceName' => self::SERVICE_NAME,
- 'apiEndpoint' =>
- self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
- 'clientConfig' =>
- __DIR__ . '/../resources/data_fusion_client_config.json',
- 'descriptorsConfigPath' =>
- __DIR__ . '/../resources/data_fusion_descriptor_config.php',
- 'gcpApiConfigPath' =>
- __DIR__ . '/../resources/data_fusion_grpc_config.json',
- 'credentialsConfig' => [
- 'defaultScopes' => self::$serviceScopes,
- ],
- 'transportConfig' => [
- 'rest' => [
- 'restClientConfigPath' =>
- __DIR__ .
- '/../resources/data_fusion_rest_client_config.php',
- ],
- ],
- ];
- }
-
- private static function getCryptoKeyNameTemplate()
- {
- if (self::$cryptoKeyNameTemplate == null) {
- self::$cryptoKeyNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}'
- );
- }
-
- return self::$cryptoKeyNameTemplate;
- }
-
- private static function getInstanceNameTemplate()
- {
- if (self::$instanceNameTemplate == null) {
- self::$instanceNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/instances/{instance}'
- );
- }
-
- return self::$instanceNameTemplate;
- }
-
- private static function getLocationNameTemplate()
- {
- if (self::$locationNameTemplate == null) {
- self::$locationNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}'
- );
- }
-
- return self::$locationNameTemplate;
- }
-
- private static function getPathTemplateMap()
- {
- if (self::$pathTemplateMap == null) {
- self::$pathTemplateMap = [
- 'cryptoKey' => self::getCryptoKeyNameTemplate(),
- 'instance' => self::getInstanceNameTemplate(),
- 'location' => self::getLocationNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * 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(
- $project,
- $location,
- $keyRing,
- $cryptoKey
- ) {
- return self::getCryptoKeyNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'key_ring' => $keyRing,
- 'crypto_key' => $cryptoKey,
- ]);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a instance
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $instance
- *
- * @return string The formatted instance resource.
- */
- public static function instanceName($project, $location, $instance)
- {
- return self::getInstanceNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'instance' => $instance,
- ]);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a location
- * resource.
- *
- * @param string $project
- * @param string $location
- *
- * @return string The formatted location resource.
- */
- public static function locationName($project, $location)
- {
- return self::getLocationNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- ]);
- }
-
- /**
- * 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/{key_ring}/cryptoKeys/{crypto_key}
- * - instance: projects/{project}/locations/{location}/instances/{instance}
- * - location: projects/{project}/locations/{location}
- *
- * The optional $template argument can be supplied to specify a particular pattern,
- * and must match one of the templates listed above. If no $template argument is
- * provided, or if the $template argument does not match one of the templates
- * listed, then parseName will check each of the supported templates, and return
- * the first match.
- *
- * @param string $formattedName The formatted name string
- * @param string $template Optional name of template to match
- *
- * @return array An associative array from name component IDs to component values.
- *
- * @throws ValidationException If $formattedName could not be matched.
- */
- public static function parseName($formattedName, $template = null)
- {
- $templateMap = self::getPathTemplateMap();
- if ($template) {
- if (!isset($templateMap[$template])) {
- throw new ValidationException(
- "Template name $template does not exist"
- );
- }
-
- return $templateMap[$template]->match($formattedName);
- }
-
- foreach ($templateMap as $templateName => $pathTemplate) {
- try {
- return $pathTemplate->match($formattedName);
- } catch (ValidationException $ex) {
- // Swallow the exception to continue trying other path templates
- }
- }
-
- throw new ValidationException(
- "Input did not match any known format. Input: $formattedName"
- );
- }
-
- /**
- * Return an OperationsClient object with the same endpoint as $this.
- *
- * @return OperationsClient
- */
- 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
- */
- 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 'datafusion.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
- */
- public function __construct(array $options = [])
- {
- $clientOptions = $this->buildClientOptions($options);
- $this->setClientOptions($clientOptions);
- $this->operationsClient = $this->createOperationsClient($clientOptions);
- }
-
- /**
- * Creates a new Data Fusion instance in the specified project and location.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedParent = $dataFusionClient->locationName('[PROJECT]', '[LOCATION]');
- * $instanceId = 'instance_id';
- * $operationResponse = $dataFusionClient->createInstance($formattedParent, $instanceId);
- * $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 = $dataFusionClient->createInstance($formattedParent, $instanceId);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $dataFusionClient->resumeOperation($operationName, 'createInstance');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The instance's project and location in the format
- * projects/{project}/locations/{location}.
- * @param string $instanceId Required. The name of the instance to create.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type Instance $instance
- * An instance resource.
- * @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
- */
- public function createInstance(
- $parent,
- $instanceId,
- array $optionalArgs = []
- ) {
- $request = new CreateInstanceRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setInstanceId($instanceId);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['instance'])) {
- $request->setInstance($optionalArgs['instance']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'CreateInstance',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Deletes a single Date Fusion instance.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedName = $dataFusionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- * $operationResponse = $dataFusionClient->deleteInstance($formattedName);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * // operation succeeded and returns no value
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $dataFusionClient->deleteInstance($formattedName);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $dataFusionClient->resumeOperation($operationName, 'deleteInstance');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * // operation succeeded and returns no value
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $name Required. The instance resource name in the format
- * projects/{project}/locations/{location}/instances/{instance}
- * @param array $optionalArgs {
- * 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 \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function deleteInstance($name, array $optionalArgs = [])
- {
- $request = new DeleteInstanceRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'DeleteInstance',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Gets details of a single Data Fusion instance.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedName = $dataFusionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- * $response = $dataFusionClient->getInstance($formattedName);
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $name Required. The instance resource name in the format
- * projects/{project}/locations/{location}/instances/{instance}.
- * @param array $optionalArgs {
- * 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 \Google\Cloud\DataFusion\V1\Instance
- *
- * @throws ApiException if the remote call fails
- */
- public function getInstance($name, array $optionalArgs = [])
- {
- $request = new GetInstanceRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'GetInstance',
- Instance::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Lists possible versions for Data Fusion instances in the specified project
- * and location.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedParent = $dataFusionClient->locationName('[PROJECT]', '[LOCATION]');
- * // Iterate over pages of elements
- * $pagedResponse = $dataFusionClient->listAvailableVersions($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $dataFusionClient->listAvailableVersions($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project and location for which to retrieve instance information
- * in the format projects/{project}/locations/{location}.
- * @param array $optionalArgs {
- * Optional.
- *
- * @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 bool $latestPatchOnly
- * Whether or not to return the latest patch of every available minor version.
- * If true, only the latest patch will be returned. Ex. if allowed versions is
- * [6.1.1, 6.1.2, 6.2.0] then response will be [6.1.2, 6.2.0]
- * @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
- */
- public function listAvailableVersions($parent, array $optionalArgs = [])
- {
- $request = new ListAvailableVersionsRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- if (isset($optionalArgs['latestPatchOnly'])) {
- $request->setLatestPatchOnly($optionalArgs['latestPatchOnly']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListAvailableVersions',
- $optionalArgs,
- ListAvailableVersionsResponse::class,
- $request
- );
- }
-
- /**
- * Lists Data Fusion instances in the specified project and location.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedParent = $dataFusionClient->locationName('[PROJECT]', '[LOCATION]');
- * // Iterate over pages of elements
- * $pagedResponse = $dataFusionClient->listInstances($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $dataFusionClient->listInstances($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project and location for which to retrieve instance information
- * in the format projects/{project}/locations/{location}. If the location is
- * specified as '-' (wildcard), then all regions available to the project
- * are queried, and the results are aggregated.
- * @param array $optionalArgs {
- * Optional.
- *
- * @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 string $filter
- * List filter.
- * @type string $orderBy
- * Sort results. Supported values are "name", "name desc", or "" (unsorted).
- * @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
- */
- public function listInstances($parent, array $optionalArgs = [])
- {
- $request = new ListInstancesRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- if (isset($optionalArgs['filter'])) {
- $request->setFilter($optionalArgs['filter']);
- }
-
- if (isset($optionalArgs['orderBy'])) {
- $request->setOrderBy($optionalArgs['orderBy']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListInstances',
- $optionalArgs,
- ListInstancesResponse::class,
- $request
- );
- }
-
- /**
- * Restart a single Data Fusion instance.
- * At the end of an operation instance is fully restarted.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $formattedName = $dataFusionClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- * $operationResponse = $dataFusionClient->restartInstance($formattedName);
- * $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 = $dataFusionClient->restartInstance($formattedName);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $dataFusionClient->resumeOperation($operationName, 'restartInstance');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param string $name Required. Name of the Data Fusion instance which need to be restarted in the form of
- * projects/{project}/locations/{location}/instances/{instance}
- * @param array $optionalArgs {
- * 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 \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function restartInstance($name, array $optionalArgs = [])
- {
- $request = new RestartInstanceRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'RestartInstance',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Updates a single Data Fusion instance.
- *
- * Sample code:
- * ```
- * $dataFusionClient = new DataFusionClient();
- * try {
- * $instance = new Instance();
- * $operationResponse = $dataFusionClient->updateInstance($instance);
- * $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 = $dataFusionClient->updateInstance($instance);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $dataFusionClient->resumeOperation($operationName, 'updateInstance');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $dataFusionClient->close();
- * }
- * ```
- *
- * @param Instance $instance Required. The instance resource that replaces the resource on the server. Currently,
- * Data Fusion only allows replacing labels, options, and stack driver
- * settings. All other fields will be ignored.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type FieldMask $updateMask
- * Field mask is used to specify the fields that the update will overwrite
- * in an instance resource. The fields specified in the update_mask are
- * relative to the resource, not the full request.
- * A field will be overwritten if it is in the mask.
- * If the user does not provide a mask, all the supported fields (labels,
- * options, and version currently) will be overwritten.
- * @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
- */
- public function updateInstance($instance, array $optionalArgs = [])
- {
- $request = new UpdateInstanceRequest();
- $requestParamHeaders = [];
- $request->setInstance($instance);
- $requestParamHeaders['instance.name'] = $instance->getName();
- if (isset($optionalArgs['updateMask'])) {
- $request->setUpdateMask($optionalArgs['updateMask']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'UpdateInstance',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-}
diff --git a/DataFusion/src/V1/GetInstanceRequest.php b/DataFusion/src/V1/GetInstanceRequest.php
index 8dc7dee0ed17..834a6a4a0037 100644
--- a/DataFusion/src/V1/GetInstanceRequest.php
+++ b/DataFusion/src/V1/GetInstanceRequest.php
@@ -21,7 +21,7 @@ class GetInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/Instance.php b/DataFusion/src/V1/Instance.php
index 7bc0227ca85a..9cf4529e3785 100644
--- a/DataFusion/src/V1/Instance.php
+++ b/DataFusion/src/V1/Instance.php
@@ -21,31 +21,31 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* A description of this instance.
*
* Generated from protobuf field string description = 2;
*/
- private $description = '';
+ protected $description = '';
/**
* Required. Instance type.
*
* Generated from protobuf field .google.cloud.datafusion.v1.Instance.Type type = 3 [(.google.api.field_behavior) = REQUIRED];
*/
- private $type = 0;
+ protected $type = 0;
/**
* Option to enable Stackdriver Logging.
*
* Generated from protobuf field bool enable_stackdriver_logging = 4;
*/
- private $enable_stackdriver_logging = false;
+ protected $enable_stackdriver_logging = false;
/**
* Option to enable Stackdriver Monitoring.
*
* Generated from protobuf field bool enable_stackdriver_monitoring = 5;
*/
- private $enable_stackdriver_monitoring = false;
+ protected $enable_stackdriver_monitoring = false;
/**
* Specifies whether the Data Fusion instance should be private. If set to
* true, all Data Fusion nodes will have private IP addresses and will not be
@@ -53,14 +53,14 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bool private_instance = 6;
*/
- private $private_instance = false;
+ protected $private_instance = false;
/**
* Network configuration options. These are required when a private Data
* Fusion instance is to be created.
*
* Generated from protobuf field .google.cloud.datafusion.v1.NetworkConfig network_config = 7;
*/
- private $network_config = null;
+ protected $network_config = null;
/**
* The resource labels for instance to use to annotate any related underlying
* resources such as Compute Engine VMs. The character '=' is not allowed to
@@ -81,45 +81,45 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp create_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $create_time = null;
+ protected $create_time = null;
/**
* Output only. The time the instance was last updated.
*
* Generated from protobuf field .google.protobuf.Timestamp update_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $update_time = null;
+ protected $update_time = null;
/**
* Output only. The current state of this Data Fusion instance.
*
* Generated from protobuf field .google.cloud.datafusion.v1.Instance.State state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $state = 0;
+ protected $state = 0;
/**
* Output only. Additional information about the current state of this Data
* Fusion instance if available.
*
* Generated from protobuf field string state_message = 13 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $state_message = '';
+ protected $state_message = '';
/**
* Output only. Endpoint on which the Data Fusion UI is accessible.
*
* Generated from protobuf field string service_endpoint = 14 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $service_endpoint = '';
+ protected $service_endpoint = '';
/**
* Name of the zone in which the Data Fusion instance will be created. Only
* DEVELOPER instances use this field.
*
* Generated from protobuf field string zone = 15;
*/
- private $zone = '';
+ protected $zone = '';
/**
* Current version of the Data Fusion. Only specifiable in Update.
*
* Generated from protobuf field string version = 16;
*/
- private $version = '';
+ protected $version = '';
/**
* Output only. Deprecated. Use tenant_project_id instead to extract the tenant project ID.
*
@@ -132,7 +132,7 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string display_name = 18;
*/
- private $display_name = '';
+ protected $display_name = '';
/**
* Available versions that the instance can be upgraded to using
* UpdateInstanceRequest.
@@ -145,13 +145,13 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string api_endpoint = 20 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $api_endpoint = '';
+ protected $api_endpoint = '';
/**
* Output only. Cloud Storage bucket generated by Data Fusion in the customer project.
*
* Generated from protobuf field string gcs_bucket = 21 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $gcs_bucket = '';
+ protected $gcs_bucket = '';
/**
* List of accelerators enabled for this CDF instance.
*
@@ -163,13 +163,13 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string p4_service_account = 23 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $p4_service_account = '';
+ protected $p4_service_account = '';
/**
* Output only. The name of the tenant project.
*
* Generated from protobuf field string tenant_project_id = 24 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $tenant_project_id = '';
+ protected $tenant_project_id = '';
/**
* User-managed service account to set on Dataproc when Cloud Data Fusion
* creates Dataproc to run data processing pipelines.
@@ -178,20 +178,20 @@ class Instance extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string dataproc_service_account = 25;
*/
- private $dataproc_service_account = '';
+ protected $dataproc_service_account = '';
/**
* Option to enable granular role-based access control.
*
* Generated from protobuf field bool enable_rbac = 27;
*/
- private $enable_rbac = false;
+ protected $enable_rbac = false;
/**
* The crypto key configuration. This field is used by the Customer-Managed
* Encryption Keys (CMEK) feature.
*
* Generated from protobuf field .google.cloud.datafusion.v1.CryptoKeyConfig crypto_key_config = 28;
*/
- private $crypto_key_config = null;
+ protected $crypto_key_config = null;
/**
* Output only. If the instance state is DISABLED, the reason for disabling the instance.
*
diff --git a/DataFusion/src/V1/ListAvailableVersionsRequest.php b/DataFusion/src/V1/ListAvailableVersionsRequest.php
index 1d58816f2f8e..8ae1ae0e0a4c 100644
--- a/DataFusion/src/V1/ListAvailableVersionsRequest.php
+++ b/DataFusion/src/V1/ListAvailableVersionsRequest.php
@@ -21,20 +21,20 @@ class ListAvailableVersionsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The maximum number of items to return.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token value to use if there are additional
* results to retrieve for this list request.
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* Whether or not to return the latest patch of every available minor version.
* If true, only the latest patch will be returned. Ex. if allowed versions is
@@ -42,7 +42,7 @@ class ListAvailableVersionsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bool latest_patch_only = 4;
*/
- private $latest_patch_only = false;
+ protected $latest_patch_only = false;
/**
* @param string $parent Required. The project and location for which to retrieve instance information
diff --git a/DataFusion/src/V1/ListAvailableVersionsResponse.php b/DataFusion/src/V1/ListAvailableVersionsResponse.php
index cb1abbf26fc8..84d6591cac2d 100644
--- a/DataFusion/src/V1/ListAvailableVersionsResponse.php
+++ b/DataFusion/src/V1/ListAvailableVersionsResponse.php
@@ -27,7 +27,7 @@ class ListAvailableVersionsResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string next_page_token = 2;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/ListInstancesRequest.php b/DataFusion/src/V1/ListInstancesRequest.php
index 37dea8a632d7..ba894d09f34a 100644
--- a/DataFusion/src/V1/ListInstancesRequest.php
+++ b/DataFusion/src/V1/ListInstancesRequest.php
@@ -23,32 +23,32 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The maximum number of items to return.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token value to use if there are additional
* results to retrieve for this list request.
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* List filter.
*
* Generated from protobuf field string filter = 4;
*/
- private $filter = '';
+ protected $filter = '';
/**
* Sort results. Supported values are "name", "name desc", or "" (unsorted).
*
* Generated from protobuf field string order_by = 5;
*/
- private $order_by = '';
+ protected $order_by = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/ListInstancesResponse.php b/DataFusion/src/V1/ListInstancesResponse.php
index 7908b0518f2b..95f50a1e2b08 100644
--- a/DataFusion/src/V1/ListInstancesResponse.php
+++ b/DataFusion/src/V1/ListInstancesResponse.php
@@ -27,7 +27,7 @@ class ListInstancesResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string next_page_token = 2;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Locations that could not be reached.
*
diff --git a/DataFusion/src/V1/NetworkConfig.php b/DataFusion/src/V1/NetworkConfig.php
index 890dac8096e8..6a65391a768e 100644
--- a/DataFusion/src/V1/NetworkConfig.php
+++ b/DataFusion/src/V1/NetworkConfig.php
@@ -28,7 +28,7 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string network = 1;
*/
- private $network = '';
+ protected $network = '';
/**
* The IP range in CIDR notation to use for the managed Data Fusion instance
* nodes. This range must not overlap with any other ranges used in the
@@ -36,7 +36,7 @@ class NetworkConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string ip_allocation = 2;
*/
- private $ip_allocation = '';
+ protected $ip_allocation = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/OperationMetadata.php b/DataFusion/src/V1/OperationMetadata.php
index 2399455b1f86..6e092c20d7a7 100644
--- a/DataFusion/src/V1/OperationMetadata.php
+++ b/DataFusion/src/V1/OperationMetadata.php
@@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp create_time = 1;
*/
- private $create_time = null;
+ protected $create_time = null;
/**
* The time the operation finished running.
*
* Generated from protobuf field .google.protobuf.Timestamp end_time = 2;
*/
- private $end_time = null;
+ protected $end_time = null;
/**
* Server-defined resource path for the target of the operation.
*
* Generated from protobuf field string target = 3;
*/
- private $target = '';
+ protected $target = '';
/**
* Name of the verb executed by the operation.
*
* Generated from protobuf field string verb = 4;
*/
- private $verb = '';
+ protected $verb = '';
/**
* Human-readable status of the operation if any.
*
* Generated from protobuf field string status_detail = 5;
*/
- private $status_detail = '';
+ protected $status_detail = '';
/**
* Identifies whether the user has requested cancellation
* of the operation. Operations that have successfully been cancelled
@@ -53,13 +53,13 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bool requested_cancellation = 6;
*/
- private $requested_cancellation = false;
+ protected $requested_cancellation = false;
/**
* API version used to start the operation.
*
* Generated from protobuf field string api_version = 7;
*/
- private $api_version = '';
+ protected $api_version = '';
/**
* Map to hold any additional status info for the operation
* If there is an accelerator being enabled/disabled/deleted, this will be
diff --git a/DataFusion/src/V1/RestartInstanceRequest.php b/DataFusion/src/V1/RestartInstanceRequest.php
index cf317c82931d..907af0135078 100644
--- a/DataFusion/src/V1/RestartInstanceRequest.php
+++ b/DataFusion/src/V1/RestartInstanceRequest.php
@@ -21,7 +21,7 @@ class RestartInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* Constructor.
diff --git a/DataFusion/src/V1/UpdateInstanceRequest.php b/DataFusion/src/V1/UpdateInstanceRequest.php
index 2962cebafac8..bfa27509b610 100644
--- a/DataFusion/src/V1/UpdateInstanceRequest.php
+++ b/DataFusion/src/V1/UpdateInstanceRequest.php
@@ -24,7 +24,7 @@ class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.datafusion.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $instance = null;
+ protected $instance = null;
/**
* Field mask is used to specify the fields that the update will overwrite
* in an instance resource. The fields specified in the update_mask are
@@ -35,7 +35,7 @@ class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.FieldMask update_mask = 2;
*/
- private $update_mask = null;
+ protected $update_mask = null;
/**
* @param \Google\Cloud\DataFusion\V1\Instance $instance Required. The instance resource that replaces the resource on the server. Currently,
diff --git a/DataFusion/src/V1/Version.php b/DataFusion/src/V1/Version.php
index ea0524cc6e58..96841661c8c1 100644
--- a/DataFusion/src/V1/Version.php
+++ b/DataFusion/src/V1/Version.php
@@ -21,13 +21,13 @@ class Version extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string version_number = 1;
*/
- private $version_number = '';
+ protected $version_number = '';
/**
* Whether this is currently the default version for Cloud Data Fusion
*
* Generated from protobuf field bool default_version = 2;
*/
- private $default_version = false;
+ protected $default_version = false;
/**
* Represents a list of available feature names for a given version.
*
@@ -39,7 +39,7 @@ class Version extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.datafusion.v1.Version.Type type = 4;
*/
- private $type = 0;
+ protected $type = 0;
/**
* Constructor.
diff --git a/DataFusion/tests/Unit/V1/Client/DataFusionClientTest.php b/DataFusion/tests/Unit/V1/Client/DataFusionClientTest.php
index 2330c41f6fd9..9be470a733fd 100644
--- a/DataFusion/tests/Unit/V1/Client/DataFusionClientTest.php
+++ b/DataFusion/tests/Unit/V1/Client/DataFusionClientTest.php
@@ -1,6 +1,6 @@
getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return DataFusionClient */
@@ -141,9 +143,7 @@ public function createInstanceTest()
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$instanceId = 'instanceId-2101995259';
- $request = (new CreateInstanceRequest())
- ->setParent($formattedParent)
- ->setInstanceId($instanceId);
+ $request = (new CreateInstanceRequest())->setParent($formattedParent)->setInstanceId($instanceId);
$response = $gapicClient->createInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -201,19 +201,20 @@ public function createInstanceExceptionTest()
$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
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$instanceId = 'instanceId-2101995259';
- $request = (new CreateInstanceRequest())
- ->setParent($formattedParent)
- ->setInstanceId($instanceId);
+ $request = (new CreateInstanceRequest())->setParent($formattedParent)->setInstanceId($instanceId);
$response = $gapicClient->createInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -267,8 +268,7 @@ public function deleteInstanceTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new DeleteInstanceRequest())
- ->setName($formattedName);
+ $request = (new DeleteInstanceRequest())->setName($formattedName);
$response = $gapicClient->deleteInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -324,17 +324,19 @@ public function deleteInstanceExceptionTest()
$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
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new DeleteInstanceRequest())
- ->setName($formattedName);
+ $request = (new DeleteInstanceRequest())->setName($formattedName);
$response = $gapicClient->deleteInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -404,8 +406,7 @@ public function getInstanceTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new GetInstanceRequest())
- ->setName($formattedName);
+ $request = (new GetInstanceRequest())->setName($formattedName);
$response = $gapicClient->getInstance($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -429,17 +430,19 @@ public function getInstanceExceptionTest()
$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);
// Mock request
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new GetInstanceRequest())
- ->setName($formattedName);
+ $request = (new GetInstanceRequest())->setName($formattedName);
try {
$gapicClient->getInstance($request);
// If the $gapicClient method call did not throw, fail the test
@@ -464,17 +467,14 @@ public function listAvailableVersionsTest()
// Mock response
$nextPageToken = '';
$availableVersionsElement = new Version();
- $availableVersions = [
- $availableVersionsElement,
- ];
+ $availableVersions = [$availableVersionsElement];
$expectedResponse = new ListAvailableVersionsResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setAvailableVersions($availableVersions);
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListAvailableVersionsRequest())
- ->setParent($formattedParent);
+ $request = (new ListAvailableVersionsRequest())->setParent($formattedParent);
$response = $gapicClient->listAvailableVersions($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -501,17 +501,19 @@ public function listAvailableVersionsExceptionTest()
$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);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListAvailableVersionsRequest())
- ->setParent($formattedParent);
+ $request = (new ListAvailableVersionsRequest())->setParent($formattedParent);
try {
$gapicClient->listAvailableVersions($request);
// If the $gapicClient method call did not throw, fail the test
@@ -536,17 +538,14 @@ public function listInstancesTest()
// Mock response
$nextPageToken = '';
$instancesElement = new Instance();
- $instances = [
- $instancesElement,
- ];
+ $instances = [$instancesElement];
$expectedResponse = new ListInstancesResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setInstances($instances);
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListInstancesRequest())
- ->setParent($formattedParent);
+ $request = (new ListInstancesRequest())->setParent($formattedParent);
$response = $gapicClient->listInstances($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -573,17 +572,19 @@ public function listInstancesExceptionTest()
$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);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListInstancesRequest())
- ->setParent($formattedParent);
+ $request = (new ListInstancesRequest())->setParent($formattedParent);
try {
$gapicClient->listInstances($request);
// If the $gapicClient method call did not throw, fail the test
@@ -662,8 +663,7 @@ public function restartInstanceTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new RestartInstanceRequest())
- ->setName($formattedName);
+ $request = (new RestartInstanceRequest())->setName($formattedName);
$response = $gapicClient->restartInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -719,17 +719,19 @@ public function restartInstanceExceptionTest()
$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
$formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $request = (new RestartInstanceRequest())
- ->setName($formattedName);
+ $request = (new RestartInstanceRequest())->setName($formattedName);
$response = $gapicClient->restartInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -819,8 +821,7 @@ public function updateInstanceTest()
$instance = new Instance();
$instanceType = Type::TYPE_UNSPECIFIED;
$instance->setType($instanceType);
- $request = (new UpdateInstanceRequest())
- ->setInstance($instance);
+ $request = (new UpdateInstanceRequest())->setInstance($instance);
$response = $gapicClient->updateInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -876,19 +877,21 @@ public function updateInstanceExceptionTest()
$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
$instance = new Instance();
$instanceType = Type::TYPE_UNSPECIFIED;
$instance->setType($instanceType);
- $request = (new UpdateInstanceRequest())
- ->setInstance($instance);
+ $request = (new UpdateInstanceRequest())->setInstance($instance);
$response = $gapicClient->updateInstance($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -977,9 +980,7 @@ public function createInstanceAsyncTest()
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$instanceId = 'instanceId-2101995259';
- $request = (new CreateInstanceRequest())
- ->setParent($formattedParent)
- ->setInstanceId($instanceId);
+ $request = (new CreateInstanceRequest())->setParent($formattedParent)->setInstanceId($instanceId);
$response = $gapicClient->createInstanceAsync($request)->wait();
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
diff --git a/DataFusion/tests/Unit/V1/DataFusionClientTest.php b/DataFusion/tests/Unit/V1/DataFusionClientTest.php
deleted file mode 100644
index 76f61787e25a..000000000000
--- a/DataFusion/tests/Unit/V1/DataFusionClientTest.php
+++ /dev/null
@@ -1,876 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
- }
-
- /** @return DataFusionClient */
- private function createClient(array $options = [])
- {
- $options += [
- 'credentials' => $this->createCredentials(),
- ];
- return new DataFusionClient($options);
- }
-
- /** @test */
- public function createInstanceTest()
- {
- $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/createInstanceTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $name = 'name3373707';
- $description = 'description-1724546052';
- $enableStackdriverLogging = true;
- $enableStackdriverMonitoring = false;
- $privateInstance = false;
- $stateMessage = 'stateMessage29641305';
- $serviceEndpoint = 'serviceEndpoint-676052001';
- $zone = 'zone3744684';
- $version = 'version351608024';
- $serviceAccount = 'serviceAccount-1948028253';
- $displayName = 'displayName1615086568';
- $apiEndpoint = 'apiEndpoint-1381395942';
- $gcsBucket = 'gcsBucket-1720393710';
- $p4ServiceAccount = 'p4ServiceAccount-1554461144';
- $tenantProjectId = 'tenantProjectId-2129337674';
- $dataprocServiceAccount = 'dataprocServiceAccount-493324700';
- $enableRbac = true;
- $expectedResponse = new Instance();
- $expectedResponse->setName($name);
- $expectedResponse->setDescription($description);
- $expectedResponse->setEnableStackdriverLogging($enableStackdriverLogging);
- $expectedResponse->setEnableStackdriverMonitoring($enableStackdriverMonitoring);
- $expectedResponse->setPrivateInstance($privateInstance);
- $expectedResponse->setStateMessage($stateMessage);
- $expectedResponse->setServiceEndpoint($serviceEndpoint);
- $expectedResponse->setZone($zone);
- $expectedResponse->setVersion($version);
- $expectedResponse->setServiceAccount($serviceAccount);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setApiEndpoint($apiEndpoint);
- $expectedResponse->setGcsBucket($gcsBucket);
- $expectedResponse->setP4ServiceAccount($p4ServiceAccount);
- $expectedResponse->setTenantProjectId($tenantProjectId);
- $expectedResponse->setDataprocServiceAccount($dataprocServiceAccount);
- $expectedResponse->setEnableRbac($enableRbac);
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/createInstanceTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $instanceId = 'instanceId-2101995259';
- $response = $gapicClient->createInstance($formattedParent, $instanceId);
- $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.datafusion.v1.DataFusion/CreateInstance', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualApiRequestObject->getInstanceId();
- $this->assertProtobufEquals($instanceId, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/createInstanceTest');
- $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 createInstanceExceptionTest()
- {
- $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/createInstanceTest');
- $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
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $instanceId = 'instanceId-2101995259';
- $response = $gapicClient->createInstance($formattedParent, $instanceId);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/createInstanceTest');
- 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 deleteInstanceTest()
- {
- $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/deleteInstanceTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new GPBEmpty();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/deleteInstanceTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $response = $gapicClient->deleteInstance($formattedName);
- $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.datafusion.v1.DataFusion/DeleteInstance', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/deleteInstanceTest');
- $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 deleteInstanceExceptionTest()
- {
- $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/deleteInstanceTest');
- $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
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $response = $gapicClient->deleteInstance($formattedName);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/deleteInstanceTest');
- 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 getInstanceTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name2 = 'name2-1052831874';
- $description = 'description-1724546052';
- $enableStackdriverLogging = true;
- $enableStackdriverMonitoring = false;
- $privateInstance = false;
- $stateMessage = 'stateMessage29641305';
- $serviceEndpoint = 'serviceEndpoint-676052001';
- $zone = 'zone3744684';
- $version = 'version351608024';
- $serviceAccount = 'serviceAccount-1948028253';
- $displayName = 'displayName1615086568';
- $apiEndpoint = 'apiEndpoint-1381395942';
- $gcsBucket = 'gcsBucket-1720393710';
- $p4ServiceAccount = 'p4ServiceAccount-1554461144';
- $tenantProjectId = 'tenantProjectId-2129337674';
- $dataprocServiceAccount = 'dataprocServiceAccount-493324700';
- $enableRbac = true;
- $expectedResponse = new Instance();
- $expectedResponse->setName($name2);
- $expectedResponse->setDescription($description);
- $expectedResponse->setEnableStackdriverLogging($enableStackdriverLogging);
- $expectedResponse->setEnableStackdriverMonitoring($enableStackdriverMonitoring);
- $expectedResponse->setPrivateInstance($privateInstance);
- $expectedResponse->setStateMessage($stateMessage);
- $expectedResponse->setServiceEndpoint($serviceEndpoint);
- $expectedResponse->setZone($zone);
- $expectedResponse->setVersion($version);
- $expectedResponse->setServiceAccount($serviceAccount);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setApiEndpoint($apiEndpoint);
- $expectedResponse->setGcsBucket($gcsBucket);
- $expectedResponse->setP4ServiceAccount($p4ServiceAccount);
- $expectedResponse->setTenantProjectId($tenantProjectId);
- $expectedResponse->setDataprocServiceAccount($dataprocServiceAccount);
- $expectedResponse->setEnableRbac($enableRbac);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $response = $gapicClient->getInstance($formattedName);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.datafusion.v1.DataFusion/GetInstance', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getInstanceExceptionTest()
- {
- $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);
- // Mock request
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- try {
- $gapicClient->getInstance($formattedName);
- // 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 listAvailableVersionsTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $availableVersionsElement = new Version();
- $availableVersions = [
- $availableVersionsElement,
- ];
- $expectedResponse = new ListAvailableVersionsResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setAvailableVersions($availableVersions);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->listAvailableVersions($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getAvailableVersions()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.datafusion.v1.DataFusion/ListAvailableVersions', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listAvailableVersionsExceptionTest()
- {
- $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);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- try {
- $gapicClient->listAvailableVersions($formattedParent);
- // 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 listInstancesTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $instancesElement = new Instance();
- $instances = [
- $instancesElement,
- ];
- $expectedResponse = new ListInstancesResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setInstances($instances);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->listInstances($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getInstances()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.datafusion.v1.DataFusion/ListInstances', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listInstancesExceptionTest()
- {
- $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);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- try {
- $gapicClient->listInstances($formattedParent);
- // 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 restartInstanceTest()
- {
- $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/restartInstanceTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $name2 = 'name2-1052831874';
- $description = 'description-1724546052';
- $enableStackdriverLogging = true;
- $enableStackdriverMonitoring = false;
- $privateInstance = false;
- $stateMessage = 'stateMessage29641305';
- $serviceEndpoint = 'serviceEndpoint-676052001';
- $zone = 'zone3744684';
- $version = 'version351608024';
- $serviceAccount = 'serviceAccount-1948028253';
- $displayName = 'displayName1615086568';
- $apiEndpoint = 'apiEndpoint-1381395942';
- $gcsBucket = 'gcsBucket-1720393710';
- $p4ServiceAccount = 'p4ServiceAccount-1554461144';
- $tenantProjectId = 'tenantProjectId-2129337674';
- $dataprocServiceAccount = 'dataprocServiceAccount-493324700';
- $enableRbac = true;
- $expectedResponse = new Instance();
- $expectedResponse->setName($name2);
- $expectedResponse->setDescription($description);
- $expectedResponse->setEnableStackdriverLogging($enableStackdriverLogging);
- $expectedResponse->setEnableStackdriverMonitoring($enableStackdriverMonitoring);
- $expectedResponse->setPrivateInstance($privateInstance);
- $expectedResponse->setStateMessage($stateMessage);
- $expectedResponse->setServiceEndpoint($serviceEndpoint);
- $expectedResponse->setZone($zone);
- $expectedResponse->setVersion($version);
- $expectedResponse->setServiceAccount($serviceAccount);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setApiEndpoint($apiEndpoint);
- $expectedResponse->setGcsBucket($gcsBucket);
- $expectedResponse->setP4ServiceAccount($p4ServiceAccount);
- $expectedResponse->setTenantProjectId($tenantProjectId);
- $expectedResponse->setDataprocServiceAccount($dataprocServiceAccount);
- $expectedResponse->setEnableRbac($enableRbac);
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/restartInstanceTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $response = $gapicClient->restartInstance($formattedName);
- $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.datafusion.v1.DataFusion/RestartInstance', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/restartInstanceTest');
- $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 restartInstanceExceptionTest()
- {
- $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/restartInstanceTest');
- $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
- $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
- $response = $gapicClient->restartInstance($formattedName);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/restartInstanceTest');
- 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 updateInstanceTest()
- {
- $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/updateInstanceTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $name = 'name3373707';
- $description = 'description-1724546052';
- $enableStackdriverLogging = true;
- $enableStackdriverMonitoring = false;
- $privateInstance = false;
- $stateMessage = 'stateMessage29641305';
- $serviceEndpoint = 'serviceEndpoint-676052001';
- $zone = 'zone3744684';
- $version = 'version351608024';
- $serviceAccount = 'serviceAccount-1948028253';
- $displayName = 'displayName1615086568';
- $apiEndpoint = 'apiEndpoint-1381395942';
- $gcsBucket = 'gcsBucket-1720393710';
- $p4ServiceAccount = 'p4ServiceAccount-1554461144';
- $tenantProjectId = 'tenantProjectId-2129337674';
- $dataprocServiceAccount = 'dataprocServiceAccount-493324700';
- $enableRbac = true;
- $expectedResponse = new Instance();
- $expectedResponse->setName($name);
- $expectedResponse->setDescription($description);
- $expectedResponse->setEnableStackdriverLogging($enableStackdriverLogging);
- $expectedResponse->setEnableStackdriverMonitoring($enableStackdriverMonitoring);
- $expectedResponse->setPrivateInstance($privateInstance);
- $expectedResponse->setStateMessage($stateMessage);
- $expectedResponse->setServiceEndpoint($serviceEndpoint);
- $expectedResponse->setZone($zone);
- $expectedResponse->setVersion($version);
- $expectedResponse->setServiceAccount($serviceAccount);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setApiEndpoint($apiEndpoint);
- $expectedResponse->setGcsBucket($gcsBucket);
- $expectedResponse->setP4ServiceAccount($p4ServiceAccount);
- $expectedResponse->setTenantProjectId($tenantProjectId);
- $expectedResponse->setDataprocServiceAccount($dataprocServiceAccount);
- $expectedResponse->setEnableRbac($enableRbac);
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/updateInstanceTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $instance = new Instance();
- $instanceType = Type::TYPE_UNSPECIFIED;
- $instance->setType($instanceType);
- $response = $gapicClient->updateInstance($instance);
- $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.datafusion.v1.DataFusion/UpdateInstance', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getInstance();
- $this->assertProtobufEquals($instance, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/updateInstanceTest');
- $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 updateInstanceExceptionTest()
- {
- $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/updateInstanceTest');
- $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
- $instance = new Instance();
- $instanceType = Type::TYPE_UNSPECIFIED;
- $instance->setType($instanceType);
- $response = $gapicClient->updateInstance($instance);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/updateInstanceTest');
- 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());
- }
-}