From a44ba3c1c93d35015505c94369fbfe66e3aefe35 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 20 Jun 2024 18:03:00 +0000 Subject: [PATCH] chore!: promote BeyondCorp to v1 --- .repo-metadata-full.json | 12 +- BeyondCorpAppConnections/.OwlBot.yaml | 4 +- BeyondCorpAppConnections/owlbot.py | 40 +- .../src/V1/AppConnection.php | 18 +- .../V1/AppConnection/ApplicationEndpoint.php | 4 +- .../src/V1/AppConnection/Gateway.php | 8 +- .../src/V1/AppConnectionOperationMetadata.php | 14 +- .../src/V1/AppConnectionsServiceClient.php | 34 - .../V1/AppConnectionsServiceGrpcClient.php | 140 -- .../V1/Client/AppConnectionsServiceClient.php | 43 +- .../src/V1/CreateAppConnectionRequest.php | 10 +- .../src/V1/DeleteAppConnectionRequest.php | 6 +- .../AppConnectionsServiceGapicClient.php | 1363 ----------------- .../src/V1/GetAppConnectionRequest.php | 2 +- .../src/V1/ListAppConnectionsRequest.php | 10 +- .../src/V1/ListAppConnectionsResponse.php | 2 +- .../src/V1/ResolveAppConnectionsRequest.php | 8 +- .../src/V1/ResolveAppConnectionsResponse.php | 2 +- .../AppConnectionDetails.php | 2 +- .../src/V1/UpdateAppConnectionRequest.php | 10 +- .../V1/AppConnectionsServiceClientTest.php | 1001 ------------ .../AppConnectionsServiceClientTest.php | 280 ++-- BeyondCorpAppConnectors/.OwlBot.yaml | 4 +- BeyondCorpAppConnectors/owlbot.py | 40 +- .../src/V1/AppConnector.php | 16 +- .../PrincipalInfo/ServiceAccount.php | 2 +- .../src/V1/AppConnectorInstanceConfig.php | 8 +- .../src/V1/AppConnectorOperationMetadata.php | 14 +- .../src/V1/AppConnectorsServiceClient.php | 34 - .../src/V1/AppConnectorsServiceGrpcClient.php | 138 -- .../V1/Client/AppConnectorsServiceClient.php | 37 +- .../src/V1/CreateAppConnectorRequest.php | 10 +- .../src/V1/DeleteAppConnectorRequest.php | 6 +- .../Gapic/AppConnectorsServiceGapicClient.php | 1302 ---------------- .../src/V1/GetAppConnectorRequest.php | 2 +- .../src/V1/ImageConfig.php | 4 +- .../src/V1/ListAppConnectorsRequest.php | 10 +- .../src/V1/ListAppConnectorsResponse.php | 2 +- .../CloudPubSubNotificationConfig.php | 2 +- .../src/V1/ReportStatusRequest.php | 8 +- .../src/V1/ResourceInfo.php | 8 +- .../src/V1/UpdateAppConnectorRequest.php | 8 +- .../V1/AppConnectorsServiceClientTest.php | 1034 ------------- .../Client/AppConnectorsServiceClientTest.php | 284 ++-- BeyondCorpAppGateways/.OwlBot.yaml | 4 +- BeyondCorpAppGateways/owlbot.py | 40 +- BeyondCorpAppGateways/src/V1/AppGateway.php | 18 +- .../src/V1/AppGateway/AllocatedConnection.php | 4 +- .../src/V1/AppGatewayOperationMetadata.php | 14 +- .../src/V1/AppGatewaysServiceClient.php | 34 - .../src/V1/AppGatewaysServiceGrpcClient.php | 108 -- .../V1/Client/AppGatewaysServiceClient.php | 37 +- .../src/V1/CreateAppGatewayRequest.php | 10 +- .../src/V1/DeleteAppGatewayRequest.php | 6 +- .../Gapic/AppGatewaysServiceGapicClient.php | 1083 ------------- .../src/V1/GetAppGatewayRequest.php | 2 +- .../src/V1/ListAppGatewaysRequest.php | 10 +- .../src/V1/ListAppGatewaysResponse.php | 2 +- .../Unit/V1/AppGatewaysServiceClientTest.php | 775 ---------- .../Client/AppGatewaysServiceClientTest.php | 223 +-- .../.OwlBot.yaml | 4 +- BeyondCorpClientConnectorServices/owlbot.py | 40 +- .../ClientConnectorServicesServiceClient.php | 80 +- .../src/V1/ClientConnectorService.php | 14 +- .../Egress/PeeredVpc.php | 2 +- .../ClientConnectorService/Ingress/Config.php | 2 +- .../Ingress/Config/DestinationRoute.php | 4 +- ...lientConnectorServiceOperationMetadata.php | 14 +- .../ClientConnectorServicesServiceClient.php | 34 - ...ientConnectorServicesServiceGrpcClient.php | 120 -- .../CreateClientConnectorServiceRequest.php | 10 +- .../DeleteClientConnectorServiceRequest.php | 6 +- ...entConnectorServicesServiceGapicClient.php | 1205 --------------- .../V1/GetClientConnectorServiceRequest.php | 2 +- .../V1/ListClientConnectorServicesRequest.php | 10 +- .../ListClientConnectorServicesResponse.php | 2 +- .../UpdateClientConnectorServiceRequest.php | 10 +- ...ientConnectorServicesServiceClientTest.php | 260 ++-- ...ientConnectorServicesServiceClientTest.php | 905 ----------- BeyondCorpClientGateways/.OwlBot.yaml | 4 +- BeyondCorpClientGateways/owlbot.py | 40 +- .../V1/Client/ClientGatewaysServiceClient.php | 37 +- .../src/V1/ClientGateway.php | 12 +- .../src/V1/ClientGatewayOperationMetadata.php | 14 +- .../src/V1/ClientGatewaysServiceClient.php | 34 - .../V1/ClientGatewaysServiceGrpcClient.php | 105 -- .../src/V1/CreateClientGatewayRequest.php | 10 +- .../src/V1/DeleteClientGatewayRequest.php | 6 +- .../ClientGatewaysServiceGapicClient.php | 1077 ------------- .../src/V1/GetClientGatewayRequest.php | 2 +- .../src/V1/ListClientGatewaysRequest.php | 10 +- .../src/V1/ListClientGatewaysResponse.php | 2 +- .../ClientGatewaysServiceClientTest.php | 228 +-- .../V1/ClientGatewaysServiceClientTest.php | 761 --------- 94 files changed, 1111 insertions(+), 12311 deletions(-) delete mode 100644 BeyondCorpAppConnections/src/V1/AppConnectionsServiceClient.php delete mode 100644 BeyondCorpAppConnections/src/V1/AppConnectionsServiceGrpcClient.php delete mode 100644 BeyondCorpAppConnections/src/V1/Gapic/AppConnectionsServiceGapicClient.php delete mode 100644 BeyondCorpAppConnections/tests/Unit/V1/AppConnectionsServiceClientTest.php delete mode 100644 BeyondCorpAppConnectors/src/V1/AppConnectorsServiceClient.php delete mode 100644 BeyondCorpAppConnectors/src/V1/AppConnectorsServiceGrpcClient.php delete mode 100644 BeyondCorpAppConnectors/src/V1/Gapic/AppConnectorsServiceGapicClient.php delete mode 100644 BeyondCorpAppConnectors/tests/Unit/V1/AppConnectorsServiceClientTest.php delete mode 100644 BeyondCorpAppGateways/src/V1/AppGatewaysServiceClient.php delete mode 100644 BeyondCorpAppGateways/src/V1/AppGatewaysServiceGrpcClient.php delete mode 100644 BeyondCorpAppGateways/src/V1/Gapic/AppGatewaysServiceGapicClient.php delete mode 100644 BeyondCorpAppGateways/tests/Unit/V1/AppGatewaysServiceClientTest.php delete mode 100644 BeyondCorpClientConnectorServices/src/V1/ClientConnectorServicesServiceClient.php delete mode 100644 BeyondCorpClientConnectorServices/src/V1/ClientConnectorServicesServiceGrpcClient.php delete mode 100644 BeyondCorpClientConnectorServices/src/V1/Gapic/ClientConnectorServicesServiceGapicClient.php delete mode 100644 BeyondCorpClientConnectorServices/tests/Unit/V1/ClientConnectorServicesServiceClientTest.php delete mode 100644 BeyondCorpClientGateways/src/V1/ClientGatewaysServiceClient.php delete mode 100644 BeyondCorpClientGateways/src/V1/ClientGatewaysServiceGrpcClient.php delete mode 100644 BeyondCorpClientGateways/src/V1/Gapic/ClientGatewaysServiceGapicClient.php delete mode 100644 BeyondCorpClientGateways/tests/Unit/V1/ClientGatewaysServiceClientTest.php diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index cfd556523e97..b9d3f5517bbf 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -190,7 +190,7 @@ "BeyondCorpAppConnections": { "language": "php", "distribution_name": "google/cloud-beyondcorp-appconnections", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-beyondcorp-appconnections/latest", "library_type": "GAPIC_AUTO", "product_documentation": "https://cloud.google.com/beyondcorp-enterprise/docs", @@ -200,7 +200,7 @@ "BeyondCorpAppConnectors": { "language": "php", "distribution_name": "google/cloud-beyondcorp-appconnectors", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-beyondcorp-appconnectors/latest", "library_type": "GAPIC_AUTO", "api_shortname": "beyondcorp" @@ -208,7 +208,7 @@ "BeyondCorpAppGateways": { "language": "php", "distribution_name": "google/cloud-beyondcorp-appgateways", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-beyondcorp-appgateways/latest", "library_type": "GAPIC_AUTO", "api_shortname": "beyondcorp" @@ -216,7 +216,7 @@ "BeyondCorpClientConnectorServices": { "language": "php", "distribution_name": "google/cloud-beyondcorp-clientconnectorservices", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-beyondcorp-clientconnectorservices/latest", "library_type": "GAPIC_AUTO", "api_shortname": "beyondcorp" @@ -224,7 +224,7 @@ "BeyondCorpClientGateways": { "language": "php", "distribution_name": "google/cloud-beyondcorp-clientgateways", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-beyondcorp-clientgateways/latest", "library_type": "GAPIC_AUTO", "api_shortname": "beyondcorp" @@ -366,7 +366,7 @@ "CommerceConsumerProcurement": { "language": "php", "distribution_name": "google/cloud-commerce-consumer-procurement", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-commerce-consumer-procurement/latest", "library_type": "GAPIC_AUTO", "api_shortname": "cloudcommerceconsumerprocurement" diff --git a/BeyondCorpAppConnections/.OwlBot.yaml b/BeyondCorpAppConnections/.OwlBot.yaml index b2e4c82ac848..1fa705a1a4b8 100644 --- a/BeyondCorpAppConnections/.OwlBot.yaml +++ b/BeyondCorpAppConnections/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/beyondcorp/appconnections/v1/.*-php/(.*) - dest: /owl-bot-staging/BeyondCorpAppConnections/v1/$1 + - source: /google/cloud/beyondcorp/appconnections/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BeyondCorpAppConnections/$1/$2 api-name: BeyondCorpAppConnections diff --git a/BeyondCorpAppConnections/owlbot.py b/BeyondCorpAppConnections/owlbot.py index c02f34ff1e7c..1bcc26160680 100644 --- a/BeyondCorpAppConnections/owlbot.py +++ b/BeyondCorpAppConnections/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/BeyondCorpAppConnections/src/V1/AppConnection.php b/BeyondCorpAppConnections/src/V1/AppConnection.php index 309d080948a4..f676e051925c 100644 --- a/BeyondCorpAppConnections/src/V1/AppConnection.php +++ b/BeyondCorpAppConnections/src/V1/AppConnection.php @@ -24,19 +24,19 @@ class AppConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Timestamp when the resource was created. * * 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. Timestamp when the resource was last modified. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. Resource labels to represent user provided metadata. * @@ -49,27 +49,27 @@ class AppConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. A unique identifier for the instance generated by the * system. * * Generated from protobuf field string uid = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Required. The type of network connectivity used by the AppConnection. * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection.Type type = 7 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * Required. Address of the remote application endpoint for the BeyondCorp * AppConnection. * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection.ApplicationEndpoint application_endpoint = 8 [(.google.api.field_behavior) = REQUIRED]; */ - private $application_endpoint = null; + protected $application_endpoint = null; /** * Optional. List of [google.cloud.beyondcorp.v1main.Connector.name] that are * authorised to be associated with this AppConnection. @@ -82,13 +82,13 @@ class AppConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection.State state = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Optional. Gateway used by the AppConnection. * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection.Gateway gateway = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $gateway = null; + protected $gateway = null; /** * Constructor. diff --git a/BeyondCorpAppConnections/src/V1/AppConnection/ApplicationEndpoint.php b/BeyondCorpAppConnections/src/V1/AppConnection/ApplicationEndpoint.php index b4b65e403711..5ad7347b8017 100644 --- a/BeyondCorpAppConnections/src/V1/AppConnection/ApplicationEndpoint.php +++ b/BeyondCorpAppConnections/src/V1/AppConnection/ApplicationEndpoint.php @@ -20,13 +20,13 @@ class ApplicationEndpoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string host = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $host = ''; + protected $host = ''; /** * Required. Port of the remote application endpoint. * * Generated from protobuf field int32 port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $port = 0; + protected $port = 0; /** * Constructor. diff --git a/BeyondCorpAppConnections/src/V1/AppConnection/Gateway.php b/BeyondCorpAppConnections/src/V1/AppConnection/Gateway.php index ae3580730248..b17cfe6d1e69 100644 --- a/BeyondCorpAppConnections/src/V1/AppConnection/Gateway.php +++ b/BeyondCorpAppConnections/src/V1/AppConnection/Gateway.php @@ -21,27 +21,27 @@ class Gateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection.Gateway.Type type = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * Output only. Server-defined URI for this resource. * * Generated from protobuf field string uri = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uri = ''; + protected $uri = ''; /** * Output only. Ingress port reserved on the gateways for this * AppConnection, if not specified or zero, the default port is 19443. * * Generated from protobuf field int32 ingress_port = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $ingress_port = 0; + protected $ingress_port = 0; /** * Required. AppGateway name in following format: * `projects/{project_id}/locations/{location_id}/appgateways/{gateway_id}` * * Generated from protobuf field string app_gateway = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $app_gateway = ''; + protected $app_gateway = ''; /** * Constructor. diff --git a/BeyondCorpAppConnections/src/V1/AppConnectionOperationMetadata.php b/BeyondCorpAppConnections/src/V1/AppConnectionOperationMetadata.php index 028c626c6659..e2ee3aedca33 100644 --- a/BeyondCorpAppConnections/src/V1/AppConnectionOperationMetadata.php +++ b/BeyondCorpAppConnections/src/V1/AppConnectionOperationMetadata.php @@ -20,31 +20,31 @@ class AppConnectionOperationMetadata 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 @@ -54,13 +54,13 @@ class AppConnectionOperationMetadata 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/BeyondCorpAppConnections/src/V1/AppConnectionsServiceClient.php b/BeyondCorpAppConnections/src/V1/AppConnectionsServiceClient.php deleted file mode 100644 index 1a81bc72d90c..000000000000 --- a/BeyondCorpAppConnections/src/V1/AppConnectionsServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections', - $argument, - ['\Google\Cloud\BeyondCorp\AppConnections\V1\ListAppConnectionsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single AppConnection. - * @param \Google\Cloud\BeyondCorp\AppConnections\V1\GetAppConnectionRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetAppConnection(\Google\Cloud\BeyondCorp\AppConnections\V1\GetAppConnectionRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection', - $argument, - ['\Google\Cloud\BeyondCorp\AppConnections\V1\AppConnection', 'decode'], - $metadata, $options); - } - - /** - * Creates a new AppConnection in a given project and location. - * @param \Google\Cloud\BeyondCorp\AppConnections\V1\CreateAppConnectionRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateAppConnection(\Google\Cloud\BeyondCorp\AppConnections\V1\CreateAppConnectionRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Updates the parameters of a single AppConnection. - * @param \Google\Cloud\BeyondCorp\AppConnections\V1\UpdateAppConnectionRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateAppConnection(\Google\Cloud\BeyondCorp\AppConnections\V1\UpdateAppConnectionRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single AppConnection. - * @param \Google\Cloud\BeyondCorp\AppConnections\V1\DeleteAppConnectionRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteAppConnection(\Google\Cloud\BeyondCorp\AppConnections\V1\DeleteAppConnectionRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Resolves AppConnections details for a given AppConnector. - * An internal method called by a connector to find AppConnections to connect - * to. - * @param \Google\Cloud\BeyondCorp\AppConnections\V1\ResolveAppConnectionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ResolveAppConnections(\Google\Cloud\BeyondCorp\AppConnections\V1\ResolveAppConnectionsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections', - $argument, - ['\Google\Cloud\BeyondCorp\AppConnections\V1\ResolveAppConnectionsResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php b/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php index 6676ffb671af..9ab45eca4fb5 100644 --- a/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php +++ b/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.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 * app_connection resource. @@ -473,8 +492,10 @@ public function listAppConnections(ListAppConnectionsRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function resolveAppConnections(ResolveAppConnectionsRequest $request, array $callOptions = []): PagedListResponse - { + public function resolveAppConnections( + ResolveAppConnectionsRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ResolveAppConnections', $request, $callOptions); } @@ -642,8 +663,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/BeyondCorpAppConnections/src/V1/CreateAppConnectionRequest.php b/BeyondCorpAppConnections/src/V1/CreateAppConnectionRequest.php index 64e7b7c1e32a..ef54860b1978 100644 --- a/BeyondCorpAppConnections/src/V1/CreateAppConnectionRequest.php +++ b/BeyondCorpAppConnections/src/V1/CreateAppConnectionRequest.php @@ -21,7 +21,7 @@ class CreateAppConnectionRequest 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. User-settable AppConnection resource ID. * * Must start with a letter. @@ -30,13 +30,13 @@ class CreateAppConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_connection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $app_connection_id = ''; + protected $app_connection_id = ''; /** * Required. A BeyondCorp AppConnection resource. * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection app_connection = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_connection = null; + protected $app_connection = null; /** * Optional. 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 @@ -52,14 +52,14 @@ class CreateAppConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. The resource project name of the AppConnection location using the diff --git a/BeyondCorpAppConnections/src/V1/DeleteAppConnectionRequest.php b/BeyondCorpAppConnections/src/V1/DeleteAppConnectionRequest.php index c32214d2bd1c..33d06fe0c0a5 100644 --- a/BeyondCorpAppConnections/src/V1/DeleteAppConnectionRequest.php +++ b/BeyondCorpAppConnections/src/V1/DeleteAppConnectionRequest.php @@ -21,7 +21,7 @@ class DeleteAppConnectionRequest 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 = ''; /** * Optional. 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 @@ -37,14 +37,14 @@ class DeleteAppConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. BeyondCorp Connector name using the form: diff --git a/BeyondCorpAppConnections/src/V1/Gapic/AppConnectionsServiceGapicClient.php b/BeyondCorpAppConnections/src/V1/Gapic/AppConnectionsServiceGapicClient.php deleted file mode 100644 index 100f599c5dad..000000000000 --- a/BeyondCorpAppConnections/src/V1/Gapic/AppConnectionsServiceGapicClient.php +++ /dev/null @@ -1,1363 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $appConnection = new AppConnection(); - * $operationResponse = $appConnectionsServiceClient->createAppConnection($formattedParent, $appConnection); - * $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 = $appConnectionsServiceClient->createAppConnection($formattedParent, $appConnection); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectionsServiceClient->resumeOperation($operationName, 'createAppConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectionsServiceClient->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\BeyondCorp\AppConnections\V1\Client\AppConnectionsServiceClient}. - */ -class AppConnectionsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.beyondcorp.appconnections.v1.AppConnectionsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'beyondcorp.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 $appConnectionNameTemplate; - - private static $appConnectorNameTemplate; - - private static $appGatewayNameTemplate; - - 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/app_connections_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/app_connections_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/app_connections_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/app_connections_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getAppConnectionNameTemplate() - { - if (self::$appConnectionNameTemplate == null) { - self::$appConnectionNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/appConnections/{app_connection}' - ); - } - - return self::$appConnectionNameTemplate; - } - - private static function getAppConnectorNameTemplate() - { - if (self::$appConnectorNameTemplate == null) { - self::$appConnectorNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/appConnectors/{app_connector}' - ); - } - - return self::$appConnectorNameTemplate; - } - - private static function getAppGatewayNameTemplate() - { - if (self::$appGatewayNameTemplate == null) { - self::$appGatewayNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/appGateways/{app_gateway}' - ); - } - - return self::$appGatewayNameTemplate; - } - - 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 = [ - 'appConnection' => self::getAppConnectionNameTemplate(), - 'appConnector' => self::getAppConnectorNameTemplate(), - 'appGateway' => self::getAppGatewayNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connection resource. - * - * @param string $project - * @param string $location - * @param string $appConnection - * - * @return string The formatted app_connection resource. - */ - public static function appConnectionName( - $project, - $location, - $appConnection - ) { - return self::getAppConnectionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'app_connection' => $appConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connector resource. - * - * @param string $project - * @param string $location - * @param string $appConnector - * - * @return string The formatted app_connector resource. - */ - public static function appConnectorName($project, $location, $appConnector) - { - return self::getAppConnectorNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'app_connector' => $appConnector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a app_gateway - * resource. - * - * @param string $project - * @param string $location - * @param string $appGateway - * - * @return string The formatted app_gateway resource. - */ - public static function appGatewayName($project, $location, $appGateway) - { - return self::getAppGatewayNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'app_gateway' => $appGateway, - ]); - } - - /** - * 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 - * - appConnection: projects/{project}/locations/{location}/appConnections/{app_connection} - * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} - * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} - * - 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 'beyondcorp.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 AppConnection in a given project and location. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $formattedParent = $appConnectionsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $appConnection = new AppConnection(); - * $operationResponse = $appConnectionsServiceClient->createAppConnection($formattedParent, $appConnection); - * $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 = $appConnectionsServiceClient->createAppConnection($formattedParent, $appConnection); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectionsServiceClient->resumeOperation($operationName, 'createAppConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource project name of the AppConnection location using the - * form: `projects/{project_id}/locations/{location_id}` - * @param AppConnection $appConnection Required. A BeyondCorp AppConnection resource. - * @param array $optionalArgs { - * Optional. - * - * @type string $appConnectionId - * Optional. User-settable AppConnection resource ID. - * * Must start with a letter. - * * Must contain between 4-63 characters from `/[a-z][0-9]-/`. - * * Must end with a number or a letter. - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 createAppConnection( - $parent, - $appConnection, - array $optionalArgs = [] - ) { - $request = new CreateAppConnectionRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAppConnection($appConnection); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['appConnectionId'])) { - $request->setAppConnectionId($optionalArgs['appConnectionId']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateAppConnection', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single AppConnection. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $formattedName = $appConnectionsServiceClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - * $operationResponse = $appConnectionsServiceClient->deleteAppConnection($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 = $appConnectionsServiceClient->deleteAppConnection($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectionsServiceClient->resumeOperation($operationName, 'deleteAppConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp Connector name using the form: - * `projects/{project_id}/locations/{location_id}/appConnections/{app_connection_id}` - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 deleteAppConnection($name, array $optionalArgs = []) - { - $request = new DeleteAppConnectionRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteAppConnection', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single AppConnection. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $formattedName = $appConnectionsServiceClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - * $response = $appConnectionsServiceClient->getAppConnection($formattedName); - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp AppConnection name using the form: - * `projects/{project_id}/locations/{location_id}/appConnections/{app_connection_id}` - * @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\BeyondCorp\AppConnections\V1\AppConnection - * - * @throws ApiException if the remote call fails - */ - public function getAppConnection($name, array $optionalArgs = []) - { - $request = new GetAppConnectionRequest(); - $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( - 'GetAppConnection', - AppConnection::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists AppConnections in a given project and location. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $formattedParent = $appConnectionsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $appConnectionsServiceClient->listAppConnections($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appConnectionsServiceClient->listAppConnections($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the AppConnection location using the form: - * `projects/{project_id}/locations/{location_id}` - * @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. A filter specifying constraints of a list operation. - * @type string $orderBy - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * @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 listAppConnections($parent, array $optionalArgs = []) - { - $request = new ListAppConnectionsRequest(); - $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( - 'ListAppConnections', - $optionalArgs, - ListAppConnectionsResponse::class, - $request - ); - } - - /** - * Resolves AppConnections details for a given AppConnector. - * An internal method called by a connector to find AppConnections to connect - * to. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $formattedParent = $appConnectionsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $formattedAppConnectorId = $appConnectionsServiceClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - * // Iterate over pages of elements - * $pagedResponse = $appConnectionsServiceClient->resolveAppConnections($formattedParent, $formattedAppConnectorId); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appConnectionsServiceClient->resolveAppConnections($formattedParent, $formattedAppConnectorId); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the AppConnection location using the form: - * `projects/{project_id}/locations/{location_id}` - * @param string $appConnectorId Required. BeyondCorp Connector name of the connector associated with those - * AppConnections using the form: - * `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}` - * @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 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 resolveAppConnections( - $parent, - $appConnectorId, - array $optionalArgs = [] - ) { - $request = new ResolveAppConnectionsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAppConnectorId($appConnectorId); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ResolveAppConnections', - $optionalArgs, - ResolveAppConnectionsResponse::class, - $request - ); - } - - /** - * Updates the parameters of a single AppConnection. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $appConnection = new AppConnection(); - * $operationResponse = $appConnectionsServiceClient->updateAppConnection($updateMask, $appConnection); - * $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 = $appConnectionsServiceClient->updateAppConnection($updateMask, $appConnection); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectionsServiceClient->resumeOperation($operationName, 'updateAppConnection'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from [BeyondCorp.AppConnection]: - * * `labels` - * * `display_name` - * * `application_endpoint` - * * `connectors` - * @param AppConnection $appConnection Required. AppConnection message with updated fields. Only supported fields - * specified in update_mask are updated. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @type bool $allowMissing - * Optional. If set as true, will create the resource if it is not found. - * @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 updateAppConnection( - $updateMask, - $appConnection, - array $optionalArgs = [] - ) { - $request = new UpdateAppConnectionRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setAppConnection($appConnection); - $requestParamHeaders['app_connection.name'] = $appConnection->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - if (isset($optionalArgs['allowMissing'])) { - $request->setAllowMissing($optionalArgs['allowMissing']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateAppConnection', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $response = $appConnectionsServiceClient->getLocation(); - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $appConnectionsServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appConnectionsServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $resource = 'resource'; - * $response = $appConnectionsServiceClient->getIamPolicy($resource); - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $appConnectionsServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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->startCall( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * Sample code: - * ``` - * $appConnectionsServiceClient = new AppConnectionsServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $appConnectionsServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $appConnectionsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/BeyondCorpAppConnections/src/V1/GetAppConnectionRequest.php b/BeyondCorpAppConnections/src/V1/GetAppConnectionRequest.php index 10bc77a1d4f1..cbda1a28657b 100644 --- a/BeyondCorpAppConnections/src/V1/GetAppConnectionRequest.php +++ b/BeyondCorpAppConnections/src/V1/GetAppConnectionRequest.php @@ -21,7 +21,7 @@ class GetAppConnectionRequest 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. BeyondCorp AppConnection name using the form: diff --git a/BeyondCorpAppConnections/src/V1/ListAppConnectionsRequest.php b/BeyondCorpAppConnections/src/V1/ListAppConnectionsRequest.php index ba67e6ebfd44..f2beaa7375a7 100644 --- a/BeyondCorpAppConnections/src/V1/ListAppConnectionsRequest.php +++ b/BeyondCorpAppConnections/src/V1/ListAppConnectionsRequest.php @@ -21,7 +21,7 @@ class ListAppConnectionsRequest 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 items to return. * If not specified, a default value of 50 will be used by the service. @@ -32,20 +32,20 @@ class ListAppConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous * ListAppConnectionsRequest, if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. A filter specifying constraints of a list operation. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Specifies the ordering of results. See * [Sorting @@ -54,7 +54,7 @@ class ListAppConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The resource name of the AppConnection location using the form: diff --git a/BeyondCorpAppConnections/src/V1/ListAppConnectionsResponse.php b/BeyondCorpAppConnections/src/V1/ListAppConnectionsResponse.php index b8315ede459a..31f3294ce77d 100644 --- a/BeyondCorpAppConnections/src/V1/ListAppConnectionsResponse.php +++ b/BeyondCorpAppConnections/src/V1/ListAppConnectionsResponse.php @@ -27,7 +27,7 @@ class ListAppConnectionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * A list of locations that could not be reached. * diff --git a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsRequest.php b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsRequest.php index ab361cca1d91..d35e11b22f80 100644 --- a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsRequest.php +++ b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsRequest.php @@ -21,7 +21,7 @@ class ResolveAppConnectionsRequest 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. BeyondCorp Connector name of the connector associated with those * AppConnections using the form: @@ -29,7 +29,7 @@ class ResolveAppConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_connector_id = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $app_connector_id = ''; + protected $app_connector_id = ''; /** * Optional. The maximum number of items to return. * If not specified, a default value of 50 will be used by the service. @@ -40,14 +40,14 @@ class ResolveAppConnectionsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous * ResolveAppConnectionsResponse, if any. * * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The resource name of the AppConnection location using the form: diff --git a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse.php b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse.php index 182173c98a94..9c3bf3d32526 100644 --- a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse.php +++ b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse.php @@ -27,7 +27,7 @@ class ResolveAppConnectionsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * A list of locations that could not be reached. * diff --git a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse/AppConnectionDetails.php b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse/AppConnectionDetails.php index 245242540e17..3dc6a3277a78 100644 --- a/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse/AppConnectionDetails.php +++ b/BeyondCorpAppConnections/src/V1/ResolveAppConnectionsResponse/AppConnectionDetails.php @@ -20,7 +20,7 @@ class AppConnectionDetails extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection app_connection = 1; */ - private $app_connection = null; + protected $app_connection = null; /** * If type=GCP_REGIONAL_MIG, contains most recent VM instances, like * `https://www.googleapis.com/compute/v1/projects/{project_id}/zones/{zone_id}/instances/{instance_id}`. diff --git a/BeyondCorpAppConnections/src/V1/UpdateAppConnectionRequest.php b/BeyondCorpAppConnections/src/V1/UpdateAppConnectionRequest.php index 05617d25054f..84b98cfce15c 100644 --- a/BeyondCorpAppConnections/src/V1/UpdateAppConnectionRequest.php +++ b/BeyondCorpAppConnections/src/V1/UpdateAppConnectionRequest.php @@ -26,14 +26,14 @@ class UpdateAppConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. AppConnection message with updated fields. Only supported fields * specified in update_mask are updated. * * Generated from protobuf field .google.cloud.beyondcorp.appconnections.v1.AppConnection app_connection = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_connection = null; + protected $app_connection = null; /** * Optional. 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 @@ -49,20 +49,20 @@ class UpdateAppConnectionRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * Optional. If set as true, will create the resource if it is not found. * * Generated from protobuf field bool allow_missing = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $allow_missing = false; + protected $allow_missing = false; /** * @param \Google\Cloud\BeyondCorp\AppConnections\V1\AppConnection $appConnection Required. AppConnection message with updated fields. Only supported fields diff --git a/BeyondCorpAppConnections/tests/Unit/V1/AppConnectionsServiceClientTest.php b/BeyondCorpAppConnections/tests/Unit/V1/AppConnectionsServiceClientTest.php deleted file mode 100644 index 38fcab64c815..000000000000 --- a/BeyondCorpAppConnections/tests/Unit/V1/AppConnectionsServiceClientTest.php +++ /dev/null @@ -1,1001 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AppConnectionsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AppConnectionsServiceClient($options); - } - - /** @test */ - public function createAppConnectionTest() - { - $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/createAppConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnection(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createAppConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $appConnection = new AppConnection(); - $appConnectionName = 'appConnectionName-1608104182'; - $appConnection->setName($appConnectionName); - $appConnectionType = Type::TYPE_UNSPECIFIED; - $appConnection->setType($appConnectionType); - $appConnectionApplicationEndpoint = new ApplicationEndpoint(); - $applicationEndpointHost = 'applicationEndpointHost1976079949'; - $appConnectionApplicationEndpoint->setHost($applicationEndpointHost); - $applicationEndpointPort = 1976318246; - $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); - $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $response = $gapicClient->createAppConnection($formattedParent, $appConnection); - $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.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getAppConnection(); - $this->assertProtobufEquals($appConnection, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppConnectionTest'); - $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 createAppConnectionExceptionTest() - { - $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/createAppConnectionTest'); - $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]'); - $appConnection = new AppConnection(); - $appConnectionName = 'appConnectionName-1608104182'; - $appConnection->setName($appConnectionName); - $appConnectionType = Type::TYPE_UNSPECIFIED; - $appConnection->setType($appConnectionType); - $appConnectionApplicationEndpoint = new ApplicationEndpoint(); - $applicationEndpointHost = 'applicationEndpointHost1976079949'; - $appConnectionApplicationEndpoint->setHost($applicationEndpointHost); - $applicationEndpointPort = 1976318246; - $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); - $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $response = $gapicClient->createAppConnection($formattedParent, $appConnection); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppConnectionTest'); - 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 deleteAppConnectionTest() - { - $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/deleteAppConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteAppConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $response = $gapicClient->deleteAppConnection($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.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppConnectionTest'); - $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 deleteAppConnectionExceptionTest() - { - $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/deleteAppConnectionTest'); - $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->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $response = $gapicClient->deleteAppConnection($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppConnectionTest'); - 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 getAppConnectionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnection(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $response = $gapicClient->getAppConnection($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.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAppConnectionExceptionTest() - { - $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->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - try { - $gapicClient->getAppConnection($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 listAppConnectionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $appConnectionsElement = new AppConnection(); - $appConnections = [ - $appConnectionsElement, - ]; - $expectedResponse = new ListAppConnectionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAppConnections($appConnections); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listAppConnections($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAppConnections()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAppConnectionsExceptionTest() - { - $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->listAppConnections($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 resolveAppConnectionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $appConnectionDetailsElement = new AppConnectionDetails(); - $appConnectionDetails = [ - $appConnectionDetailsElement, - ]; - $expectedResponse = new ResolveAppConnectionsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAppConnectionDetails($appConnectionDetails); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $formattedAppConnectorId = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $response = $gapicClient->resolveAppConnections($formattedParent, $formattedAppConnectorId); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAppConnectionDetails()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getAppConnectorId(); - $this->assertProtobufEquals($formattedAppConnectorId, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function resolveAppConnectionsExceptionTest() - { - $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]'); - $formattedAppConnectorId = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - try { - $gapicClient->resolveAppConnections($formattedParent, $formattedAppConnectorId); - // 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 updateAppConnectionTest() - { - $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/updateAppConnectionTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnection(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateAppConnectionTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $appConnection = new AppConnection(); - $appConnectionName = 'appConnectionName-1608104182'; - $appConnection->setName($appConnectionName); - $appConnectionType = Type::TYPE_UNSPECIFIED; - $appConnection->setType($appConnectionType); - $appConnectionApplicationEndpoint = new ApplicationEndpoint(); - $applicationEndpointHost = 'applicationEndpointHost1976079949'; - $appConnectionApplicationEndpoint->setHost($applicationEndpointHost); - $applicationEndpointPort = 1976318246; - $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); - $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $response = $gapicClient->updateAppConnection($updateMask, $appConnection); - $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.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getAppConnection(); - $this->assertProtobufEquals($appConnection, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppConnectionTest'); - $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 updateAppConnectionExceptionTest() - { - $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/updateAppConnectionTest'); - $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 - $updateMask = new FieldMask(); - $appConnection = new AppConnection(); - $appConnectionName = 'appConnectionName-1608104182'; - $appConnection->setName($appConnectionName); - $appConnectionType = Type::TYPE_UNSPECIFIED; - $appConnection->setType($appConnectionType); - $appConnectionApplicationEndpoint = new ApplicationEndpoint(); - $applicationEndpointHost = 'applicationEndpointHost1976079949'; - $appConnectionApplicationEndpoint->setHost($applicationEndpointHost); - $applicationEndpointPort = 1976318246; - $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); - $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $response = $gapicClient->updateAppConnection($updateMask, $appConnection); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppConnectionTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->getLocation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->listLocations(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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()); - } -} diff --git a/BeyondCorpAppConnections/tests/Unit/V1/Client/AppConnectionsServiceClientTest.php b/BeyondCorpAppConnections/tests/Unit/V1/Client/AppConnectionsServiceClientTest.php index a179a5352807..288bac22f3e9 100644 --- a/BeyondCorpAppConnections/tests/Unit/V1/Client/AppConnectionsServiceClientTest.php +++ b/BeyondCorpAppConnections/tests/Unit/V1/Client/AppConnectionsServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AppConnectionsServiceClient */ @@ -133,9 +135,7 @@ public function createAppConnectionTest() $applicationEndpointPort = 1976318246; $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $request = (new CreateAppConnectionRequest()) - ->setParent($formattedParent) - ->setAppConnection($appConnection); + $request = (new CreateAppConnectionRequest())->setParent($formattedParent)->setAppConnection($appConnection); $response = $gapicClient->createAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -145,7 +145,10 @@ public function createAppConnectionTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppConnection(); @@ -193,12 +196,15 @@ public function createAppConnectionExceptionTest() $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]'); @@ -213,9 +219,7 @@ public function createAppConnectionExceptionTest() $applicationEndpointPort = 1976318246; $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $request = (new CreateAppConnectionRequest()) - ->setParent($formattedParent) - ->setAppConnection($appConnection); + $request = (new CreateAppConnectionRequest())->setParent($formattedParent)->setAppConnection($appConnection); $response = $gapicClient->createAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -269,8 +273,7 @@ public function deleteAppConnectionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $request = (new DeleteAppConnectionRequest()) - ->setName($formattedName); + $request = (new DeleteAppConnectionRequest())->setName($formattedName); $response = $gapicClient->deleteAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -280,7 +283,10 @@ public function deleteAppConnectionTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -326,17 +332,19 @@ public function deleteAppConnectionExceptionTest() $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->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $request = (new DeleteAppConnectionRequest()) - ->setName($formattedName); + $request = (new DeleteAppConnectionRequest())->setName($formattedName); $response = $gapicClient->deleteAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -378,15 +386,17 @@ public function getAppConnectionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $request = (new GetAppConnectionRequest()) - ->setName($formattedName); + $request = (new GetAppConnectionRequest())->setName($formattedName); $response = $gapicClient->getAppConnection($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -403,17 +413,19 @@ public function getAppConnectionExceptionTest() $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->appConnectionName('[PROJECT]', '[LOCATION]', '[APP_CONNECTION]'); - $request = (new GetAppConnectionRequest()) - ->setName($formattedName); + $request = (new GetAppConnectionRequest())->setName($formattedName); try { $gapicClient->getAppConnection($request); // If the $gapicClient method call did not throw, fail the test @@ -438,17 +450,14 @@ public function listAppConnectionsTest() // Mock response $nextPageToken = ''; $appConnectionsElement = new AppConnection(); - $appConnections = [ - $appConnectionsElement, - ]; + $appConnections = [$appConnectionsElement]; $expectedResponse = new ListAppConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAppConnections($appConnections); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListAppConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListAppConnectionsRequest())->setParent($formattedParent); $response = $gapicClient->listAppConnections($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -458,7 +467,10 @@ public function listAppConnectionsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -475,17 +487,19 @@ public function listAppConnectionsExceptionTest() $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 ListAppConnectionsRequest()) - ->setParent($formattedParent); + $request = (new ListAppConnectionsRequest())->setParent($formattedParent); try { $gapicClient->listAppConnections($request); // If the $gapicClient method call did not throw, fail the test @@ -510,9 +524,7 @@ public function resolveAppConnectionsTest() // Mock response $nextPageToken = ''; $appConnectionDetailsElement = new AppConnectionDetails(); - $appConnectionDetails = [ - $appConnectionDetailsElement, - ]; + $appConnectionDetails = [$appConnectionDetailsElement]; $expectedResponse = new ResolveAppConnectionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAppConnectionDetails($appConnectionDetails); @@ -532,7 +544,10 @@ public function resolveAppConnectionsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getAppConnectorId(); @@ -551,12 +566,15 @@ public function resolveAppConnectionsExceptionTest() $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]'); @@ -625,9 +643,7 @@ public function updateAppConnectionTest() $applicationEndpointPort = 1976318246; $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $request = (new UpdateAppConnectionRequest()) - ->setUpdateMask($updateMask) - ->setAppConnection($appConnection); + $request = (new UpdateAppConnectionRequest())->setUpdateMask($updateMask)->setAppConnection($appConnection); $response = $gapicClient->updateAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -637,7 +653,10 @@ public function updateAppConnectionTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getAppConnection(); @@ -685,12 +704,15 @@ public function updateAppConnectionExceptionTest() $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 $updateMask = new FieldMask(); @@ -705,9 +727,7 @@ public function updateAppConnectionExceptionTest() $applicationEndpointPort = 1976318246; $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $request = (new UpdateAppConnectionRequest()) - ->setUpdateMask($updateMask) - ->setAppConnection($appConnection); + $request = (new UpdateAppConnectionRequest())->setUpdateMask($updateMask)->setAppConnection($appConnection); $response = $gapicClient->updateAppConnection($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -769,12 +789,15 @@ public function getLocationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -801,9 +824,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -833,12 +854,15 @@ public function listLocationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -871,8 +895,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -896,17 +919,19 @@ public function getIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -938,9 +963,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -966,19 +989,20 @@ public function setIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -1006,9 +1030,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1034,19 +1056,20 @@ public function testIamPermissionsExceptionTest() $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 $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -1108,9 +1131,7 @@ public function createAppConnectionAsyncTest() $applicationEndpointPort = 1976318246; $appConnectionApplicationEndpoint->setPort($applicationEndpointPort); $appConnection->setApplicationEndpoint($appConnectionApplicationEndpoint); - $request = (new CreateAppConnectionRequest()) - ->setParent($formattedParent) - ->setAppConnection($appConnection); + $request = (new CreateAppConnectionRequest())->setParent($formattedParent)->setAppConnection($appConnection); $response = $gapicClient->createAppConnectionAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1120,7 +1141,10 @@ public function createAppConnectionAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppConnection(); diff --git a/BeyondCorpAppConnectors/.OwlBot.yaml b/BeyondCorpAppConnectors/.OwlBot.yaml index 4c5c415e79f6..6f90c6e9020d 100644 --- a/BeyondCorpAppConnectors/.OwlBot.yaml +++ b/BeyondCorpAppConnectors/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/beyondcorp/appconnectors/v1/.*-php/(.*) - dest: /owl-bot-staging/BeyondCorpAppConnectors/v1/$1 + - source: /google/cloud/beyondcorp/appconnectors/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BeyondCorpAppConnectors/$1/$2 api-name: BeyondCorpAppConnectors diff --git a/BeyondCorpAppConnectors/owlbot.py b/BeyondCorpAppConnectors/owlbot.py index e26780eecc65..0de834c1b56b 100644 --- a/BeyondCorpAppConnectors/owlbot.py +++ b/BeyondCorpAppConnectors/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/BeyondCorpAppConnectors/src/V1/AppConnector.php b/BeyondCorpAppConnectors/src/V1/AppConnector.php index c98453157d3b..8601a1ecc6c5 100644 --- a/BeyondCorpAppConnectors/src/V1/AppConnector.php +++ b/BeyondCorpAppConnectors/src/V1/AppConnector.php @@ -25,19 +25,19 @@ class AppConnector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Timestamp when the resource was created. * * 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. Timestamp when the resource was last modified. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. Resource labels to represent user provided metadata. * @@ -50,32 +50,32 @@ class AppConnector extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. A unique identifier for the instance generated by the * system. * * Generated from protobuf field string uid = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Output only. The current state of the AppConnector. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.AppConnector.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Required. Principal information about the Identity of the AppConnector. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.AppConnector.PrincipalInfo principal_info = 8 [(.google.api.field_behavior) = REQUIRED]; */ - private $principal_info = null; + protected $principal_info = null; /** * Optional. Resource info of the connector. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.ResourceInfo resource_info = 11 [(.google.api.field_behavior) = OPTIONAL]; */ - private $resource_info = null; + protected $resource_info = null; /** * Constructor. diff --git a/BeyondCorpAppConnectors/src/V1/AppConnector/PrincipalInfo/ServiceAccount.php b/BeyondCorpAppConnectors/src/V1/AppConnector/PrincipalInfo/ServiceAccount.php index 4037b06cb8da..3dd72f6e8943 100644 --- a/BeyondCorpAppConnectors/src/V1/AppConnector/PrincipalInfo/ServiceAccount.php +++ b/BeyondCorpAppConnectors/src/V1/AppConnector/PrincipalInfo/ServiceAccount.php @@ -20,7 +20,7 @@ class ServiceAccount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string email = 1; */ - private $email = ''; + protected $email = ''; /** * Constructor. diff --git a/BeyondCorpAppConnectors/src/V1/AppConnectorInstanceConfig.php b/BeyondCorpAppConnectors/src/V1/AppConnectorInstanceConfig.php index 0a73c63557a8..59a44797fb90 100644 --- a/BeyondCorpAppConnectors/src/V1/AppConnectorInstanceConfig.php +++ b/BeyondCorpAppConnectors/src/V1/AppConnectorInstanceConfig.php @@ -22,27 +22,27 @@ class AppConnectorInstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 sequence_number = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $sequence_number = 0; + protected $sequence_number = 0; /** * The SLM instance agent configuration. * * Generated from protobuf field .google.protobuf.Any instance_config = 2; */ - private $instance_config = null; + protected $instance_config = null; /** * NotificationConfig defines the notification mechanism that the remote * instance should subscribe to in order to receive notification. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.NotificationConfig notification_config = 3; */ - private $notification_config = null; + protected $notification_config = null; /** * ImageConfig defines the GCR images to run for the remote agent's control * plane. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.ImageConfig image_config = 4; */ - private $image_config = null; + protected $image_config = null; /** * Constructor. diff --git a/BeyondCorpAppConnectors/src/V1/AppConnectorOperationMetadata.php b/BeyondCorpAppConnectors/src/V1/AppConnectorOperationMetadata.php index dd17b9e55778..28e101a224c3 100644 --- a/BeyondCorpAppConnectors/src/V1/AppConnectorOperationMetadata.php +++ b/BeyondCorpAppConnectors/src/V1/AppConnectorOperationMetadata.php @@ -20,31 +20,31 @@ class AppConnectorOperationMetadata 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 @@ -54,13 +54,13 @@ class AppConnectorOperationMetadata 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/BeyondCorpAppConnectors/src/V1/AppConnectorsServiceClient.php b/BeyondCorpAppConnectors/src/V1/AppConnectorsServiceClient.php deleted file mode 100644 index d87bd7ad9579..000000000000 --- a/BeyondCorpAppConnectors/src/V1/AppConnectorsServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors', - $argument, - ['\Google\Cloud\BeyondCorp\AppConnectors\V1\ListAppConnectorsResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single AppConnector. - * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\GetAppConnectorRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetAppConnector(\Google\Cloud\BeyondCorp\AppConnectors\V1\GetAppConnectorRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector', - $argument, - ['\Google\Cloud\BeyondCorp\AppConnectors\V1\AppConnector', 'decode'], - $metadata, $options); - } - - /** - * Creates a new AppConnector in a given project and location. - * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\CreateAppConnectorRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateAppConnector(\Google\Cloud\BeyondCorp\AppConnectors\V1\CreateAppConnectorRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Updates the parameters of a single AppConnector. - * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\UpdateAppConnectorRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateAppConnector(\Google\Cloud\BeyondCorp\AppConnectors\V1\UpdateAppConnectorRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single AppConnector. - * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\DeleteAppConnectorRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteAppConnector(\Google\Cloud\BeyondCorp\AppConnectors\V1\DeleteAppConnectorRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Report status for a given connector. - * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\ReportStatusRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ReportStatus(\Google\Cloud\BeyondCorp\AppConnectors\V1\ReportStatusRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php b/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php index a97752cddbe0..fa1f8d9717f6 100644 --- a/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php +++ b/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.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 * app_connector resource. @@ -598,8 +617,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/BeyondCorpAppConnectors/src/V1/CreateAppConnectorRequest.php b/BeyondCorpAppConnectors/src/V1/CreateAppConnectorRequest.php index d927f6cb34e3..971d96884ddc 100644 --- a/BeyondCorpAppConnectors/src/V1/CreateAppConnectorRequest.php +++ b/BeyondCorpAppConnectors/src/V1/CreateAppConnectorRequest.php @@ -21,7 +21,7 @@ class CreateAppConnectorRequest 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. User-settable AppConnector resource ID. * * Must start with a letter. @@ -30,13 +30,13 @@ class CreateAppConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_connector_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $app_connector_id = ''; + protected $app_connector_id = ''; /** * Required. A BeyondCorp AppConnector resource. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.AppConnector app_connector = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_connector = null; + protected $app_connector = null; /** * Optional. 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 @@ -52,14 +52,14 @@ class CreateAppConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. The resource project name of the AppConnector location using the diff --git a/BeyondCorpAppConnectors/src/V1/DeleteAppConnectorRequest.php b/BeyondCorpAppConnectors/src/V1/DeleteAppConnectorRequest.php index 8daff7f552be..a9ac702ffd42 100644 --- a/BeyondCorpAppConnectors/src/V1/DeleteAppConnectorRequest.php +++ b/BeyondCorpAppConnectors/src/V1/DeleteAppConnectorRequest.php @@ -21,7 +21,7 @@ class DeleteAppConnectorRequest 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 = ''; /** * Optional. 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 @@ -37,14 +37,14 @@ class DeleteAppConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. BeyondCorp AppConnector name using the form: diff --git a/BeyondCorpAppConnectors/src/V1/Gapic/AppConnectorsServiceGapicClient.php b/BeyondCorpAppConnectors/src/V1/Gapic/AppConnectorsServiceGapicClient.php deleted file mode 100644 index 5fc28a2d3372..000000000000 --- a/BeyondCorpAppConnectors/src/V1/Gapic/AppConnectorsServiceGapicClient.php +++ /dev/null @@ -1,1302 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $appConnector = new AppConnector(); - * $operationResponse = $appConnectorsServiceClient->createAppConnector($formattedParent, $appConnector); - * $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 = $appConnectorsServiceClient->createAppConnector($formattedParent, $appConnector); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectorsServiceClient->resumeOperation($operationName, 'createAppConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectorsServiceClient->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\BeyondCorp\AppConnectors\V1\Client\AppConnectorsServiceClient}. - */ -class AppConnectorsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'beyondcorp.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 $appConnectorNameTemplate; - - 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/app_connectors_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/app_connectors_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/app_connectors_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/app_connectors_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getAppConnectorNameTemplate() - { - if (self::$appConnectorNameTemplate == null) { - self::$appConnectorNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/appConnectors/{app_connector}' - ); - } - - return self::$appConnectorNameTemplate; - } - - 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 = [ - 'appConnector' => self::getAppConnectorNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connector resource. - * - * @param string $project - * @param string $location - * @param string $appConnector - * - * @return string The formatted app_connector resource. - */ - public static function appConnectorName($project, $location, $appConnector) - { - return self::getAppConnectorNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'app_connector' => $appConnector, - ]); - } - - /** - * 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 - * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} - * - 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 'beyondcorp.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 AppConnector in a given project and location. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $formattedParent = $appConnectorsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $appConnector = new AppConnector(); - * $operationResponse = $appConnectorsServiceClient->createAppConnector($formattedParent, $appConnector); - * $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 = $appConnectorsServiceClient->createAppConnector($formattedParent, $appConnector); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectorsServiceClient->resumeOperation($operationName, 'createAppConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource project name of the AppConnector location using the - * form: `projects/{project_id}/locations/{location_id}` - * @param AppConnector $appConnector Required. A BeyondCorp AppConnector resource. - * @param array $optionalArgs { - * Optional. - * - * @type string $appConnectorId - * Optional. User-settable AppConnector resource ID. - * - * * Must start with a letter. - * * Must contain between 4-63 characters from `/[a-z][0-9]-/`. - * * Must end with a number or a letter. - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 createAppConnector( - $parent, - $appConnector, - array $optionalArgs = [] - ) { - $request = new CreateAppConnectorRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAppConnector($appConnector); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['appConnectorId'])) { - $request->setAppConnectorId($optionalArgs['appConnectorId']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateAppConnector', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single AppConnector. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $formattedName = $appConnectorsServiceClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - * $operationResponse = $appConnectorsServiceClient->deleteAppConnector($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 = $appConnectorsServiceClient->deleteAppConnector($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectorsServiceClient->resumeOperation($operationName, 'deleteAppConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp AppConnector name using the form: - * `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}` - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 deleteAppConnector($name, array $optionalArgs = []) - { - $request = new DeleteAppConnectorRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteAppConnector', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single AppConnector. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $formattedName = $appConnectorsServiceClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - * $response = $appConnectorsServiceClient->getAppConnector($formattedName); - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp AppConnector name using the form: - * `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}` - * @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\BeyondCorp\AppConnectors\V1\AppConnector - * - * @throws ApiException if the remote call fails - */ - public function getAppConnector($name, array $optionalArgs = []) - { - $request = new GetAppConnectorRequest(); - $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( - 'GetAppConnector', - AppConnector::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists AppConnectors in a given project and location. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $formattedParent = $appConnectorsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $appConnectorsServiceClient->listAppConnectors($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appConnectorsServiceClient->listAppConnectors($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the AppConnector location using the form: - * `projects/{project_id}/locations/{location_id}` - * @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. A filter specifying constraints of a list operation. - * @type string $orderBy - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * @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 listAppConnectors($parent, array $optionalArgs = []) - { - $request = new ListAppConnectorsRequest(); - $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( - 'ListAppConnectors', - $optionalArgs, - ListAppConnectorsResponse::class, - $request - ); - } - - /** - * Report status for a given connector. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $formattedAppConnector = $appConnectorsServiceClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - * $resourceInfo = new ResourceInfo(); - * $operationResponse = $appConnectorsServiceClient->reportStatus($formattedAppConnector, $resourceInfo); - * $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 = $appConnectorsServiceClient->reportStatus($formattedAppConnector, $resourceInfo); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectorsServiceClient->resumeOperation($operationName, 'reportStatus'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $appConnector Required. BeyondCorp Connector name using the form: - * `projects/{project_id}/locations/{location_id}/connectors/{connector}` - * @param ResourceInfo $resourceInfo Required. Resource info of the connector. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 reportStatus( - $appConnector, - $resourceInfo, - array $optionalArgs = [] - ) { - $request = new ReportStatusRequest(); - $requestParamHeaders = []; - $request->setAppConnector($appConnector); - $request->setResourceInfo($resourceInfo); - $requestParamHeaders['app_connector'] = $appConnector; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'ReportStatus', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Updates the parameters of a single AppConnector. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $appConnector = new AppConnector(); - * $operationResponse = $appConnectorsServiceClient->updateAppConnector($updateMask, $appConnector); - * $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 = $appConnectorsServiceClient->updateAppConnector($updateMask, $appConnector); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appConnectorsServiceClient->resumeOperation($operationName, 'updateAppConnector'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field may only include these - * fields from [BeyondCorp.AppConnector]: - * * `labels` - * * `display_name` - * @param AppConnector $appConnector Required. AppConnector message with updated fields. Only supported fields - * specified in update_mask are updated. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 updateAppConnector( - $updateMask, - $appConnector, - array $optionalArgs = [] - ) { - $request = new UpdateAppConnectorRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setAppConnector($appConnector); - $requestParamHeaders['app_connector.name'] = $appConnector->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateAppConnector', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $response = $appConnectorsServiceClient->getLocation(); - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $appConnectorsServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appConnectorsServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $resource = 'resource'; - * $response = $appConnectorsServiceClient->getIamPolicy($resource); - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $appConnectorsServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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->startCall( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * Sample code: - * ``` - * $appConnectorsServiceClient = new AppConnectorsServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $appConnectorsServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $appConnectorsServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/BeyondCorpAppConnectors/src/V1/GetAppConnectorRequest.php b/BeyondCorpAppConnectors/src/V1/GetAppConnectorRequest.php index b6e027fb8ff9..977e4560e303 100644 --- a/BeyondCorpAppConnectors/src/V1/GetAppConnectorRequest.php +++ b/BeyondCorpAppConnectors/src/V1/GetAppConnectorRequest.php @@ -21,7 +21,7 @@ class GetAppConnectorRequest 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. BeyondCorp AppConnector name using the form: diff --git a/BeyondCorpAppConnectors/src/V1/ImageConfig.php b/BeyondCorpAppConnectors/src/V1/ImageConfig.php index 309803f0fb3a..f31d9006cf66 100644 --- a/BeyondCorpAppConnectors/src/V1/ImageConfig.php +++ b/BeyondCorpAppConnectors/src/V1/ImageConfig.php @@ -21,14 +21,14 @@ class ImageConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string target_image = 1; */ - private $target_image = ''; + protected $target_image = ''; /** * The stable image that the remote agent will fallback to if the target image * fails. * * Generated from protobuf field string stable_image = 2; */ - private $stable_image = ''; + protected $stable_image = ''; /** * Constructor. diff --git a/BeyondCorpAppConnectors/src/V1/ListAppConnectorsRequest.php b/BeyondCorpAppConnectors/src/V1/ListAppConnectorsRequest.php index 733116c6737e..eb6639769249 100644 --- a/BeyondCorpAppConnectors/src/V1/ListAppConnectorsRequest.php +++ b/BeyondCorpAppConnectors/src/V1/ListAppConnectorsRequest.php @@ -21,7 +21,7 @@ class ListAppConnectorsRequest 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 items to return. * If not specified, a default value of 50 will be used by the service. @@ -32,20 +32,20 @@ class ListAppConnectorsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous * ListAppConnectorsRequest, if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. A filter specifying constraints of a list operation. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Specifies the ordering of results. See * [Sorting @@ -54,7 +54,7 @@ class ListAppConnectorsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The resource name of the AppConnector location using the form: diff --git a/BeyondCorpAppConnectors/src/V1/ListAppConnectorsResponse.php b/BeyondCorpAppConnectors/src/V1/ListAppConnectorsResponse.php index c0ec0e7f9a70..4dd5d6387e1b 100644 --- a/BeyondCorpAppConnectors/src/V1/ListAppConnectorsResponse.php +++ b/BeyondCorpAppConnectors/src/V1/ListAppConnectorsResponse.php @@ -27,7 +27,7 @@ class ListAppConnectorsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * A list of locations that could not be reached. * diff --git a/BeyondCorpAppConnectors/src/V1/NotificationConfig/CloudPubSubNotificationConfig.php b/BeyondCorpAppConnectors/src/V1/NotificationConfig/CloudPubSubNotificationConfig.php index c6187decef19..176ad7965e69 100644 --- a/BeyondCorpAppConnectors/src/V1/NotificationConfig/CloudPubSubNotificationConfig.php +++ b/BeyondCorpAppConnectors/src/V1/NotificationConfig/CloudPubSubNotificationConfig.php @@ -20,7 +20,7 @@ class CloudPubSubNotificationConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string pubsub_subscription = 1; */ - private $pubsub_subscription = ''; + protected $pubsub_subscription = ''; /** * Constructor. diff --git a/BeyondCorpAppConnectors/src/V1/ReportStatusRequest.php b/BeyondCorpAppConnectors/src/V1/ReportStatusRequest.php index e3f04afb0147..15a4889b3bc3 100644 --- a/BeyondCorpAppConnectors/src/V1/ReportStatusRequest.php +++ b/BeyondCorpAppConnectors/src/V1/ReportStatusRequest.php @@ -21,13 +21,13 @@ class ReportStatusRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_connector = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $app_connector = ''; + protected $app_connector = ''; /** * Required. Resource info of the connector. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.ResourceInfo resource_info = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $resource_info = null; + protected $resource_info = null; /** * Optional. 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 @@ -43,14 +43,14 @@ class ReportStatusRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $appConnector Required. BeyondCorp Connector name using the form: diff --git a/BeyondCorpAppConnectors/src/V1/ResourceInfo.php b/BeyondCorpAppConnectors/src/V1/ResourceInfo.php index c2efa041d33e..e2ea6c977df7 100644 --- a/BeyondCorpAppConnectors/src/V1/ResourceInfo.php +++ b/BeyondCorpAppConnectors/src/V1/ResourceInfo.php @@ -29,27 +29,27 @@ class ResourceInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $id = ''; + protected $id = ''; /** * Overall health status. Overall status is derived based on the status of * each sub level resources. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.HealthStatus status = 2; */ - private $status = 0; + protected $status = 0; /** * Specific details for the resource. This is for internal use only. * * Generated from protobuf field .google.protobuf.Any resource = 3; */ - private $resource = null; + protected $resource = null; /** * The timestamp to collect the info. It is suggested to be set by * the topmost level resource only. * * Generated from protobuf field .google.protobuf.Timestamp time = 4; */ - private $time = null; + protected $time = null; /** * List of Info for the sub level resources. * diff --git a/BeyondCorpAppConnectors/src/V1/UpdateAppConnectorRequest.php b/BeyondCorpAppConnectors/src/V1/UpdateAppConnectorRequest.php index c4464ebe1dc4..eb3293b86e4f 100644 --- a/BeyondCorpAppConnectors/src/V1/UpdateAppConnectorRequest.php +++ b/BeyondCorpAppConnectors/src/V1/UpdateAppConnectorRequest.php @@ -24,14 +24,14 @@ class UpdateAppConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. AppConnector message with updated fields. Only supported fields * specified in update_mask are updated. * * Generated from protobuf field .google.cloud.beyondcorp.appconnectors.v1.AppConnector app_connector = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_connector = null; + protected $app_connector = null; /** * Optional. 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 @@ -47,14 +47,14 @@ class UpdateAppConnectorRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param \Google\Cloud\BeyondCorp\AppConnectors\V1\AppConnector $appConnector Required. AppConnector message with updated fields. Only supported fields diff --git a/BeyondCorpAppConnectors/tests/Unit/V1/AppConnectorsServiceClientTest.php b/BeyondCorpAppConnectors/tests/Unit/V1/AppConnectorsServiceClientTest.php deleted file mode 100644 index 21624429984b..000000000000 --- a/BeyondCorpAppConnectors/tests/Unit/V1/AppConnectorsServiceClientTest.php +++ /dev/null @@ -1,1034 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AppConnectorsServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AppConnectorsServiceClient($options); - } - - /** @test */ - public function createAppConnectorTest() - { - $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/createAppConnectorTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnector(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createAppConnectorTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $appConnector = new AppConnector(); - $appConnectorName = 'appConnectorName-1263736873'; - $appConnector->setName($appConnectorName); - $appConnectorPrincipalInfo = new PrincipalInfo(); - $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $response = $gapicClient->createAppConnector($formattedParent, $appConnector); - $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.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getAppConnector(); - $this->assertProtobufEquals($appConnector, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppConnectorTest'); - $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 createAppConnectorExceptionTest() - { - $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/createAppConnectorTest'); - $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]'); - $appConnector = new AppConnector(); - $appConnectorName = 'appConnectorName-1263736873'; - $appConnector->setName($appConnectorName); - $appConnectorPrincipalInfo = new PrincipalInfo(); - $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $response = $gapicClient->createAppConnector($formattedParent, $appConnector); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppConnectorTest'); - 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 deleteAppConnectorTest() - { - $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/deleteAppConnectorTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteAppConnectorTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $response = $gapicClient->deleteAppConnector($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.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppConnectorTest'); - $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 deleteAppConnectorExceptionTest() - { - $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/deleteAppConnectorTest'); - $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->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $response = $gapicClient->deleteAppConnector($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppConnectorTest'); - 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 getAppConnectorTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnector(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $response = $gapicClient->getAppConnector($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.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAppConnectorExceptionTest() - { - $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->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - try { - $gapicClient->getAppConnector($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 listAppConnectorsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $appConnectorsElement = new AppConnector(); - $appConnectors = [ - $appConnectorsElement, - ]; - $expectedResponse = new ListAppConnectorsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAppConnectors($appConnectors); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listAppConnectors($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAppConnectors()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAppConnectorsExceptionTest() - { - $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->listAppConnectors($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 reportStatusTest() - { - $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/reportStatusTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnector(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/reportStatusTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedAppConnector = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $resourceInfo = new ResourceInfo(); - $resourceInfoId = 'resourceInfoId-332404713'; - $resourceInfo->setId($resourceInfoId); - $response = $gapicClient->reportStatus($formattedAppConnector, $resourceInfo); - $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.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getAppConnector(); - $this->assertProtobufEquals($formattedAppConnector, $actualValue); - $actualValue = $actualApiRequestObject->getResourceInfo(); - $this->assertProtobufEquals($resourceInfo, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reportStatusTest'); - $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 reportStatusExceptionTest() - { - $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/reportStatusTest'); - $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 - $formattedAppConnector = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $resourceInfo = new ResourceInfo(); - $resourceInfoId = 'resourceInfoId-332404713'; - $resourceInfo->setId($resourceInfoId); - $response = $gapicClient->reportStatus($formattedAppConnector, $resourceInfo); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/reportStatusTest'); - 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 updateAppConnectorTest() - { - $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/updateAppConnectorTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $expectedResponse = new AppConnector(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateAppConnectorTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $appConnector = new AppConnector(); - $appConnectorName = 'appConnectorName-1263736873'; - $appConnector->setName($appConnectorName); - $appConnectorPrincipalInfo = new PrincipalInfo(); - $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $response = $gapicClient->updateAppConnector($updateMask, $appConnector); - $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.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getAppConnector(); - $this->assertProtobufEquals($appConnector, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppConnectorTest'); - $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 updateAppConnectorExceptionTest() - { - $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/updateAppConnectorTest'); - $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 - $updateMask = new FieldMask(); - $appConnector = new AppConnector(); - $appConnectorName = 'appConnectorName-1263736873'; - $appConnector->setName($appConnectorName); - $appConnectorPrincipalInfo = new PrincipalInfo(); - $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $response = $gapicClient->updateAppConnector($updateMask, $appConnector); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppConnectorTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->getLocation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->listLocations(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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()); - } -} diff --git a/BeyondCorpAppConnectors/tests/Unit/V1/Client/AppConnectorsServiceClientTest.php b/BeyondCorpAppConnectors/tests/Unit/V1/Client/AppConnectorsServiceClientTest.php index bff4f852225f..321471794753 100644 --- a/BeyondCorpAppConnectors/tests/Unit/V1/Client/AppConnectorsServiceClientTest.php +++ b/BeyondCorpAppConnectors/tests/Unit/V1/Client/AppConnectorsServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AppConnectorsServiceClient */ @@ -125,9 +127,7 @@ public function createAppConnectorTest() $appConnector->setName($appConnectorName); $appConnectorPrincipalInfo = new PrincipalInfo(); $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $request = (new CreateAppConnectorRequest()) - ->setParent($formattedParent) - ->setAppConnector($appConnector); + $request = (new CreateAppConnectorRequest())->setParent($formattedParent)->setAppConnector($appConnector); $response = $gapicClient->createAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -137,7 +137,10 @@ public function createAppConnectorTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppConnector(); @@ -185,12 +188,15 @@ public function createAppConnectorExceptionTest() $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]'); @@ -199,9 +205,7 @@ public function createAppConnectorExceptionTest() $appConnector->setName($appConnectorName); $appConnectorPrincipalInfo = new PrincipalInfo(); $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $request = (new CreateAppConnectorRequest()) - ->setParent($formattedParent) - ->setAppConnector($appConnector); + $request = (new CreateAppConnectorRequest())->setParent($formattedParent)->setAppConnector($appConnector); $response = $gapicClient->createAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -255,8 +259,7 @@ public function deleteAppConnectorTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $request = (new DeleteAppConnectorRequest()) - ->setName($formattedName); + $request = (new DeleteAppConnectorRequest())->setName($formattedName); $response = $gapicClient->deleteAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -266,7 +269,10 @@ public function deleteAppConnectorTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -312,17 +318,19 @@ public function deleteAppConnectorExceptionTest() $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->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $request = (new DeleteAppConnectorRequest()) - ->setName($formattedName); + $request = (new DeleteAppConnectorRequest())->setName($formattedName); $response = $gapicClient->deleteAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -364,15 +372,17 @@ public function getAppConnectorTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $request = (new GetAppConnectorRequest()) - ->setName($formattedName); + $request = (new GetAppConnectorRequest())->setName($formattedName); $response = $gapicClient->getAppConnector($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -389,17 +399,19 @@ public function getAppConnectorExceptionTest() $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->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); - $request = (new GetAppConnectorRequest()) - ->setName($formattedName); + $request = (new GetAppConnectorRequest())->setName($formattedName); try { $gapicClient->getAppConnector($request); // If the $gapicClient method call did not throw, fail the test @@ -424,17 +436,14 @@ public function listAppConnectorsTest() // Mock response $nextPageToken = ''; $appConnectorsElement = new AppConnector(); - $appConnectors = [ - $appConnectorsElement, - ]; + $appConnectors = [$appConnectorsElement]; $expectedResponse = new ListAppConnectorsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAppConnectors($appConnectors); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListAppConnectorsRequest()) - ->setParent($formattedParent); + $request = (new ListAppConnectorsRequest())->setParent($formattedParent); $response = $gapicClient->listAppConnectors($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -444,7 +453,10 @@ public function listAppConnectorsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -461,17 +473,19 @@ public function listAppConnectorsExceptionTest() $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 ListAppConnectorsRequest()) - ->setParent($formattedParent); + $request = (new ListAppConnectorsRequest())->setParent($formattedParent); try { $gapicClient->listAppConnectors($request); // If the $gapicClient method call did not throw, fail the test @@ -525,9 +539,7 @@ public function reportStatusTest() $resourceInfo = new ResourceInfo(); $resourceInfoId = 'resourceInfoId-332404713'; $resourceInfo->setId($resourceInfoId); - $request = (new ReportStatusRequest()) - ->setAppConnector($formattedAppConnector) - ->setResourceInfo($resourceInfo); + $request = (new ReportStatusRequest())->setAppConnector($formattedAppConnector)->setResourceInfo($resourceInfo); $response = $gapicClient->reportStatus($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -537,7 +549,10 @@ public function reportStatusTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getAppConnector(); $this->assertProtobufEquals($formattedAppConnector, $actualValue); $actualValue = $actualApiRequestObject->getResourceInfo(); @@ -585,21 +600,22 @@ public function reportStatusExceptionTest() $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 $formattedAppConnector = $gapicClient->appConnectorName('[PROJECT]', '[LOCATION]', '[APP_CONNECTOR]'); $resourceInfo = new ResourceInfo(); $resourceInfoId = 'resourceInfoId-332404713'; $resourceInfo->setId($resourceInfoId); - $request = (new ReportStatusRequest()) - ->setAppConnector($formattedAppConnector) - ->setResourceInfo($resourceInfo); + $request = (new ReportStatusRequest())->setAppConnector($formattedAppConnector)->setResourceInfo($resourceInfo); $response = $gapicClient->reportStatus($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -664,9 +680,7 @@ public function updateAppConnectorTest() $appConnector->setName($appConnectorName); $appConnectorPrincipalInfo = new PrincipalInfo(); $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $request = (new UpdateAppConnectorRequest()) - ->setUpdateMask($updateMask) - ->setAppConnector($appConnector); + $request = (new UpdateAppConnectorRequest())->setUpdateMask($updateMask)->setAppConnector($appConnector); $response = $gapicClient->updateAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -676,7 +690,10 @@ public function updateAppConnectorTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getAppConnector(); @@ -724,12 +741,15 @@ public function updateAppConnectorExceptionTest() $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 $updateMask = new FieldMask(); @@ -738,9 +758,7 @@ public function updateAppConnectorExceptionTest() $appConnector->setName($appConnectorName); $appConnectorPrincipalInfo = new PrincipalInfo(); $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $request = (new UpdateAppConnectorRequest()) - ->setUpdateMask($updateMask) - ->setAppConnector($appConnector); + $request = (new UpdateAppConnectorRequest())->setUpdateMask($updateMask)->setAppConnector($appConnector); $response = $gapicClient->updateAppConnector($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -802,12 +820,15 @@ public function getLocationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -834,9 +855,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -866,12 +885,15 @@ public function listLocationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -904,8 +926,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -929,17 +950,19 @@ public function getIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -971,9 +994,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -999,19 +1020,20 @@ public function setIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -1039,9 +1061,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -1067,19 +1087,20 @@ public function testIamPermissionsExceptionTest() $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 $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -1135,9 +1156,7 @@ public function createAppConnectorAsyncTest() $appConnector->setName($appConnectorName); $appConnectorPrincipalInfo = new PrincipalInfo(); $appConnector->setPrincipalInfo($appConnectorPrincipalInfo); - $request = (new CreateAppConnectorRequest()) - ->setParent($formattedParent) - ->setAppConnector($appConnector); + $request = (new CreateAppConnectorRequest())->setParent($formattedParent)->setAppConnector($appConnector); $response = $gapicClient->createAppConnectorAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -1147,7 +1166,10 @@ public function createAppConnectorAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppConnector(); diff --git a/BeyondCorpAppGateways/.OwlBot.yaml b/BeyondCorpAppGateways/.OwlBot.yaml index a5ca8df0dc93..3c0e476f5c25 100644 --- a/BeyondCorpAppGateways/.OwlBot.yaml +++ b/BeyondCorpAppGateways/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/beyondcorp/appgateways/v1/.*-php/(.*) - dest: /owl-bot-staging/BeyondCorpAppGateways/v1/$1 + - source: /google/cloud/beyondcorp/appgateways/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BeyondCorpAppGateways/$1/$2 api-name: BeyondCorpAppGateways diff --git a/BeyondCorpAppGateways/owlbot.py b/BeyondCorpAppGateways/owlbot.py index 13fe4259a0b7..296f97779625 100644 --- a/BeyondCorpAppGateways/owlbot.py +++ b/BeyondCorpAppGateways/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/BeyondCorpAppGateways/src/V1/AppGateway.php b/BeyondCorpAppGateways/src/V1/AppGateway.php index 1f87e79f3e7a..37dbc13aa53e 100644 --- a/BeyondCorpAppGateways/src/V1/AppGateway.php +++ b/BeyondCorpAppGateways/src/V1/AppGateway.php @@ -24,19 +24,19 @@ class AppGateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. Timestamp when the resource was created. * * 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. Timestamp when the resource was last modified. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. Resource labels to represent user provided metadata. * @@ -49,32 +49,32 @@ class AppGateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Output only. A unique identifier for the instance generated by the * system. * * Generated from protobuf field string uid = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uid = ''; + protected $uid = ''; /** * Required. The type of network connectivity used by the AppGateway. * * Generated from protobuf field .google.cloud.beyondcorp.appgateways.v1.AppGateway.Type type = 7 [(.google.api.field_behavior) = REQUIRED]; */ - private $type = 0; + protected $type = 0; /** * Output only. The current state of the AppGateway. * * Generated from protobuf field .google.cloud.beyondcorp.appgateways.v1.AppGateway.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. Server-defined URI for this resource. * * Generated from protobuf field string uri = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $uri = ''; + protected $uri = ''; /** * Output only. A list of connections allocated for the Gateway * @@ -86,7 +86,7 @@ class AppGateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.beyondcorp.appgateways.v1.AppGateway.HostType host_type = 11 [(.google.api.field_behavior) = REQUIRED]; */ - private $host_type = 0; + protected $host_type = 0; /** * Constructor. diff --git a/BeyondCorpAppGateways/src/V1/AppGateway/AllocatedConnection.php b/BeyondCorpAppGateways/src/V1/AppGateway/AllocatedConnection.php index 4ac9cda10a6d..a98a2c17f65b 100644 --- a/BeyondCorpAppGateways/src/V1/AppGateway/AllocatedConnection.php +++ b/BeyondCorpAppGateways/src/V1/AppGateway/AllocatedConnection.php @@ -20,13 +20,13 @@ class AllocatedConnection extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string psc_uri = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $psc_uri = ''; + protected $psc_uri = ''; /** * Required. The ingress port of an allocated connection * * Generated from protobuf field int32 ingress_port = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $ingress_port = 0; + protected $ingress_port = 0; /** * Constructor. diff --git a/BeyondCorpAppGateways/src/V1/AppGatewayOperationMetadata.php b/BeyondCorpAppGateways/src/V1/AppGatewayOperationMetadata.php index a2b5770564fd..cc45976fe154 100644 --- a/BeyondCorpAppGateways/src/V1/AppGatewayOperationMetadata.php +++ b/BeyondCorpAppGateways/src/V1/AppGatewayOperationMetadata.php @@ -20,31 +20,31 @@ class AppGatewayOperationMetadata 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 @@ -54,13 +54,13 @@ class AppGatewayOperationMetadata 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/BeyondCorpAppGateways/src/V1/AppGatewaysServiceClient.php b/BeyondCorpAppGateways/src/V1/AppGatewaysServiceClient.php deleted file mode 100644 index 3dd67dbe813a..000000000000 --- a/BeyondCorpAppGateways/src/V1/AppGatewaysServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways', - $argument, - ['\Google\Cloud\BeyondCorp\AppGateways\V1\ListAppGatewaysResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single AppGateway. - * @param \Google\Cloud\BeyondCorp\AppGateways\V1\GetAppGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetAppGateway(\Google\Cloud\BeyondCorp\AppGateways\V1\GetAppGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/GetAppGateway', - $argument, - ['\Google\Cloud\BeyondCorp\AppGateways\V1\AppGateway', 'decode'], - $metadata, $options); - } - - /** - * Creates a new AppGateway in a given project and location. - * @param \Google\Cloud\BeyondCorp\AppGateways\V1\CreateAppGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateAppGateway(\Google\Cloud\BeyondCorp\AppGateways\V1\CreateAppGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single AppGateway. - * @param \Google\Cloud\BeyondCorp\AppGateways\V1\DeleteAppGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteAppGateway(\Google\Cloud\BeyondCorp\AppGateways\V1\DeleteAppGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php b/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php index b61a22e179f8..88498369e2ce 100644 --- a/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php +++ b/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.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 app_gateway * resource. @@ -538,8 +557,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/BeyondCorpAppGateways/src/V1/CreateAppGatewayRequest.php b/BeyondCorpAppGateways/src/V1/CreateAppGatewayRequest.php index 7cdb4f5bb709..1462f6d587f3 100644 --- a/BeyondCorpAppGateways/src/V1/CreateAppGatewayRequest.php +++ b/BeyondCorpAppGateways/src/V1/CreateAppGatewayRequest.php @@ -21,7 +21,7 @@ class CreateAppGatewayRequest 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. User-settable AppGateway resource ID. * * Must start with a letter. @@ -30,13 +30,13 @@ class CreateAppGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_gateway_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $app_gateway_id = ''; + protected $app_gateway_id = ''; /** * Required. A BeyondCorp AppGateway resource. * * Generated from protobuf field .google.cloud.beyondcorp.appgateways.v1.AppGateway app_gateway = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_gateway = null; + protected $app_gateway = null; /** * Optional. 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 @@ -52,14 +52,14 @@ class CreateAppGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. The resource project name of the AppGateway location using the diff --git a/BeyondCorpAppGateways/src/V1/DeleteAppGatewayRequest.php b/BeyondCorpAppGateways/src/V1/DeleteAppGatewayRequest.php index 12f8ed7be02e..0dd9bed3f1c3 100644 --- a/BeyondCorpAppGateways/src/V1/DeleteAppGatewayRequest.php +++ b/BeyondCorpAppGateways/src/V1/DeleteAppGatewayRequest.php @@ -21,7 +21,7 @@ class DeleteAppGatewayRequest 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 = ''; /** * Optional. 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 @@ -37,14 +37,14 @@ class DeleteAppGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. BeyondCorp AppGateway name using the form: diff --git a/BeyondCorpAppGateways/src/V1/Gapic/AppGatewaysServiceGapicClient.php b/BeyondCorpAppGateways/src/V1/Gapic/AppGatewaysServiceGapicClient.php deleted file mode 100644 index 4225143082a4..000000000000 --- a/BeyondCorpAppGateways/src/V1/Gapic/AppGatewaysServiceGapicClient.php +++ /dev/null @@ -1,1083 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $appGateway = new AppGateway(); - * $operationResponse = $appGatewaysServiceClient->createAppGateway($formattedParent, $appGateway); - * $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 = $appGatewaysServiceClient->createAppGateway($formattedParent, $appGateway); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appGatewaysServiceClient->resumeOperation($operationName, 'createAppGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appGatewaysServiceClient->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\BeyondCorp\AppGateways\V1\Client\AppGatewaysServiceClient}. - */ -class AppGatewaysServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.beyondcorp.appgateways.v1.AppGatewaysService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'beyondcorp.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 $appGatewayNameTemplate; - - 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/app_gateways_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/app_gateways_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../resources/app_gateways_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/app_gateways_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getAppGatewayNameTemplate() - { - if (self::$appGatewayNameTemplate == null) { - self::$appGatewayNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/appGateways/{app_gateway}' - ); - } - - return self::$appGatewayNameTemplate; - } - - 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 = [ - 'appGateway' => self::getAppGatewayNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a app_gateway - * resource. - * - * @param string $project - * @param string $location - * @param string $appGateway - * - * @return string The formatted app_gateway resource. - */ - public static function appGatewayName($project, $location, $appGateway) - { - return self::getAppGatewayNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'app_gateway' => $appGateway, - ]); - } - - /** - * 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 - * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} - * - 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 'beyondcorp.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 AppGateway in a given project and location. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $formattedParent = $appGatewaysServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $appGateway = new AppGateway(); - * $operationResponse = $appGatewaysServiceClient->createAppGateway($formattedParent, $appGateway); - * $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 = $appGatewaysServiceClient->createAppGateway($formattedParent, $appGateway); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appGatewaysServiceClient->resumeOperation($operationName, 'createAppGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource project name of the AppGateway location using the - * form: `projects/{project_id}/locations/{location_id}` - * @param AppGateway $appGateway Required. A BeyondCorp AppGateway resource. - * @param array $optionalArgs { - * Optional. - * - * @type string $appGatewayId - * Optional. User-settable AppGateway resource ID. - * * Must start with a letter. - * * Must contain between 4-63 characters from `/[a-z][0-9]-/`. - * * Must end with a number or a letter. - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 createAppGateway( - $parent, - $appGateway, - array $optionalArgs = [] - ) { - $request = new CreateAppGatewayRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAppGateway($appGateway); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['appGatewayId'])) { - $request->setAppGatewayId($optionalArgs['appGatewayId']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateAppGateway', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single AppGateway. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $formattedName = $appGatewaysServiceClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - * $operationResponse = $appGatewaysServiceClient->deleteAppGateway($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 = $appGatewaysServiceClient->deleteAppGateway($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $appGatewaysServiceClient->resumeOperation($operationName, 'deleteAppGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp AppGateway name using the form: - * `projects/{project_id}/locations/{location_id}/appGateways/{app_gateway_id}` - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 deleteAppGateway($name, array $optionalArgs = []) - { - $request = new DeleteAppGatewayRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteAppGateway', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single AppGateway. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $formattedName = $appGatewaysServiceClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - * $response = $appGatewaysServiceClient->getAppGateway($formattedName); - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $name Required. BeyondCorp AppGateway name using the form: - * `projects/{project_id}/locations/{location_id}/appGateways/{app_gateway_id}` - * @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\BeyondCorp\AppGateways\V1\AppGateway - * - * @throws ApiException if the remote call fails - */ - public function getAppGateway($name, array $optionalArgs = []) - { - $request = new GetAppGatewayRequest(); - $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( - 'GetAppGateway', - AppGateway::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists AppGateways in a given project and location. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $formattedParent = $appGatewaysServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $appGatewaysServiceClient->listAppGateways($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appGatewaysServiceClient->listAppGateways($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The resource name of the AppGateway location using the form: - * `projects/{project_id}/locations/{location_id}` - * @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. A filter specifying constraints of a list operation. - * @type string $orderBy - * Optional. Specifies the ordering of results. See - * [Sorting - * order](https://cloud.google.com/apis/design/design_patterns#sorting_order) - * for more information. - * @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 listAppGateways($parent, array $optionalArgs = []) - { - $request = new ListAppGatewaysRequest(); - $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( - 'ListAppGateways', - $optionalArgs, - ListAppGatewaysResponse::class, - $request - ); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $response = $appGatewaysServiceClient->getLocation(); - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $appGatewaysServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $appGatewaysServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $response = $appGatewaysServiceClient->getIamPolicy($resource); - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $appGatewaysServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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->startCall( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * Sample code: - * ``` - * $appGatewaysServiceClient = new AppGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $appGatewaysServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $appGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/BeyondCorpAppGateways/src/V1/GetAppGatewayRequest.php b/BeyondCorpAppGateways/src/V1/GetAppGatewayRequest.php index 829a72acb3cb..f19a8b563b82 100644 --- a/BeyondCorpAppGateways/src/V1/GetAppGatewayRequest.php +++ b/BeyondCorpAppGateways/src/V1/GetAppGatewayRequest.php @@ -21,7 +21,7 @@ class GetAppGatewayRequest 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. BeyondCorp AppGateway name using the form: diff --git a/BeyondCorpAppGateways/src/V1/ListAppGatewaysRequest.php b/BeyondCorpAppGateways/src/V1/ListAppGatewaysRequest.php index 751049db5960..7fde412ec54b 100644 --- a/BeyondCorpAppGateways/src/V1/ListAppGatewaysRequest.php +++ b/BeyondCorpAppGateways/src/V1/ListAppGatewaysRequest.php @@ -21,7 +21,7 @@ class ListAppGatewaysRequest 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 items to return. * If not specified, a default value of 50 will be used by the service. @@ -32,20 +32,20 @@ class ListAppGatewaysRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The next_page_token value returned from a previous * ListAppGatewaysRequest, if any. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. A filter specifying constraints of a list operation. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Specifies the ordering of results. See * [Sorting @@ -54,7 +54,7 @@ class ListAppGatewaysRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. The resource name of the AppGateway location using the form: diff --git a/BeyondCorpAppGateways/src/V1/ListAppGatewaysResponse.php b/BeyondCorpAppGateways/src/V1/ListAppGatewaysResponse.php index 5429da9e9735..757bac5b484a 100644 --- a/BeyondCorpAppGateways/src/V1/ListAppGatewaysResponse.php +++ b/BeyondCorpAppGateways/src/V1/ListAppGatewaysResponse.php @@ -27,7 +27,7 @@ class ListAppGatewaysResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * A list of locations that could not be reached. * diff --git a/BeyondCorpAppGateways/tests/Unit/V1/AppGatewaysServiceClientTest.php b/BeyondCorpAppGateways/tests/Unit/V1/AppGatewaysServiceClientTest.php deleted file mode 100644 index d2a6e1f07938..000000000000 --- a/BeyondCorpAppGateways/tests/Unit/V1/AppGatewaysServiceClientTest.php +++ /dev/null @@ -1,775 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return AppGatewaysServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new AppGatewaysServiceClient($options); - } - - /** @test */ - public function createAppGatewayTest() - { - $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/createAppGatewayTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $uri = 'uri116076'; - $expectedResponse = new AppGateway(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $expectedResponse->setUri($uri); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createAppGatewayTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $appGateway = new AppGateway(); - $appGatewayName = 'appGatewayName-1786203634'; - $appGateway->setName($appGatewayName); - $appGatewayType = Type::TYPE_UNSPECIFIED; - $appGateway->setType($appGatewayType); - $appGatewayHostType = HostType::HOST_TYPE_UNSPECIFIED; - $appGateway->setHostType($appGatewayHostType); - $response = $gapicClient->createAppGateway($formattedParent, $appGateway); - $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.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getAppGateway(); - $this->assertProtobufEquals($appGateway, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppGatewayTest'); - $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 createAppGatewayExceptionTest() - { - $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/createAppGatewayTest'); - $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]'); - $appGateway = new AppGateway(); - $appGatewayName = 'appGatewayName-1786203634'; - $appGateway->setName($appGatewayName); - $appGatewayType = Type::TYPE_UNSPECIFIED; - $appGateway->setType($appGatewayType); - $appGatewayHostType = HostType::HOST_TYPE_UNSPECIFIED; - $appGateway->setHostType($appGatewayHostType); - $response = $gapicClient->createAppGateway($formattedParent, $appGateway); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAppGatewayTest'); - 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 deleteAppGatewayTest() - { - $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/deleteAppGatewayTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteAppGatewayTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $response = $gapicClient->deleteAppGateway($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.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppGatewayTest'); - $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 deleteAppGatewayExceptionTest() - { - $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/deleteAppGatewayTest'); - $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->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $response = $gapicClient->deleteAppGateway($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteAppGatewayTest'); - 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 getAppGatewayTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $uid = 'uid115792'; - $uri = 'uri116076'; - $expectedResponse = new AppGateway(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setUid($uid); - $expectedResponse->setUri($uri); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $response = $gapicClient->getAppGateway($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.beyondcorp.appgateways.v1.AppGatewaysService/GetAppGateway', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAppGatewayExceptionTest() - { - $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->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - try { - $gapicClient->getAppGateway($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 listAppGatewaysTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $appGatewaysElement = new AppGateway(); - $appGateways = [ - $appGatewaysElement, - ]; - $expectedResponse = new ListAppGatewaysResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAppGateways($appGateways); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listAppGateways($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAppGateways()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAppGatewaysExceptionTest() - { - $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->listAppGateways($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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->getLocation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->listLocations(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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()); - } -} diff --git a/BeyondCorpAppGateways/tests/Unit/V1/Client/AppGatewaysServiceClientTest.php b/BeyondCorpAppGateways/tests/Unit/V1/Client/AppGatewaysServiceClientTest.php index 7155d2dc2ace..25763d771798 100644 --- a/BeyondCorpAppGateways/tests/Unit/V1/Client/AppGatewaysServiceClientTest.php +++ b/BeyondCorpAppGateways/tests/Unit/V1/Client/AppGatewaysServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AppGatewaysServiceClient */ @@ -126,9 +128,7 @@ public function createAppGatewayTest() $appGateway->setType($appGatewayType); $appGatewayHostType = HostType::HOST_TYPE_UNSPECIFIED; $appGateway->setHostType($appGatewayHostType); - $request = (new CreateAppGatewayRequest()) - ->setParent($formattedParent) - ->setAppGateway($appGateway); + $request = (new CreateAppGatewayRequest())->setParent($formattedParent)->setAppGateway($appGateway); $response = $gapicClient->createAppGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -138,7 +138,10 @@ public function createAppGatewayTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppGateway(); @@ -186,12 +189,15 @@ public function createAppGatewayExceptionTest() $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]'); @@ -202,9 +208,7 @@ public function createAppGatewayExceptionTest() $appGateway->setType($appGatewayType); $appGatewayHostType = HostType::HOST_TYPE_UNSPECIFIED; $appGateway->setHostType($appGatewayHostType); - $request = (new CreateAppGatewayRequest()) - ->setParent($formattedParent) - ->setAppGateway($appGateway); + $request = (new CreateAppGatewayRequest())->setParent($formattedParent)->setAppGateway($appGateway); $response = $gapicClient->createAppGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -258,8 +262,7 @@ public function deleteAppGatewayTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $request = (new DeleteAppGatewayRequest()) - ->setName($formattedName); + $request = (new DeleteAppGatewayRequest())->setName($formattedName); $response = $gapicClient->deleteAppGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -269,7 +272,10 @@ public function deleteAppGatewayTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -315,17 +321,19 @@ public function deleteAppGatewayExceptionTest() $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->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $request = (new DeleteAppGatewayRequest()) - ->setName($formattedName); + $request = (new DeleteAppGatewayRequest())->setName($formattedName); $response = $gapicClient->deleteAppGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -369,8 +377,7 @@ public function getAppGatewayTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $request = (new GetAppGatewayRequest()) - ->setName($formattedName); + $request = (new GetAppGatewayRequest())->setName($formattedName); $response = $gapicClient->getAppGateway($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -394,17 +401,19 @@ public function getAppGatewayExceptionTest() $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->appGatewayName('[PROJECT]', '[LOCATION]', '[APP_GATEWAY]'); - $request = (new GetAppGatewayRequest()) - ->setName($formattedName); + $request = (new GetAppGatewayRequest())->setName($formattedName); try { $gapicClient->getAppGateway($request); // If the $gapicClient method call did not throw, fail the test @@ -429,17 +438,14 @@ public function listAppGatewaysTest() // Mock response $nextPageToken = ''; $appGatewaysElement = new AppGateway(); - $appGateways = [ - $appGatewaysElement, - ]; + $appGateways = [$appGatewaysElement]; $expectedResponse = new ListAppGatewaysResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAppGateways($appGateways); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListAppGatewaysRequest()) - ->setParent($formattedParent); + $request = (new ListAppGatewaysRequest())->setParent($formattedParent); $response = $gapicClient->listAppGateways($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -449,7 +455,10 @@ public function listAppGatewaysTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -466,17 +475,19 @@ public function listAppGatewaysExceptionTest() $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 ListAppGatewaysRequest()) - ->setParent($formattedParent); + $request = (new ListAppGatewaysRequest())->setParent($formattedParent); try { $gapicClient->listAppGateways($request); // If the $gapicClient method call did not throw, fail the test @@ -529,12 +540,15 @@ public function getLocationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -561,9 +575,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -593,12 +605,15 @@ public function listLocationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -631,8 +646,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -656,17 +670,19 @@ public function getIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -698,9 +714,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -726,19 +740,20 @@ public function setIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -766,9 +781,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -794,19 +807,20 @@ public function testIamPermissionsExceptionTest() $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 $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -866,9 +880,7 @@ public function createAppGatewayAsyncTest() $appGateway->setType($appGatewayType); $appGatewayHostType = HostType::HOST_TYPE_UNSPECIFIED; $appGateway->setHostType($appGatewayHostType); - $request = (new CreateAppGatewayRequest()) - ->setParent($formattedParent) - ->setAppGateway($appGateway); + $request = (new CreateAppGatewayRequest())->setParent($formattedParent)->setAppGateway($appGateway); $response = $gapicClient->createAppGatewayAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -878,7 +890,10 @@ public function createAppGatewayAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getAppGateway(); diff --git a/BeyondCorpClientConnectorServices/.OwlBot.yaml b/BeyondCorpClientConnectorServices/.OwlBot.yaml index c50111baf05d..e0f5e4a7583f 100644 --- a/BeyondCorpClientConnectorServices/.OwlBot.yaml +++ b/BeyondCorpClientConnectorServices/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/beyondcorp/clientconnectorservices/v1/.*-php/(.*) - dest: /owl-bot-staging/BeyondCorpClientConnectorServices/v1/$1 + - source: /google/cloud/beyondcorp/clientconnectorservices/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BeyondCorpClientConnectorServices/$1/$2 api-name: BeyondCorpClientConnectorServices diff --git a/BeyondCorpClientConnectorServices/owlbot.py b/BeyondCorpClientConnectorServices/owlbot.py index 3d9cbc2794e0..68670ecf3e70 100644 --- a/BeyondCorpClientConnectorServices/owlbot.py +++ b/BeyondCorpClientConnectorServices/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/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php b/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php index f854f92bd609..1876632db42d 100644 --- a/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php +++ b/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php @@ -1,6 +1,6 @@ self::SERVICE_NAME, 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, 'clientConfig' => __DIR__ . '/../resources/client_connector_services_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/client_connector_services_service_descriptor_config.php', + 'descriptorsConfigPath' => + __DIR__ . '/../resources/client_connector_services_service_descriptor_config.php', 'gcpApiConfigPath' => __DIR__ . '/../resources/client_connector_services_service_grpc_config.json', 'credentialsConfig' => [ 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/client_connector_services_service_rest_client_config.php', + 'restClientConfigPath' => + __DIR__ . '/../resources/client_connector_services_service_rest_client_config.php', ], ], ]; @@ -157,12 +157,33 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; } + /** + * Create the default operation client for the service. + * + * @param array $options ClientOptions for the client. + * + * @return OperationsClient + */ + private function createOperationsClient(array $options) + { + // Unset client-specific configuration options + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); + + if (isset($options['operationsClient'])) { + return $options['operationsClient']; + } + + return new OperationsClient($options); + } + /** * Formats a string containing the fully-qualified path to represent a * client_connector_service resource. @@ -173,8 +194,11 @@ public function resumeOperation($operationName, $methodName = null) * * @return string The formatted client_connector_service resource. */ - public static function clientConnectorServiceName(string $project, string $location, string $clientConnectorService): string - { + public static function clientConnectorServiceName( + string $project, + string $location, + string $clientConnectorService + ): string { return self::getPathTemplate('clientConnectorService')->render([ 'project' => $project, 'location' => $location, @@ -319,8 +343,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createClientConnectorService(CreateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { + public function createClientConnectorService( + CreateClientConnectorServiceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('CreateClientConnectorService', $request, $callOptions)->wait(); } @@ -347,8 +373,10 @@ public function createClientConnectorService(CreateClientConnectorServiceRequest * * @throws ApiException Thrown if the API call fails. */ - public function deleteClientConnectorService(DeleteClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { + public function deleteClientConnectorService( + DeleteClientConnectorServiceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('DeleteClientConnectorService', $request, $callOptions)->wait(); } @@ -374,8 +402,10 @@ public function deleteClientConnectorService(DeleteClientConnectorServiceRequest * * @throws ApiException Thrown if the API call fails. */ - public function getClientConnectorService(GetClientConnectorServiceRequest $request, array $callOptions = []): ClientConnectorService - { + public function getClientConnectorService( + GetClientConnectorServiceRequest $request, + array $callOptions = [] + ): ClientConnectorService { return $this->startApiCall('GetClientConnectorService', $request, $callOptions)->wait(); } @@ -402,8 +432,10 @@ public function getClientConnectorService(GetClientConnectorServiceRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function listClientConnectorServices(ListClientConnectorServicesRequest $request, array $callOptions = []): PagedListResponse - { + public function listClientConnectorServices( + ListClientConnectorServicesRequest $request, + array $callOptions = [] + ): PagedListResponse { return $this->startApiCall('ListClientConnectorServices', $request, $callOptions); } @@ -430,8 +462,10 @@ public function listClientConnectorServices(ListClientConnectorServicesRequest $ * * @throws ApiException Thrown if the API call fails. */ - public function updateClientConnectorService(UpdateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { + public function updateClientConnectorService( + UpdateClientConnectorServiceRequest $request, + array $callOptions = [] + ): OperationResponse { return $this->startApiCall('UpdateClientConnectorService', $request, $callOptions)->wait(); } @@ -576,8 +610,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService.php index f6b4669ff61e..bb20f193a989 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService.php +++ b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService.php @@ -20,19 +20,19 @@ class ClientConnectorService extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. [Output only] Create time stamp. * * 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. [Output only] Update time stamp. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Optional. User-provided name. * The display name should follow certain format. @@ -42,25 +42,25 @@ class ClientConnectorService extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $display_name = ''; + protected $display_name = ''; /** * Required. The details of the ingress settings. * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService.Ingress ingress = 6 [(.google.api.field_behavior) = REQUIRED]; */ - private $ingress = null; + protected $ingress = null; /** * Required. The details of the egress settings. * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService.Egress egress = 7 [(.google.api.field_behavior) = REQUIRED]; */ - private $egress = null; + protected $egress = null; /** * Output only. The operational state of the ClientConnectorService. * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Egress/PeeredVpc.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Egress/PeeredVpc.php index 596e052b35eb..220635366d00 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Egress/PeeredVpc.php +++ b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Egress/PeeredVpc.php @@ -20,7 +20,7 @@ class PeeredVpc extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network_vpc = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $network_vpc = ''; + protected $network_vpc = ''; /** * Constructor. diff --git a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config.php index a5e88be2a71e..d841292f1e90 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config.php +++ b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config.php @@ -21,7 +21,7 @@ class Config extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService.Ingress.Config.TransportProtocol transport_protocol = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = IMMUTABLE]; */ - private $transport_protocol = 0; + protected $transport_protocol = 0; /** * Required. The settings used to configure basic ClientGateways. * diff --git a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config/DestinationRoute.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config/DestinationRoute.php index 862351109362..8c18ca415978 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config/DestinationRoute.php +++ b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorService/Ingress/Config/DestinationRoute.php @@ -23,14 +23,14 @@ class DestinationRoute extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string address = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $address = ''; + protected $address = ''; /** * Required. The network mask of the subnet * for which the packet is routed to the ClientGateway. * * Generated from protobuf field string netmask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $netmask = ''; + protected $netmask = ''; /** * Constructor. diff --git a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServiceOperationMetadata.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServiceOperationMetadata.php index ad0439aaa8bc..844551d17009 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServiceOperationMetadata.php +++ b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServiceOperationMetadata.php @@ -20,31 +20,31 @@ class ClientConnectorServiceOperationMetadata extends \Google\Protobuf\Internal\ * * 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 @@ -54,13 +54,13 @@ class ClientConnectorServiceOperationMetadata extends \Google\Protobuf\Internal\ * * 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/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServicesServiceClient.php b/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServicesServiceClient.php deleted file mode 100644 index 247353034030..000000000000 --- a/BeyondCorpClientConnectorServices/src/V1/ClientConnectorServicesServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices', - $argument, - ['\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ListClientConnectorServicesResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single ClientConnectorService. - * @param \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\GetClientConnectorServiceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetClientConnectorService(\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\GetClientConnectorServiceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService', - $argument, - ['\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ClientConnectorService', 'decode'], - $metadata, $options); - } - - /** - * Creates a new ClientConnectorService in a given project and location. - * @param \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\CreateClientConnectorServiceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateClientConnectorService(\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\CreateClientConnectorServiceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Updates the parameters of a single ClientConnectorService. - * @param \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\UpdateClientConnectorServiceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateClientConnectorService(\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\UpdateClientConnectorServiceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single ClientConnectorService. - * @param \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\DeleteClientConnectorServiceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteClientConnectorService(\Google\Cloud\BeyondCorp\ClientConnectorServices\V1\DeleteClientConnectorServiceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/BeyondCorpClientConnectorServices/src/V1/CreateClientConnectorServiceRequest.php b/BeyondCorpClientConnectorServices/src/V1/CreateClientConnectorServiceRequest.php index d3a9baeac8ba..0a95214649da 100644 --- a/BeyondCorpClientConnectorServices/src/V1/CreateClientConnectorServiceRequest.php +++ b/BeyondCorpClientConnectorServices/src/V1/CreateClientConnectorServiceRequest.php @@ -20,7 +20,7 @@ class CreateClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. User-settable client connector service resource ID. * * Must start with a letter. @@ -31,13 +31,13 @@ class CreateClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string client_connector_service_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $client_connector_service_id = ''; + protected $client_connector_service_id = ''; /** * Required. The resource being created. * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService client_connector_service = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $client_connector_service = null; + protected $client_connector_service = null; /** * Optional. 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 @@ -53,14 +53,14 @@ class CreateClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. Value for parent. Please see diff --git a/BeyondCorpClientConnectorServices/src/V1/DeleteClientConnectorServiceRequest.php b/BeyondCorpClientConnectorServices/src/V1/DeleteClientConnectorServiceRequest.php index fc6657258aaa..191baa3fdc0e 100644 --- a/BeyondCorpClientConnectorServices/src/V1/DeleteClientConnectorServiceRequest.php +++ b/BeyondCorpClientConnectorServices/src/V1/DeleteClientConnectorServiceRequest.php @@ -20,7 +20,7 @@ class DeleteClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. 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 @@ -36,14 +36,14 @@ class DeleteClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. Name of the resource. Please see diff --git a/BeyondCorpClientConnectorServices/src/V1/Gapic/ClientConnectorServicesServiceGapicClient.php b/BeyondCorpClientConnectorServices/src/V1/Gapic/ClientConnectorServicesServiceGapicClient.php deleted file mode 100644 index e2521c6d67eb..000000000000 --- a/BeyondCorpClientConnectorServices/src/V1/Gapic/ClientConnectorServicesServiceGapicClient.php +++ /dev/null @@ -1,1205 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $clientConnectorService = new ClientConnectorService(); - * $operationResponse = $clientConnectorServicesServiceClient->createClientConnectorService($formattedParent, $clientConnectorService); - * $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 = $clientConnectorServicesServiceClient->createClientConnectorService($formattedParent, $clientConnectorService); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientConnectorServicesServiceClient->resumeOperation($operationName, 'createClientConnectorService'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientConnectorServicesServiceClient->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\BeyondCorp\ClientConnectorServices\V1\Client\ClientConnectorServicesServiceClient}. - */ -class ClientConnectorServicesServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'beyondcorp.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 $clientConnectorServiceNameTemplate; - - 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/client_connector_services_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/client_connector_services_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/client_connector_services_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/client_connector_services_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getClientConnectorServiceNameTemplate() - { - if (self::$clientConnectorServiceNameTemplate == null) { - self::$clientConnectorServiceNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/clientConnectorServices/{client_connector_service}' - ); - } - - return self::$clientConnectorServiceNameTemplate; - } - - 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 = [ - 'clientConnectorService' => self::getClientConnectorServiceNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * client_connector_service resource. - * - * @param string $project - * @param string $location - * @param string $clientConnectorService - * - * @return string The formatted client_connector_service resource. - */ - public static function clientConnectorServiceName( - $project, - $location, - $clientConnectorService - ) { - return self::getClientConnectorServiceNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'client_connector_service' => $clientConnectorService, - ]); - } - - /** - * 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 - * - clientConnectorService: projects/{project}/locations/{location}/clientConnectorServices/{client_connector_service} - * - 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 'beyondcorp.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 ClientConnectorService in a given project and location. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $formattedParent = $clientConnectorServicesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $clientConnectorService = new ClientConnectorService(); - * $operationResponse = $clientConnectorServicesServiceClient->createClientConnectorService($formattedParent, $clientConnectorService); - * $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 = $clientConnectorServicesServiceClient->createClientConnectorService($formattedParent, $clientConnectorService); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientConnectorServicesServiceClient->resumeOperation($operationName, 'createClientConnectorService'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Value for parent. - * @param ClientConnectorService $clientConnectorService Required. The resource being created. - * @param array $optionalArgs { - * Optional. - * - * @type string $clientConnectorServiceId - * Optional. User-settable client connector service resource ID. - * * Must start with a letter. - * * Must contain between 4-63 characters from `/[a-z][0-9]-/`. - * * Must end with a number or a letter. - * - * A random system generated name will be assigned - * if not specified by the user. - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 createClientConnectorService( - $parent, - $clientConnectorService, - array $optionalArgs = [] - ) { - $request = new CreateClientConnectorServiceRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setClientConnectorService($clientConnectorService); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['clientConnectorServiceId'])) { - $request->setClientConnectorServiceId( - $optionalArgs['clientConnectorServiceId'] - ); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateClientConnectorService', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single ClientConnectorService. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $formattedName = $clientConnectorServicesServiceClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - * $operationResponse = $clientConnectorServicesServiceClient->deleteClientConnectorService($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 = $clientConnectorServicesServiceClient->deleteClientConnectorService($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientConnectorServicesServiceClient->resumeOperation($operationName, 'deleteClientConnectorService'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the resource. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 deleteClientConnectorService( - $name, - array $optionalArgs = [] - ) { - $request = new DeleteClientConnectorServiceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteClientConnectorService', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single ClientConnectorService. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $formattedName = $clientConnectorServicesServiceClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - * $response = $clientConnectorServicesServiceClient->getClientConnectorService($formattedName); - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the resource. - * @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\BeyondCorp\ClientConnectorServices\V1\ClientConnectorService - * - * @throws ApiException if the remote call fails - */ - public function getClientConnectorService($name, array $optionalArgs = []) - { - $request = new GetClientConnectorServiceRequest(); - $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( - 'GetClientConnectorService', - ClientConnectorService::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists ClientConnectorServices in a given project and location. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $formattedParent = $clientConnectorServicesServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $clientConnectorServicesServiceClient->listClientConnectorServices($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $clientConnectorServicesServiceClient->listClientConnectorServices($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListClientConnectorServicesRequest. - * @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. Filtering results. - * @type string $orderBy - * Optional. Hint for how to order the results. - * @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 listClientConnectorServices( - $parent, - array $optionalArgs = [] - ) { - $request = new ListClientConnectorServicesRequest(); - $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( - 'ListClientConnectorServices', - $optionalArgs, - ListClientConnectorServicesResponse::class, - $request - ); - } - - /** - * Updates the parameters of a single ClientConnectorService. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $updateMask = new FieldMask(); - * $clientConnectorService = new ClientConnectorService(); - * $operationResponse = $clientConnectorServicesServiceClient->updateClientConnectorService($updateMask, $clientConnectorService); - * $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 = $clientConnectorServicesServiceClient->updateClientConnectorService($updateMask, $clientConnectorService); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientConnectorServicesServiceClient->resumeOperation($operationName, 'updateClientConnectorService'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param FieldMask $updateMask Required. Field mask is used to specify the fields to be overwritten in the - * ClientConnectorService resource by the update. - * 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 then all fields will be overwritten. - * - * Mutable fields: display_name. - * @param ClientConnectorService $clientConnectorService Required. The resource being updated. - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @type bool $allowMissing - * Optional. If set as true, will create the resource if it is not found. - * @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 updateClientConnectorService( - $updateMask, - $clientConnectorService, - array $optionalArgs = [] - ) { - $request = new UpdateClientConnectorServiceRequest(); - $requestParamHeaders = []; - $request->setUpdateMask($updateMask); - $request->setClientConnectorService($clientConnectorService); - $requestParamHeaders[ - 'client_connector_service.name' - ] = $clientConnectorService->getName(); - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - if (isset($optionalArgs['allowMissing'])) { - $request->setAllowMissing($optionalArgs['allowMissing']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'UpdateClientConnectorService', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $response = $clientConnectorServicesServiceClient->getLocation(); - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $clientConnectorServicesServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $clientConnectorServicesServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $resource = 'resource'; - * $response = $clientConnectorServicesServiceClient->getIamPolicy($resource); - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $clientConnectorServicesServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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->startCall( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * Sample code: - * ``` - * $clientConnectorServicesServiceClient = new ClientConnectorServicesServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $clientConnectorServicesServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $clientConnectorServicesServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/BeyondCorpClientConnectorServices/src/V1/GetClientConnectorServiceRequest.php b/BeyondCorpClientConnectorServices/src/V1/GetClientConnectorServiceRequest.php index 26a116ab1704..375cdd935d62 100644 --- a/BeyondCorpClientConnectorServices/src/V1/GetClientConnectorServiceRequest.php +++ b/BeyondCorpClientConnectorServices/src/V1/GetClientConnectorServiceRequest.php @@ -20,7 +20,7 @@ class GetClientConnectorServiceRequest 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. Name of the resource. Please see diff --git a/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesRequest.php b/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesRequest.php index 5710d7889096..5f92bfb0a749 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesRequest.php +++ b/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesRequest.php @@ -20,32 +20,32 @@ class ListClientConnectorServicesRequest extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. Requested page size. Server may return fewer items than * requested. If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. A token identifying a page of results the server should return. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. Filtering results. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Hint for how to order the results. * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. Parent value for ListClientConnectorServicesRequest. Please see diff --git a/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesResponse.php b/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesResponse.php index be85b058b356..606e1598f06e 100644 --- a/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesResponse.php +++ b/BeyondCorpClientConnectorServices/src/V1/ListClientConnectorServicesResponse.php @@ -26,7 +26,7 @@ class ListClientConnectorServicesResponse extends \Google\Protobuf\Internal\Mess * * 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/BeyondCorpClientConnectorServices/src/V1/UpdateClientConnectorServiceRequest.php b/BeyondCorpClientConnectorServices/src/V1/UpdateClientConnectorServiceRequest.php index faf952ce4900..d972d609914e 100644 --- a/BeyondCorpClientConnectorServices/src/V1/UpdateClientConnectorServiceRequest.php +++ b/BeyondCorpClientConnectorServices/src/V1/UpdateClientConnectorServiceRequest.php @@ -25,13 +25,13 @@ class UpdateClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * Required. The resource being updated. * * Generated from protobuf field .google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorService client_connector_service = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $client_connector_service = null; + protected $client_connector_service = null; /** * Optional. 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 @@ -47,20 +47,20 @@ class UpdateClientConnectorServiceRequest extends \Google\Protobuf\Internal\Mess * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * Optional. If set as true, will create the resource if it is not found. * * Generated from protobuf field bool allow_missing = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $allow_missing = false; + protected $allow_missing = false; /** * @param \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ClientConnectorService $clientConnectorService Required. The resource being updated. diff --git a/BeyondCorpClientConnectorServices/tests/Unit/V1/Client/ClientConnectorServicesServiceClientTest.php b/BeyondCorpClientConnectorServices/tests/Unit/V1/Client/ClientConnectorServicesServiceClientTest.php index c7880d02594f..37aa07c83e7a 100644 --- a/BeyondCorpClientConnectorServices/tests/Unit/V1/Client/ClientConnectorServicesServiceClientTest.php +++ b/BeyondCorpClientConnectorServices/tests/Unit/V1/Client/ClientConnectorServicesServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ClientConnectorServicesServiceClient */ @@ -136,7 +138,10 @@ public function createClientConnectorServiceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getClientConnectorService(); @@ -184,12 +189,15 @@ public function createClientConnectorServiceExceptionTest() $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]'); @@ -255,9 +263,12 @@ public function deleteClientConnectorServiceTest() $completeOperation->setResponse($anyResponse); $operationsTransport->addResponse($completeOperation); // Mock request - $formattedName = $gapicClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $request = (new DeleteClientConnectorServiceRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->clientConnectorServiceName( + '[PROJECT]', + '[LOCATION]', + '[CLIENT_CONNECTOR_SERVICE]' + ); + $request = (new DeleteClientConnectorServiceRequest())->setName($formattedName); $response = $gapicClient->deleteClientConnectorService($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -267,7 +278,10 @@ public function deleteClientConnectorServiceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -313,17 +327,23 @@ public function deleteClientConnectorServiceExceptionTest() $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->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $request = (new DeleteClientConnectorServiceRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->clientConnectorServiceName( + '[PROJECT]', + '[LOCATION]', + '[CLIENT_CONNECTOR_SERVICE]' + ); + $request = (new DeleteClientConnectorServiceRequest())->setName($formattedName); $response = $gapicClient->deleteClientConnectorService($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -362,16 +382,22 @@ public function getClientConnectorServiceTest() $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $request = (new GetClientConnectorServiceRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->clientConnectorServiceName( + '[PROJECT]', + '[LOCATION]', + '[CLIENT_CONNECTOR_SERVICE]' + ); + $request = (new GetClientConnectorServiceRequest())->setName($formattedName); $response = $gapicClient->getClientConnectorService($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -388,17 +414,23 @@ public function getClientConnectorServiceExceptionTest() $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->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $request = (new GetClientConnectorServiceRequest()) - ->setName($formattedName); + $formattedName = $gapicClient->clientConnectorServiceName( + '[PROJECT]', + '[LOCATION]', + '[CLIENT_CONNECTOR_SERVICE]' + ); + $request = (new GetClientConnectorServiceRequest())->setName($formattedName); try { $gapicClient->getClientConnectorService($request); // If the $gapicClient method call did not throw, fail the test @@ -423,17 +455,14 @@ public function listClientConnectorServicesTest() // Mock response $nextPageToken = ''; $clientConnectorServicesElement = new ClientConnectorService(); - $clientConnectorServices = [ - $clientConnectorServicesElement, - ]; + $clientConnectorServices = [$clientConnectorServicesElement]; $expectedResponse = new ListClientConnectorServicesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setClientConnectorServices($clientConnectorServices); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListClientConnectorServicesRequest()) - ->setParent($formattedParent); + $request = (new ListClientConnectorServicesRequest())->setParent($formattedParent); $response = $gapicClient->listClientConnectorServices($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -443,7 +472,10 @@ public function listClientConnectorServicesTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -460,17 +492,19 @@ public function listClientConnectorServicesExceptionTest() $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 ListClientConnectorServicesRequest()) - ->setParent($formattedParent); + $request = (new ListClientConnectorServicesRequest())->setParent($formattedParent); try { $gapicClient->listClientConnectorServices($request); // If the $gapicClient method call did not throw, fail the test @@ -538,7 +572,10 @@ public function updateClientConnectorServiceTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getUpdateMask(); $this->assertProtobufEquals($updateMask, $actualValue); $actualValue = $actualApiRequestObject->getClientConnectorService(); @@ -586,12 +623,15 @@ public function updateClientConnectorServiceExceptionTest() $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 $updateMask = new FieldMask(); @@ -666,12 +706,15 @@ public function getLocationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -698,9 +741,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -730,12 +771,15 @@ public function listLocationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -768,8 +812,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -793,17 +836,19 @@ public function getIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -835,9 +880,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -863,19 +906,20 @@ public function setIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -903,9 +947,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -931,19 +973,20 @@ public function testIamPermissionsExceptionTest() $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 $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -1011,7 +1054,10 @@ public function createClientConnectorServiceAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getClientConnectorService(); diff --git a/BeyondCorpClientConnectorServices/tests/Unit/V1/ClientConnectorServicesServiceClientTest.php b/BeyondCorpClientConnectorServices/tests/Unit/V1/ClientConnectorServicesServiceClientTest.php deleted file mode 100644 index 89ae900550b8..000000000000 --- a/BeyondCorpClientConnectorServices/tests/Unit/V1/ClientConnectorServicesServiceClientTest.php +++ /dev/null @@ -1,905 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ClientConnectorServicesServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ClientConnectorServicesServiceClient($options); - } - - /** @test */ - public function createClientConnectorServiceTest() - { - $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/createClientConnectorServiceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ClientConnectorService(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createClientConnectorServiceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $clientConnectorService = new ClientConnectorService(); - $clientConnectorServiceName = 'clientConnectorServiceName1804966078'; - $clientConnectorService->setName($clientConnectorServiceName); - $clientConnectorServiceIngress = new Ingress(); - $clientConnectorService->setIngress($clientConnectorServiceIngress); - $clientConnectorServiceEgress = new Egress(); - $clientConnectorService->setEgress($clientConnectorServiceEgress); - $response = $gapicClient->createClientConnectorService($formattedParent, $clientConnectorService); - $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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getClientConnectorService(); - $this->assertProtobufEquals($clientConnectorService, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClientConnectorServiceTest'); - $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 createClientConnectorServiceExceptionTest() - { - $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/createClientConnectorServiceTest'); - $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]'); - $clientConnectorService = new ClientConnectorService(); - $clientConnectorServiceName = 'clientConnectorServiceName1804966078'; - $clientConnectorService->setName($clientConnectorServiceName); - $clientConnectorServiceIngress = new Ingress(); - $clientConnectorService->setIngress($clientConnectorServiceIngress); - $clientConnectorServiceEgress = new Egress(); - $clientConnectorService->setEgress($clientConnectorServiceEgress); - $response = $gapicClient->createClientConnectorService($formattedParent, $clientConnectorService); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClientConnectorServiceTest'); - 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 deleteClientConnectorServiceTest() - { - $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/deleteClientConnectorServiceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteClientConnectorServiceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $response = $gapicClient->deleteClientConnectorService($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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteClientConnectorServiceTest'); - $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 deleteClientConnectorServiceExceptionTest() - { - $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/deleteClientConnectorServiceTest'); - $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->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $response = $gapicClient->deleteClientConnectorService($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteClientConnectorServiceTest'); - 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 getClientConnectorServiceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ClientConnectorService(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - $response = $gapicClient->getClientConnectorService($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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getClientConnectorServiceExceptionTest() - { - $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->clientConnectorServiceName('[PROJECT]', '[LOCATION]', '[CLIENT_CONNECTOR_SERVICE]'); - try { - $gapicClient->getClientConnectorService($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 listClientConnectorServicesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $clientConnectorServicesElement = new ClientConnectorService(); - $clientConnectorServices = [ - $clientConnectorServicesElement, - ]; - $expectedResponse = new ListClientConnectorServicesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setClientConnectorServices($clientConnectorServices); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listClientConnectorServices($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getClientConnectorServices()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listClientConnectorServicesExceptionTest() - { - $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->listClientConnectorServices($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 updateClientConnectorServiceTest() - { - $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/updateClientConnectorServiceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new ClientConnectorService(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateClientConnectorServiceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $updateMask = new FieldMask(); - $clientConnectorService = new ClientConnectorService(); - $clientConnectorServiceName = 'clientConnectorServiceName1804966078'; - $clientConnectorService->setName($clientConnectorServiceName); - $clientConnectorServiceIngress = new Ingress(); - $clientConnectorService->setIngress($clientConnectorServiceIngress); - $clientConnectorServiceEgress = new Egress(); - $clientConnectorService->setEgress($clientConnectorServiceEgress); - $response = $gapicClient->updateClientConnectorService($updateMask, $clientConnectorService); - $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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $actualValue = $actualApiRequestObject->getClientConnectorService(); - $this->assertProtobufEquals($clientConnectorService, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateClientConnectorServiceTest'); - $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 updateClientConnectorServiceExceptionTest() - { - $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/updateClientConnectorServiceTest'); - $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 - $updateMask = new FieldMask(); - $clientConnectorService = new ClientConnectorService(); - $clientConnectorServiceName = 'clientConnectorServiceName1804966078'; - $clientConnectorService->setName($clientConnectorServiceName); - $clientConnectorServiceIngress = new Ingress(); - $clientConnectorService->setIngress($clientConnectorServiceIngress); - $clientConnectorServiceEgress = new Egress(); - $clientConnectorService->setEgress($clientConnectorServiceEgress); - $response = $gapicClient->updateClientConnectorService($updateMask, $clientConnectorService); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateClientConnectorServiceTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->getLocation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->listLocations(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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()); - } -} diff --git a/BeyondCorpClientGateways/.OwlBot.yaml b/BeyondCorpClientGateways/.OwlBot.yaml index 2b9cee1bf0bb..32a941eb7565 100644 --- a/BeyondCorpClientGateways/.OwlBot.yaml +++ b/BeyondCorpClientGateways/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/beyondcorp/clientgateways/v1/.*-php/(.*) - dest: /owl-bot-staging/BeyondCorpClientGateways/v1/$1 + - source: /google/cloud/beyondcorp/clientgateways/(v1)/.*-php/(.*) + dest: /owl-bot-staging/BeyondCorpClientGateways/$1/$2 api-name: BeyondCorpClientGateways diff --git a/BeyondCorpClientGateways/owlbot.py b/BeyondCorpClientGateways/owlbot.py index 6c4a77a86902..ee46adc35290 100644 --- a/BeyondCorpClientGateways/owlbot.py +++ b/BeyondCorpClientGateways/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/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php b/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php index 7f416376b318..d0aeb5edcc21 100644 --- a/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php +++ b/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.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 * client_gateway resource. @@ -539,8 +558,10 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/BeyondCorpClientGateways/src/V1/ClientGateway.php b/BeyondCorpClientGateways/src/V1/ClientGateway.php index df06e265be63..720bc7d33494 100644 --- a/BeyondCorpClientGateways/src/V1/ClientGateway.php +++ b/BeyondCorpClientGateways/src/V1/ClientGateway.php @@ -20,31 +20,31 @@ class ClientGateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Output only. [Output only] Create time stamp. * * 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. [Output only] Update time stamp. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $update_time = null; + protected $update_time = null; /** * Output only. The operational state of the gateway. * * Generated from protobuf field .google.cloud.beyondcorp.clientgateways.v1.ClientGateway.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. A unique identifier for the instance generated by the system. * * Generated from protobuf field string id = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $id = ''; + protected $id = ''; /** * Output only. The client connector service name that the client gateway is * associated to. Client Connector Services, named as follows: @@ -52,7 +52,7 @@ class ClientGateway extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string client_connector_service = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $client_connector_service = ''; + protected $client_connector_service = ''; /** * Constructor. diff --git a/BeyondCorpClientGateways/src/V1/ClientGatewayOperationMetadata.php b/BeyondCorpClientGateways/src/V1/ClientGatewayOperationMetadata.php index 8f699358a1d2..eebce8959553 100644 --- a/BeyondCorpClientGateways/src/V1/ClientGatewayOperationMetadata.php +++ b/BeyondCorpClientGateways/src/V1/ClientGatewayOperationMetadata.php @@ -20,31 +20,31 @@ class ClientGatewayOperationMetadata 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 been cancelled successfully @@ -54,13 +54,13 @@ class ClientGatewayOperationMetadata 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/BeyondCorpClientGateways/src/V1/ClientGatewaysServiceClient.php b/BeyondCorpClientGateways/src/V1/ClientGatewaysServiceClient.php deleted file mode 100644 index cd201574c12a..000000000000 --- a/BeyondCorpClientGateways/src/V1/ClientGatewaysServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -_simpleRequest('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways', - $argument, - ['\Google\Cloud\BeyondCorp\ClientGateways\V1\ListClientGatewaysResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets details of a single ClientGateway. - * @param \Google\Cloud\BeyondCorp\ClientGateways\V1\GetClientGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetClientGateway(\Google\Cloud\BeyondCorp\ClientGateways\V1\GetClientGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway', - $argument, - ['\Google\Cloud\BeyondCorp\ClientGateways\V1\ClientGateway', 'decode'], - $metadata, $options); - } - - /** - * Creates a new ClientGateway in a given project and location. - * @param \Google\Cloud\BeyondCorp\ClientGateways\V1\CreateClientGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateClientGateway(\Google\Cloud\BeyondCorp\ClientGateways\V1\CreateClientGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a single ClientGateway. - * @param \Google\Cloud\BeyondCorp\ClientGateways\V1\DeleteClientGatewayRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteClientGateway(\Google\Cloud\BeyondCorp\ClientGateways\V1\DeleteClientGatewayRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - -} diff --git a/BeyondCorpClientGateways/src/V1/CreateClientGatewayRequest.php b/BeyondCorpClientGateways/src/V1/CreateClientGatewayRequest.php index 8640495ebaa2..09b409646d7a 100644 --- a/BeyondCorpClientGateways/src/V1/CreateClientGatewayRequest.php +++ b/BeyondCorpClientGateways/src/V1/CreateClientGatewayRequest.php @@ -20,7 +20,7 @@ class CreateClientGatewayRequest 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. User-settable client gateway resource ID. * * Must start with a letter. @@ -29,13 +29,13 @@ class CreateClientGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string client_gateway_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $client_gateway_id = ''; + protected $client_gateway_id = ''; /** * Required. The resource being created. * * Generated from protobuf field .google.cloud.beyondcorp.clientgateways.v1.ClientGateway client_gateway = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $client_gateway = null; + protected $client_gateway = null; /** * Optional. 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 @@ -51,14 +51,14 @@ class CreateClientGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $parent Required. Value for parent. Please see diff --git a/BeyondCorpClientGateways/src/V1/DeleteClientGatewayRequest.php b/BeyondCorpClientGateways/src/V1/DeleteClientGatewayRequest.php index c04514891435..4ebd3346210c 100644 --- a/BeyondCorpClientGateways/src/V1/DeleteClientGatewayRequest.php +++ b/BeyondCorpClientGateways/src/V1/DeleteClientGatewayRequest.php @@ -20,7 +20,7 @@ class DeleteClientGatewayRequest 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 = ''; /** * Optional. 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 @@ -36,14 +36,14 @@ class DeleteClientGatewayRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $request_id = ''; + protected $request_id = ''; /** * Optional. If set, validates request by executing a dry-run which would not * alter the resource in any way. * * Generated from protobuf field bool validate_only = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $validate_only = false; + protected $validate_only = false; /** * @param string $name Required. Name of the resource diff --git a/BeyondCorpClientGateways/src/V1/Gapic/ClientGatewaysServiceGapicClient.php b/BeyondCorpClientGateways/src/V1/Gapic/ClientGatewaysServiceGapicClient.php deleted file mode 100644 index 347ab7a4fe94..000000000000 --- a/BeyondCorpClientGateways/src/V1/Gapic/ClientGatewaysServiceGapicClient.php +++ /dev/null @@ -1,1077 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $clientGateway = new ClientGateway(); - * $operationResponse = $clientGatewaysServiceClient->createClientGateway($formattedParent, $clientGateway); - * $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 = $clientGatewaysServiceClient->createClientGateway($formattedParent, $clientGateway); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientGatewaysServiceClient->resumeOperation($operationName, 'createClientGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientGatewaysServiceClient->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\BeyondCorp\ClientGateways\V1\Client\ClientGatewaysServiceClient}. - */ -class ClientGatewaysServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'beyondcorp.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 $clientGatewayNameTemplate; - - 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/client_gateways_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../resources/client_gateways_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../resources/client_gateways_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/client_gateways_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getClientGatewayNameTemplate() - { - if (self::$clientGatewayNameTemplate == null) { - self::$clientGatewayNameTemplate = new PathTemplate( - 'projects/{project}/locations/{location}/clientGateways/{client_gateway}' - ); - } - - return self::$clientGatewayNameTemplate; - } - - 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 = [ - 'clientGateway' => self::getClientGatewayNameTemplate(), - 'location' => self::getLocationNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * client_gateway resource. - * - * @param string $project - * @param string $location - * @param string $clientGateway - * - * @return string The formatted client_gateway resource. - */ - public static function clientGatewayName( - $project, - $location, - $clientGateway - ) { - return self::getClientGatewayNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'client_gateway' => $clientGateway, - ]); - } - - /** - * 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 - * - clientGateway: projects/{project}/locations/{location}/clientGateways/{client_gateway} - * - 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 'beyondcorp.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 ClientGateway in a given project and location. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $formattedParent = $clientGatewaysServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $clientGateway = new ClientGateway(); - * $operationResponse = $clientGatewaysServiceClient->createClientGateway($formattedParent, $clientGateway); - * $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 = $clientGatewaysServiceClient->createClientGateway($formattedParent, $clientGateway); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientGatewaysServiceClient->resumeOperation($operationName, 'createClientGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Value for parent. - * @param ClientGateway $clientGateway Required. The resource being created. - * @param array $optionalArgs { - * Optional. - * - * @type string $clientGatewayId - * Optional. User-settable client gateway resource ID. - * * Must start with a letter. - * * Must contain between 4-63 characters from `/[a-z][0-9]-/`. - * * Must end with a number or a letter. - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 createClientGateway( - $parent, - $clientGateway, - array $optionalArgs = [] - ) { - $request = new CreateClientGatewayRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setClientGateway($clientGateway); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['clientGatewayId'])) { - $request->setClientGatewayId($optionalArgs['clientGatewayId']); - } - - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'CreateClientGateway', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Deletes a single ClientGateway. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $formattedName = $clientGatewaysServiceClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - * $operationResponse = $clientGatewaysServiceClient->deleteClientGateway($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 = $clientGatewaysServiceClient->deleteClientGateway($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $clientGatewaysServiceClient->resumeOperation($operationName, 'deleteClientGateway'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the resource - * @param array $optionalArgs { - * Optional. - * - * @type string $requestId - * Optional. 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 bool $validateOnly - * Optional. If set, validates request by executing a dry-run which would not - * alter the resource in any way. - * @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 deleteClientGateway($name, array $optionalArgs = []) - { - $request = new DeleteClientGatewayRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['requestId'])) { - $request->setRequestId($optionalArgs['requestId']); - } - - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startOperationsCall( - 'DeleteClientGateway', - $optionalArgs, - $request, - $this->getOperationsClient() - )->wait(); - } - - /** - * Gets details of a single ClientGateway. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $formattedName = $clientGatewaysServiceClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - * $response = $clientGatewaysServiceClient->getClientGateway($formattedName); - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the resource - * @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\BeyondCorp\ClientGateways\V1\ClientGateway - * - * @throws ApiException if the remote call fails - */ - public function getClientGateway($name, array $optionalArgs = []) - { - $request = new GetClientGatewayRequest(); - $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( - 'GetClientGateway', - ClientGateway::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Lists ClientGateways in a given project and location. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $formattedParent = $clientGatewaysServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $clientGatewaysServiceClient->listClientGateways($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $clientGatewaysServiceClient->listClientGateways($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. Parent value for ListClientGatewaysRequest. - * @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. Filtering results. - * @type string $orderBy - * Optional. Hint for how to order the results. - * @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 listClientGateways($parent, array $optionalArgs = []) - { - $request = new ListClientGatewaysRequest(); - $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( - 'ListClientGateways', - $optionalArgs, - ListClientGatewaysResponse::class, - $request - ); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $response = $clientGatewaysServiceClient->getLocation(); - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * Resource name for the location. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Location\Location - * - * @throws ApiException if the remote call fails - */ - public function getLocation(array $optionalArgs = []) - { - $request = new GetLocationRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetLocation', - Location::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.cloud.location.Locations' - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $clientGatewaysServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $clientGatewaysServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $name - * The resource that owns the locations collection, if applicable. - * @type string $filter - * The standard list filter. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listLocations(array $optionalArgs = []) - { - $request = new ListLocationsRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['name'])) { - $request->setName($optionalArgs['name']); - $requestParamHeaders['name'] = $optionalArgs['name']; - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->getPagedListResponse( - 'ListLocations', - $optionalArgs, - ListLocationsResponse::class, - $request, - 'google.cloud.location.Locations' - ); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $response = $clientGatewaysServiceClient->getIamPolicy($resource); - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $policy = new Policy(); - * $response = $clientGatewaysServiceClient->setIamPolicy($resource, $policy); - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - 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->startCall( - 'SetIamPolicy', - Policy::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * Sample code: - * ``` - * $clientGatewaysServiceClient = new ClientGatewaysServiceClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $clientGatewaysServiceClient->testIamPermissions($resource, $permissions); - * } finally { - * $clientGatewaysServiceClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions( - $resource, - $permissions, - array $optionalArgs = [] - ) { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'TestIamPermissions', - TestIamPermissionsResponse::class, - $optionalArgs, - $request, - Call::UNARY_CALL, - 'google.iam.v1.IAMPolicy' - )->wait(); - } -} diff --git a/BeyondCorpClientGateways/src/V1/GetClientGatewayRequest.php b/BeyondCorpClientGateways/src/V1/GetClientGatewayRequest.php index 3c30cfa9ba60..34aa28bf8694 100644 --- a/BeyondCorpClientGateways/src/V1/GetClientGatewayRequest.php +++ b/BeyondCorpClientGateways/src/V1/GetClientGatewayRequest.php @@ -20,7 +20,7 @@ class GetClientGatewayRequest 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. Name of the resource diff --git a/BeyondCorpClientGateways/src/V1/ListClientGatewaysRequest.php b/BeyondCorpClientGateways/src/V1/ListClientGatewaysRequest.php index 4ebfc6b5de23..4c7efdb4e0d1 100644 --- a/BeyondCorpClientGateways/src/V1/ListClientGatewaysRequest.php +++ b/BeyondCorpClientGateways/src/V1/ListClientGatewaysRequest.php @@ -20,32 +20,32 @@ class ListClientGatewaysRequest 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. Requested page size. Server may return fewer items than * requested. If unspecified, server will pick an appropriate default. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. A token identifying a page of results the server should return. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. Filtering results. * * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $filter = ''; + protected $filter = ''; /** * Optional. Hint for how to order the results. * * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $order_by = ''; + protected $order_by = ''; /** * @param string $parent Required. Parent value for ListClientGatewaysRequest. Please see diff --git a/BeyondCorpClientGateways/src/V1/ListClientGatewaysResponse.php b/BeyondCorpClientGateways/src/V1/ListClientGatewaysResponse.php index 5156f8e4862a..41559467cdc4 100644 --- a/BeyondCorpClientGateways/src/V1/ListClientGatewaysResponse.php +++ b/BeyondCorpClientGateways/src/V1/ListClientGatewaysResponse.php @@ -26,7 +26,7 @@ class ListClientGatewaysResponse 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/BeyondCorpClientGateways/tests/Unit/V1/Client/ClientGatewaysServiceClientTest.php b/BeyondCorpClientGateways/tests/Unit/V1/Client/ClientGatewaysServiceClientTest.php index f4477b2e932c..006b33e83390 100644 --- a/BeyondCorpClientGateways/tests/Unit/V1/Client/ClientGatewaysServiceClientTest.php +++ b/BeyondCorpClientGateways/tests/Unit/V1/Client/ClientGatewaysServiceClientTest.php @@ -1,6 +1,6 @@ getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ClientGatewaysServiceClient */ @@ -118,9 +120,7 @@ public function createClientGatewayTest() $clientGateway = new ClientGateway(); $clientGatewayName = 'clientGatewayName-1795593692'; $clientGateway->setName($clientGatewayName); - $request = (new CreateClientGatewayRequest()) - ->setParent($formattedParent) - ->setClientGateway($clientGateway); + $request = (new CreateClientGatewayRequest())->setParent($formattedParent)->setClientGateway($clientGateway); $response = $gapicClient->createClientGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -130,7 +130,10 @@ public function createClientGatewayTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getClientGateway(); @@ -178,21 +181,22 @@ public function createClientGatewayExceptionTest() $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]'); $clientGateway = new ClientGateway(); $clientGatewayName = 'clientGatewayName-1795593692'; $clientGateway->setName($clientGatewayName); - $request = (new CreateClientGatewayRequest()) - ->setParent($formattedParent) - ->setClientGateway($clientGateway); + $request = (new CreateClientGatewayRequest())->setParent($formattedParent)->setClientGateway($clientGateway); $response = $gapicClient->createClientGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -246,8 +250,7 @@ public function deleteClientGatewayTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $request = (new DeleteClientGatewayRequest()) - ->setName($formattedName); + $request = (new DeleteClientGatewayRequest())->setName($formattedName); $response = $gapicClient->deleteClientGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -257,7 +260,10 @@ public function deleteClientGatewayTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -303,17 +309,19 @@ public function deleteClientGatewayExceptionTest() $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->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $request = (new DeleteClientGatewayRequest()) - ->setName($formattedName); + $request = (new DeleteClientGatewayRequest())->setName($formattedName); $response = $gapicClient->deleteClientGateway($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -355,15 +363,17 @@ public function getClientGatewayTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $request = (new GetClientGatewayRequest()) - ->setName($formattedName); + $request = (new GetClientGatewayRequest())->setName($formattedName); $response = $gapicClient->getClientGateway($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -380,17 +390,19 @@ public function getClientGatewayExceptionTest() $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->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $request = (new GetClientGatewayRequest()) - ->setName($formattedName); + $request = (new GetClientGatewayRequest())->setName($formattedName); try { $gapicClient->getClientGateway($request); // If the $gapicClient method call did not throw, fail the test @@ -415,17 +427,14 @@ public function listClientGatewaysTest() // Mock response $nextPageToken = ''; $clientGatewaysElement = new ClientGateway(); - $clientGateways = [ - $clientGatewaysElement, - ]; + $clientGateways = [$clientGatewaysElement]; $expectedResponse = new ListClientGatewaysResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setClientGateways($clientGateways); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $request = (new ListClientGatewaysRequest()) - ->setParent($formattedParent); + $request = (new ListClientGatewaysRequest())->setParent($formattedParent); $response = $gapicClient->listClientGateways($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); @@ -435,7 +444,10 @@ public function listClientGatewaysTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways', $actualFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -452,17 +464,19 @@ public function listClientGatewaysExceptionTest() $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 ListClientGatewaysRequest()) - ->setParent($formattedParent); + $request = (new ListClientGatewaysRequest())->setParent($formattedParent); try { $gapicClient->listClientGateways($request); // If the $gapicClient method call did not throw, fail the test @@ -515,12 +529,15 @@ public function getLocationExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new GetLocationRequest(); try { @@ -547,9 +564,7 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); @@ -579,12 +594,15 @@ public function listLocationsExceptionTest() $status = new stdClass(); $status->code = Code::DATA_LOSS; $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); $request = new ListLocationsRequest(); try { @@ -617,8 +635,7 @@ public function getIamPolicyTest() $transport->addResponse($expectedResponse); // Mock request $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); $response = $gapicClient->getIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -642,17 +659,19 @@ public function getIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; - $request = (new GetIamPolicyRequest()) - ->setResource($resource); + $request = (new GetIamPolicyRequest())->setResource($resource); try { $gapicClient->getIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -684,9 +703,7 @@ public function setIamPolicyTest() // Mock request $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); $response = $gapicClient->setIamPolicy($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -712,19 +729,20 @@ public function setIamPolicyExceptionTest() $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 $resource = 'resource-341064690'; $policy = new Policy(); - $request = (new SetIamPolicyRequest()) - ->setResource($resource) - ->setPolicy($policy); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); try { $gapicClient->setIamPolicy($request); // If the $gapicClient method call did not throw, fail the test @@ -752,9 +770,7 @@ public function testIamPermissionsTest() // Mock request $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); $response = $gapicClient->testIamPermissions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -780,19 +796,20 @@ public function testIamPermissionsExceptionTest() $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 $resource = 'resource-341064690'; $permissions = []; - $request = (new TestIamPermissionsRequest()) - ->setResource($resource) - ->setPermissions($permissions); + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); try { $gapicClient->testIamPermissions($request); // If the $gapicClient method call did not throw, fail the test @@ -846,9 +863,7 @@ public function createClientGatewayAsyncTest() $clientGateway = new ClientGateway(); $clientGatewayName = 'clientGatewayName-1795593692'; $clientGateway->setName($clientGatewayName); - $request = (new CreateClientGatewayRequest()) - ->setParent($formattedParent) - ->setClientGateway($clientGateway); + $request = (new CreateClientGatewayRequest())->setParent($formattedParent)->setClientGateway($clientGateway); $response = $gapicClient->createClientGatewayAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); @@ -858,7 +873,10 @@ public function createClientGatewayAsyncTest() $this->assertSame(0, count($operationsRequestsEmpty)); $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', $actualApiFuncCall); + $this->assertSame( + '/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', + $actualApiFuncCall + ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualApiRequestObject->getClientGateway(); diff --git a/BeyondCorpClientGateways/tests/Unit/V1/ClientGatewaysServiceClientTest.php b/BeyondCorpClientGateways/tests/Unit/V1/ClientGatewaysServiceClientTest.php deleted file mode 100644 index 6d44a314c962..000000000000 --- a/BeyondCorpClientGateways/tests/Unit/V1/ClientGatewaysServiceClientTest.php +++ /dev/null @@ -1,761 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ClientGatewaysServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ClientGatewaysServiceClient($options); - } - - /** @test */ - public function createClientGatewayTest() - { - $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/createClientGatewayTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $id = 'id3355'; - $clientConnectorService = 'clientConnectorService-1152817841'; - $expectedResponse = new ClientGateway(); - $expectedResponse->setName($name); - $expectedResponse->setId($id); - $expectedResponse->setClientConnectorService($clientConnectorService); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createClientGatewayTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $clientGateway = new ClientGateway(); - $clientGatewayName = 'clientGatewayName-1795593692'; - $clientGateway->setName($clientGatewayName); - $response = $gapicClient->createClientGateway($formattedParent, $clientGateway); - $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.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getClientGateway(); - $this->assertProtobufEquals($clientGateway, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClientGatewayTest'); - $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 createClientGatewayExceptionTest() - { - $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/createClientGatewayTest'); - $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]'); - $clientGateway = new ClientGateway(); - $clientGatewayName = 'clientGatewayName-1795593692'; - $clientGateway->setName($clientGatewayName); - $response = $gapicClient->createClientGateway($formattedParent, $clientGateway); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClientGatewayTest'); - 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 deleteClientGatewayTest() - { - $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/deleteClientGatewayTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $expectedResponse = new GPBEmpty(); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/deleteClientGatewayTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $response = $gapicClient->deleteClientGateway($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.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteClientGatewayTest'); - $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 deleteClientGatewayExceptionTest() - { - $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/deleteClientGatewayTest'); - $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->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $response = $gapicClient->deleteClientGateway($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/deleteClientGatewayTest'); - 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 getClientGatewayTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $id = 'id3355'; - $clientConnectorService = 'clientConnectorService-1152817841'; - $expectedResponse = new ClientGateway(); - $expectedResponse->setName($name2); - $expectedResponse->setId($id); - $expectedResponse->setClientConnectorService($clientConnectorService); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - $response = $gapicClient->getClientGateway($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.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getClientGatewayExceptionTest() - { - $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->clientGatewayName('[PROJECT]', '[LOCATION]', '[CLIENT_GATEWAY]'); - try { - $gapicClient->getClientGateway($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 listClientGatewaysTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $clientGatewaysElement = new ClientGateway(); - $clientGateways = [ - $clientGatewaysElement, - ]; - $expectedResponse = new ListClientGatewaysResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setClientGateways($clientGateways); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listClientGateways($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getClientGateways()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listClientGatewaysExceptionTest() - { - $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->listClientGateways($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 getLocationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $locationId = 'locationId552319461'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Location(); - $expectedResponse->setName($name2); - $expectedResponse->setLocationId($locationId); - $expectedResponse->setDisplayName($displayName); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getLocationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->getLocation(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; - $expectedResponse = new ListLocationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setLocations($locations); - $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listLocationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->listLocations(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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()); - } -}