diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json
index 49b3491111d7..1f924813db02 100644
--- a/.repo-metadata-full.json
+++ b/.repo-metadata-full.json
@@ -778,7 +778,7 @@
"Ids": {
"language": "php",
"distribution_name": "google/cloud-ids",
- "release_level": "preview",
+ "release_level": "stable",
"client_documentation": "https://cloud.google.com/php/docs/reference/cloud-ids/latest",
"library_type": "GAPIC_AUTO",
"api_shortname": "ids"
diff --git a/Ids/README.md b/Ids/README.md
index ccdd27435e2b..09440faf5b8b 100644
--- a/Ids/README.md
+++ b/Ids/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/Ids/owlbot.py b/Ids/owlbot.py
index 0ba12d50ced5..c20d5eeb904a 100644
--- a/Ids/owlbot.py
+++ b/Ids/owlbot.py
@@ -1,4 +1,4 @@
-# Copyright 2022 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.
@@ -30,13 +30,7 @@
# Added so that we can pass copy_excludes in the owlbot_main() call
_tracked_paths.add(src)
-php.owlbot_main(
- src=src,
- dest=dest,
- copy_excludes=[
- src / "**/[A-Z]*_*.php"
- ]
-)
+php.owlbot_main(src=src, dest=dest)
# remove class_alias code
s.replace(
@@ -47,32 +41,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 +49,8 @@
'--package=@prettier/plugin-php@^0.16',
'--',
'prettier',
- '**/Gapic/*',
+ '**/Client/*',
'--write',
'--parser=php',
'--single-quote',
- '--print-width=80'])
+ '--print-width=120'])
diff --git a/Ids/src/V1/Client/IDSClient.php b/Ids/src/V1/Client/IDSClient.php
index 0351ecc04bc0..1588e03eed83 100644
--- a/Ids/src/V1/Client/IDSClient.php
+++ b/Ids/src/V1/Client/IDSClient.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 endpoint
* resource.
diff --git a/Ids/src/V1/CreateEndpointRequest.php b/Ids/src/V1/CreateEndpointRequest.php
index c411fd5848ac..928ba143eaf5 100644
--- a/Ids/src/V1/CreateEndpointRequest.php
+++ b/Ids/src/V1/CreateEndpointRequest.php
@@ -18,7 +18,7 @@ class CreateEndpointRequest 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 endpoint identifier. This will be part of the endpoint's
* resource name.
@@ -29,13 +29,13 @@ class CreateEndpointRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string endpoint_id = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $endpoint_id = '';
+ protected $endpoint_id = '';
/**
* Required. The endpoint to create.
*
* Generated from protobuf field .google.cloud.ids.v1.Endpoint endpoint = 3 [(.google.api.field_behavior) = REQUIRED];
*/
- private $endpoint = null;
+ protected $endpoint = null;
/**
* An optional request ID to identify requests. Specify a unique request ID
* so that if you must retry your request, the server will know to ignore
@@ -51,7 +51,7 @@ class CreateEndpointRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string request_id = 4;
*/
- private $request_id = '';
+ protected $request_id = '';
/**
* @param string $parent Required. The endpoint's parent. Please see
diff --git a/Ids/src/V1/DeleteEndpointRequest.php b/Ids/src/V1/DeleteEndpointRequest.php
index b2e4ea6e9be8..fa24daaf67d1 100644
--- a/Ids/src/V1/DeleteEndpointRequest.php
+++ b/Ids/src/V1/DeleteEndpointRequest.php
@@ -18,7 +18,7 @@ class DeleteEndpointRequest 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 = '';
/**
* An optional request ID to identify requests. Specify a unique request ID
* so that if you must retry your request, the server will know to ignore
@@ -34,7 +34,7 @@ class DeleteEndpointRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string request_id = 2;
*/
- private $request_id = '';
+ protected $request_id = '';
/**
* @param string $name Required. The name of the endpoint to delete. Please see
diff --git a/Ids/src/V1/Endpoint.php b/Ids/src/V1/Endpoint.php
index a59e611439d7..f6410808a084 100644
--- a/Ids/src/V1/Endpoint.php
+++ b/Ids/src/V1/Endpoint.php
@@ -21,19 +21,19 @@ class Endpoint extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $name = '';
+ protected $name = '';
/**
* Output only. The create time timestamp.
*
* Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $create_time = null;
+ protected $create_time = null;
/**
* Output only. The update time timestamp.
*
* Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $update_time = null;
+ protected $update_time = null;
/**
* The labels of the endpoint.
*
@@ -46,43 +46,43 @@ class Endpoint extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string network = 5 [(.google.api.field_behavior) = REQUIRED];
*/
- private $network = '';
+ protected $network = '';
/**
* Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule.
*
* Generated from protobuf field string endpoint_forwarding_rule = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $endpoint_forwarding_rule = '';
+ protected $endpoint_forwarding_rule = '';
/**
* Output only. The IP address of the IDS Endpoint's ILB.
*
* Generated from protobuf field string endpoint_ip = 7 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $endpoint_ip = '';
+ protected $endpoint_ip = '';
/**
* User-provided description of the endpoint
*
* Generated from protobuf field string description = 8;
*/
- private $description = '';
+ protected $description = '';
/**
* Required. Lowest threat severity that this endpoint will alert on.
*
* Generated from protobuf field .google.cloud.ids.v1.Endpoint.Severity severity = 9 [(.google.api.field_behavior) = REQUIRED];
*/
- private $severity = 0;
+ protected $severity = 0;
/**
* Output only. Current state of the endpoint.
*
* Generated from protobuf field .google.cloud.ids.v1.Endpoint.State state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $state = 0;
+ protected $state = 0;
/**
* Whether the endpoint should report traffic logs in addition to threat logs.
*
* Generated from protobuf field bool traffic_logs = 13;
*/
- private $traffic_logs = false;
+ protected $traffic_logs = false;
/**
* Constructor.
diff --git a/Ids/src/V1/Gapic/IDSGapicClient.php b/Ids/src/V1/Gapic/IDSGapicClient.php
deleted file mode 100644
index be0801d4cd0d..000000000000
--- a/Ids/src/V1/Gapic/IDSGapicClient.php
+++ /dev/null
@@ -1,701 +0,0 @@
-locationName('[PROJECT]', '[LOCATION]');
- * $endpointId = 'endpoint_id';
- * $endpoint = new Endpoint();
- * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- * $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 = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'createEndpoint');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $iDSClient->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\Ids\V1\Client\IDSClient}.
- */
-class IDSGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.ids.v1.IDS';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'ids.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'ids.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 $endpointNameTemplate;
-
- 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/ids_client_config.json',
- 'descriptorsConfigPath' =>
- __DIR__ . '/../resources/ids_descriptor_config.php',
- 'gcpApiConfigPath' =>
- __DIR__ . '/../resources/ids_grpc_config.json',
- 'credentialsConfig' => [
- 'defaultScopes' => self::$serviceScopes,
- ],
- 'transportConfig' => [
- 'rest' => [
- 'restClientConfigPath' =>
- __DIR__ . '/../resources/ids_rest_client_config.php',
- ],
- ],
- ];
- }
-
- private static function getEndpointNameTemplate()
- {
- if (self::$endpointNameTemplate == null) {
- self::$endpointNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/endpoints/{endpoint}'
- );
- }
-
- return self::$endpointNameTemplate;
- }
-
- 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 = [
- 'endpoint' => self::getEndpointNameTemplate(),
- 'location' => self::getLocationNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a endpoint
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $endpoint
- *
- * @return string The formatted endpoint resource.
- */
- public static function endpointName($project, $location, $endpoint)
- {
- return self::getEndpointNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'endpoint' => $endpoint,
- ]);
- }
-
- /**
- * 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
- * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint}
- * - 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 'ids.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 Endpoint in a given project and location.
- *
- * Sample code:
- * ```
- * $iDSClient = new IDSClient();
- * try {
- * $formattedParent = $iDSClient->locationName('[PROJECT]', '[LOCATION]');
- * $endpointId = 'endpoint_id';
- * $endpoint = new Endpoint();
- * $operationResponse = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- * $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 = $iDSClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'createEndpoint');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $iDSClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The endpoint's parent.
- * @param string $endpointId Required. The endpoint identifier. This will be part of the endpoint's
- * resource name.
- * This value must start with a lowercase letter followed by up to 62
- * lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
- * Values that do not match this pattern will trigger an INVALID_ARGUMENT
- * error.
- * @param Endpoint $endpoint Required. The endpoint to create.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $requestId
- * An optional request ID to identify requests. Specify a unique request ID
- * so that if you must retry your request, the server will know to ignore
- * the request if it has already been completed. The server will guarantee
- * that for at least 60 minutes since the first request.
- *
- * For example, consider a situation where you make an initial request and t
- * he request times out. If you make the request again with the same request
- * ID, the server can check if original operation with the same request ID
- * was received, and if so, will ignore the second request. This prevents
- * clients from accidentally creating duplicate commitments.
- *
- * The request ID must be a valid UUID with the exception that zero UUID is
- * not supported (00000000-0000-0000-0000-000000000000).
- * @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 createEndpoint(
- $parent,
- $endpointId,
- $endpoint,
- array $optionalArgs = []
- ) {
- $request = new CreateEndpointRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setEndpointId($endpointId);
- $request->setEndpoint($endpoint);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['requestId'])) {
- $request->setRequestId($optionalArgs['requestId']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'CreateEndpoint',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Deletes a single Endpoint.
- *
- * Sample code:
- * ```
- * $iDSClient = new IDSClient();
- * try {
- * $formattedName = $iDSClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- * $operationResponse = $iDSClient->deleteEndpoint($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 = $iDSClient->deleteEndpoint($formattedName);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $iDSClient->resumeOperation($operationName, 'deleteEndpoint');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * // operation succeeded and returns no value
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $iDSClient->close();
- * }
- * ```
- *
- * @param string $name Required. The name of the endpoint to delete.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $requestId
- * An optional request ID to identify requests. Specify a unique request ID
- * so that if you must retry your request, the server will know to ignore
- * the request if it has already been completed. The server will guarantee
- * that for at least 60 minutes after the first request.
- *
- * For example, consider a situation where you make an initial request and t
- * he request times out. If you make the request again with the same request
- * ID, the server can check if original operation with the same request ID
- * was received, and if so, will ignore the second request. This prevents
- * clients from accidentally creating duplicate commitments.
- *
- * The request ID must be a valid UUID with the exception that zero UUID is
- * not supported (00000000-0000-0000-0000-000000000000).
- * @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 deleteEndpoint($name, array $optionalArgs = [])
- {
- $request = new DeleteEndpointRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- if (isset($optionalArgs['requestId'])) {
- $request->setRequestId($optionalArgs['requestId']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'DeleteEndpoint',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Gets details of a single Endpoint.
- *
- * Sample code:
- * ```
- * $iDSClient = new IDSClient();
- * try {
- * $formattedName = $iDSClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- * $response = $iDSClient->getEndpoint($formattedName);
- * } finally {
- * $iDSClient->close();
- * }
- * ```
- *
- * @param string $name Required. The name of the endpoint to retrieve.
- * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`
- * @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\Ids\V1\Endpoint
- *
- * @throws ApiException if the remote call fails
- */
- public function getEndpoint($name, array $optionalArgs = [])
- {
- $request = new GetEndpointRequest();
- $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(
- 'GetEndpoint',
- Endpoint::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Lists Endpoints in a given project and location.
- *
- * Sample code:
- * ```
- * $iDSClient = new IDSClient();
- * try {
- * $formattedParent = $iDSClient->locationName('[PROJECT]', '[LOCATION]');
- * // Iterate over pages of elements
- * $pagedResponse = $iDSClient->listEndpoints($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $iDSClient->listEndpoints($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $iDSClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The parent, which owns this collection of endpoints.
- * @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
- * Optional. The filter expression, following the syntax outlined in
- * https://google.aip.dev/160.
- * @type string $orderBy
- * Optional. One or more fields to compare and use to sort the output.
- * See https://google.aip.dev/132#ordering.
- * @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 listEndpoints($parent, array $optionalArgs = [])
- {
- $request = new ListEndpointsRequest();
- $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(
- 'ListEndpoints',
- $optionalArgs,
- ListEndpointsResponse::class,
- $request
- );
- }
-}
diff --git a/Ids/src/V1/GetEndpointRequest.php b/Ids/src/V1/GetEndpointRequest.php
index 95095044e893..adf2a00628ad 100644
--- a/Ids/src/V1/GetEndpointRequest.php
+++ b/Ids/src/V1/GetEndpointRequest.php
@@ -19,7 +19,7 @@ class GetEndpointRequest 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 name of the endpoint to retrieve.
diff --git a/Ids/src/V1/IDSClient.php b/Ids/src/V1/IDSClient.php
deleted file mode 100644
index ee498ea47b60..000000000000
--- a/Ids/src/V1/IDSClient.php
+++ /dev/null
@@ -1,34 +0,0 @@
-_simpleRequest('/google.cloud.ids.v1.IDS/ListEndpoints',
- $argument,
- ['\Google\Cloud\Ids\V1\ListEndpointsResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Gets details of a single Endpoint.
- * @param \Google\Cloud\Ids\V1\GetEndpointRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function GetEndpoint(\Google\Cloud\Ids\V1\GetEndpointRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.ids.v1.IDS/GetEndpoint',
- $argument,
- ['\Google\Cloud\Ids\V1\Endpoint', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Creates a new Endpoint in a given project and location.
- * @param \Google\Cloud\Ids\V1\CreateEndpointRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function CreateEndpoint(\Google\Cloud\Ids\V1\CreateEndpointRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.ids.v1.IDS/CreateEndpoint',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Deletes a single Endpoint.
- * @param \Google\Cloud\Ids\V1\DeleteEndpointRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function DeleteEndpoint(\Google\Cloud\Ids\V1\DeleteEndpointRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.ids.v1.IDS/DeleteEndpoint',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/Ids/src/V1/ListEndpointsRequest.php b/Ids/src/V1/ListEndpointsRequest.php
index 577524d5a60e..e566c2aff1b6 100644
--- a/Ids/src/V1/ListEndpointsRequest.php
+++ b/Ids/src/V1/ListEndpointsRequest.php
@@ -18,14 +18,14 @@ class ListEndpointsRequest 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 = '';
/**
* Optional. The maximum number of endpoints to return. The service may return fewer
* than this value.
*
* Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* Optional. A page token, received from a previous `ListEndpoints` call.
* Provide this to retrieve the subsequent page.
@@ -34,21 +34,21 @@ class ListEndpointsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* Optional. The filter expression, following the syntax outlined in
* https://google.aip.dev/160.
*
* Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $filter = '';
+ protected $filter = '';
/**
* Optional. One or more fields to compare and use to sort the output.
* See https://google.aip.dev/132#ordering.
*
* Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $order_by = '';
+ protected $order_by = '';
/**
* @param string $parent Required. The parent, which owns this collection of endpoints. Please see
diff --git a/Ids/src/V1/ListEndpointsResponse.php b/Ids/src/V1/ListEndpointsResponse.php
index 00a81ac7b9b1..c24d54eeef07 100644
--- a/Ids/src/V1/ListEndpointsResponse.php
+++ b/Ids/src/V1/ListEndpointsResponse.php
@@ -25,7 +25,7 @@ class ListEndpointsResponse 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/Ids/src/V1/OperationMetadata.php b/Ids/src/V1/OperationMetadata.php
index 4ff2fe963e04..50e0d626665f 100644
--- a/Ids/src/V1/OperationMetadata.php
+++ b/Ids/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 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $create_time = null;
+ protected $create_time = null;
/**
* Output only. The time the operation finished running.
*
* Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $end_time = null;
+ protected $end_time = null;
/**
* Output only. Server-defined resource path for the target of the operation.
*
* Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $target = '';
+ protected $target = '';
/**
* Output only. Name of the verb executed by the operation.
*
* Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $verb = '';
+ protected $verb = '';
/**
* Output only. Human-readable status of the operation, if any.
*
* Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $status_message = '';
+ protected $status_message = '';
/**
* Output only. 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 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $requested_cancellation = false;
+ protected $requested_cancellation = false;
/**
* Output only. API version used to start the operation.
*
* Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $api_version = '';
+ protected $api_version = '';
/**
* Constructor.
diff --git a/Ids/tests/Unit/V1/Client/IDSClientTest.php b/Ids/tests/Unit/V1/Client/IDSClientTest.php
index 15d1d4cd2a76..f050a03d8c0b 100644
--- a/Ids/tests/Unit/V1/Client/IDSClientTest.php
+++ b/Ids/tests/Unit/V1/Client/IDSClientTest.php
@@ -1,6 +1,6 @@
getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return IDSClient */
@@ -182,12 +184,15 @@ public function createEndpointExceptionTest()
$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]');
@@ -254,8 +259,7 @@ public function deleteEndpointTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$formattedName = $gapicClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $request = (new DeleteEndpointRequest())
- ->setName($formattedName);
+ $request = (new DeleteEndpointRequest())->setName($formattedName);
$response = $gapicClient->deleteEndpoint($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -311,17 +315,19 @@ public function deleteEndpointExceptionTest()
$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->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $request = (new DeleteEndpointRequest())
- ->setName($formattedName);
+ $request = (new DeleteEndpointRequest())->setName($formattedName);
$response = $gapicClient->deleteEndpoint($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -369,8 +375,7 @@ public function getEndpointTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $request = (new GetEndpointRequest())
- ->setName($formattedName);
+ $request = (new GetEndpointRequest())->setName($formattedName);
$response = $gapicClient->getEndpoint($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -394,17 +399,19 @@ public function getEndpointExceptionTest()
$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->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $request = (new GetEndpointRequest())
- ->setName($formattedName);
+ $request = (new GetEndpointRequest())->setName($formattedName);
try {
$gapicClient->getEndpoint($request);
// If the $gapicClient method call did not throw, fail the test
@@ -429,17 +436,14 @@ public function listEndpointsTest()
// Mock response
$nextPageToken = '';
$endpointsElement = new Endpoint();
- $endpoints = [
- $endpointsElement,
- ];
+ $endpoints = [$endpointsElement];
$expectedResponse = new ListEndpointsResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setEndpoints($endpoints);
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListEndpointsRequest())
- ->setParent($formattedParent);
+ $request = (new ListEndpointsRequest())->setParent($formattedParent);
$response = $gapicClient->listEndpoints($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -466,17 +470,19 @@ public function listEndpointsExceptionTest()
$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 ListEndpointsRequest())
- ->setParent($formattedParent);
+ $request = (new ListEndpointsRequest())->setParent($formattedParent);
try {
$gapicClient->listEndpoints($request);
// If the $gapicClient method call did not throw, fail the test
diff --git a/Ids/tests/Unit/V1/IDSClientTest.php b/Ids/tests/Unit/V1/IDSClientTest.php
deleted file mode 100644
index afb770d2c5dd..000000000000
--- a/Ids/tests/Unit/V1/IDSClientTest.php
+++ /dev/null
@@ -1,468 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
- }
-
- /** @return IDSClient */
- private function createClient(array $options = [])
- {
- $options += [
- 'credentials' => $this->createCredentials(),
- ];
- return new IDSClient($options);
- }
-
- /** @test */
- public function createEndpointTest()
- {
- $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/createEndpointTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $name = 'name3373707';
- $network = 'network1843485230';
- $endpointForwardingRule = 'endpointForwardingRule-1878786988';
- $endpointIp = 'endpointIp-1135808495';
- $description = 'description-1724546052';
- $trafficLogs = false;
- $expectedResponse = new Endpoint();
- $expectedResponse->setName($name);
- $expectedResponse->setNetwork($network);
- $expectedResponse->setEndpointForwardingRule($endpointForwardingRule);
- $expectedResponse->setEndpointIp($endpointIp);
- $expectedResponse->setDescription($description);
- $expectedResponse->setTrafficLogs($trafficLogs);
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/createEndpointTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $endpointId = 'endpointId-1135808507';
- $endpoint = new Endpoint();
- $endpointNetwork = 'endpointNetwork1670861529';
- $endpoint->setNetwork($endpointNetwork);
- $endpointSeverity = Severity::SEVERITY_UNSPECIFIED;
- $endpoint->setSeverity($endpointSeverity);
- $response = $gapicClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- $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.ids.v1.IDS/CreateEndpoint', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualApiRequestObject->getEndpointId();
- $this->assertProtobufEquals($endpointId, $actualValue);
- $actualValue = $actualApiRequestObject->getEndpoint();
- $this->assertProtobufEquals($endpoint, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/createEndpointTest');
- $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 createEndpointExceptionTest()
- {
- $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/createEndpointTest');
- $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]');
- $endpointId = 'endpointId-1135808507';
- $endpoint = new Endpoint();
- $endpointNetwork = 'endpointNetwork1670861529';
- $endpoint->setNetwork($endpointNetwork);
- $endpointSeverity = Severity::SEVERITY_UNSPECIFIED;
- $endpoint->setSeverity($endpointSeverity);
- $response = $gapicClient->createEndpoint($formattedParent, $endpointId, $endpoint);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/createEndpointTest');
- 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 deleteEndpointTest()
- {
- $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/deleteEndpointTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new GPBEmpty();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/deleteEndpointTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedName = $gapicClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $response = $gapicClient->deleteEndpoint($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.ids.v1.IDS/DeleteEndpoint', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/deleteEndpointTest');
- $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 deleteEndpointExceptionTest()
- {
- $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/deleteEndpointTest');
- $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->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $response = $gapicClient->deleteEndpoint($formattedName);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/deleteEndpointTest');
- 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 getEndpointTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name2 = 'name2-1052831874';
- $network = 'network1843485230';
- $endpointForwardingRule = 'endpointForwardingRule-1878786988';
- $endpointIp = 'endpointIp-1135808495';
- $description = 'description-1724546052';
- $trafficLogs = false;
- $expectedResponse = new Endpoint();
- $expectedResponse->setName($name2);
- $expectedResponse->setNetwork($network);
- $expectedResponse->setEndpointForwardingRule($endpointForwardingRule);
- $expectedResponse->setEndpointIp($endpointIp);
- $expectedResponse->setDescription($description);
- $expectedResponse->setTrafficLogs($trafficLogs);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- $response = $gapicClient->getEndpoint($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.ids.v1.IDS/GetEndpoint', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getEndpointExceptionTest()
- {
- $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->endpointName('[PROJECT]', '[LOCATION]', '[ENDPOINT]');
- try {
- $gapicClient->getEndpoint($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 listEndpointsTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $endpointsElement = new Endpoint();
- $endpoints = [
- $endpointsElement,
- ];
- $expectedResponse = new ListEndpointsResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setEndpoints($endpoints);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->listEndpoints($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getEndpoints()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.ids.v1.IDS/ListEndpoints', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listEndpointsExceptionTest()
- {
- $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->listEndpoints($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());
- }
-}