From 59737b8998e712f9048566472bdfeb40c1a1b24b Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 17 Dec 2024 21:37:45 +0000 Subject: [PATCH] chore!: promote GkeConnectGateway to v2 --- .repo-metadata-full.json | 4 +- GkeConnectGateway/.OwlBot.yaml | 2 +- GkeConnectGateway/README.md | 5 +- .../metadata/V1Beta1/Gateway.php | 36 -- GkeConnectGateway/owlbot.py | 43 +- .../src/V1/Client/GatewayControlClient.php | 18 +- .../src/V1/GenerateCredentialsRequest.php | 10 +- .../OperatingSystem.php | 2 - .../src/V1/GenerateCredentialsResponse.php | 4 +- .../V1beta1/Client/GatewayControlClient.php | 18 +- .../V1beta1/Client/GatewayServiceClient.php | 317 ------------ .../OperatingSystem.php | 38 -- .../Gapic/GatewayControlGapicClient.php | 271 ---------- .../Gapic/GatewayServiceGapicClient.php | 466 ------------------ .../src/V1beta1/GatewayControlClient.php | 36 -- .../src/V1beta1/GatewayServiceClient.php | 36 -- .../src/V1beta1/GatewayServiceGrpcClient.php | 114 ----- .../V1beta1/GenerateCredentialsRequest.php | 10 +- .../OperatingSystem.php | 2 - .../V1beta1/GenerateCredentialsResponse.php | 4 +- .../gateway_service_client_config.json | 47 -- .../gateway_service_descriptor_config.php | 48 -- .../gateway_service_rest_client_config.php | 48 -- .../V1/Client/GatewayControlClientTest.php | 28 +- .../Client/GatewayControlClientTest.php | 38 +- .../Client/GatewayServiceClientTest.php | 377 -------------- .../Unit/V1beta1/GatewayControlClientTest.php | 123 ----- .../Unit/V1beta1/GatewayServiceClientTest.php | 341 ------------- 28 files changed, 79 insertions(+), 2407 deletions(-) delete mode 100644 GkeConnectGateway/metadata/V1Beta1/Gateway.php delete mode 100644 GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/Enums/GenerateCredentialsRequest/OperatingSystem.php delete mode 100644 GkeConnectGateway/src/V1beta1/Gapic/GatewayControlGapicClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/Gapic/GatewayServiceGapicClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/GatewayControlClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/GatewayServiceClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/GatewayServiceGrpcClient.php delete mode 100644 GkeConnectGateway/src/V1beta1/resources/gateway_service_client_config.json delete mode 100644 GkeConnectGateway/src/V1beta1/resources/gateway_service_descriptor_config.php delete mode 100644 GkeConnectGateway/src/V1beta1/resources/gateway_service_rest_client_config.php delete mode 100644 GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayServiceClientTest.php delete mode 100644 GkeConnectGateway/tests/Unit/V1beta1/GatewayControlClientTest.php delete mode 100644 GkeConnectGateway/tests/Unit/V1beta1/GatewayServiceClientTest.php diff --git a/.repo-metadata-full.json b/.repo-metadata-full.json index 47293b0e4b2a..a741032afb44 100644 --- a/.repo-metadata-full.json +++ b/.repo-metadata-full.json @@ -743,7 +743,7 @@ "GkeConnectGateway": { "language": "php", "distribution_name": "google/cloud-gke-connect-gateway", - "release_level": "preview", + "release_level": "stable", "client_documentation": "https://cloud.google.com/php/docs/reference/cloud-gke-connect-gateway/latest", "library_type": "GAPIC_AUTO", "api_shortname": "connectgateway" @@ -1599,4 +1599,4 @@ "library_type": "GAPIC_AUTO", "api_shortname": "workflows" } -} +} \ No newline at end of file diff --git a/GkeConnectGateway/.OwlBot.yaml b/GkeConnectGateway/.OwlBot.yaml index 380f806efaf5..8c6f1bc7ba59 100644 --- a/GkeConnectGateway/.OwlBot.yaml +++ b/GkeConnectGateway/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/cloud/gkeconnect/gateway/(v1beta1|v1)/.*-php/(.*) + - source: /google/cloud/gkeconnect/gateway/(v1|v1beta1)/.*-php/(.*) dest: /owl-bot-staging/GkeConnectGateway/$1/$2 api-name: GkeConnectGateway diff --git a/GkeConnectGateway/README.md b/GkeConnectGateway/README.md index dd6a1af70180..59980fb75504 100644 --- a/GkeConnectGateway/README.md +++ b/GkeConnectGateway/README.md @@ -35,9 +35,8 @@ for more information about the debugging tools. ### Version -This component is considered beta. As such, it should be expected to be mostly -stable and we're working towards a release candidate. We will address issues -and requests with a higher priority. +This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in +any minor or patch releases. We will address issues and requests with the highest priority. ### Next Steps diff --git a/GkeConnectGateway/metadata/V1Beta1/Gateway.php b/GkeConnectGateway/metadata/V1Beta1/Gateway.php deleted file mode 100644 index f38c7f0914f6..000000000000 --- a/GkeConnectGateway/metadata/V1Beta1/Gateway.php +++ /dev/null @@ -1,36 +0,0 @@ -internalAddGeneratedFile( - ' -� -5google/cloud/gkeconnect/gateway/v1beta1/gateway.proto\'google.cloud.gkeconnect.gateway.v1beta1google/api/client.protogoogle/api/httpbody.proto2� -GatewayServiceN - GetResource.google.api.HttpBody.google.api.HttpBody"���  /v1beta1/**O - PostResource.google.api.HttpBody.google.api.HttpBody"��� " /v1beta1/**Q -DeleteResource.google.api.HttpBody.google.api.HttpBody"��� * /v1beta1/**N - PutResource.google.api.HttpBody.google.api.HttpBody"���  /v1beta1/**P - PatchResource.google.api.HttpBody.google.api.HttpBody"��� 2 /v1beta1/**Q�Aconnectgateway.googleapis.com�A.https://www.googleapis.com/auth/cloud-platformB� -+com.google.cloud.gkeconnect.gateway.v1beta1B GatewayProtoPZEcloud.google.com/go/gkeconnect/gateway/apiv1beta1/gatewaypb;gatewaypb�\'Google.Cloud.GkeConnect.Gateway.V1Beta1�\'Google\\Cloud\\GkeConnect\\Gateway\\V1beta1�+Google::Cloud::GkeConnect::Gateway::V1beta1bproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/GkeConnectGateway/owlbot.py b/GkeConnectGateway/owlbot.py index f7b96f481151..c0864e4a206f 100644 --- a/GkeConnectGateway/owlbot.py +++ b/GkeConnectGateway/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2021 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,37 +32,14 @@ php.owlbot_main(src=src, dest=dest) -# Change the wording for the deprecation warning. +# remove class_alias code s.replace( - 'src/*/*_*.php', - r'will be removed in the next major release', - 'will be removed in a future release') - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) + "src/V*/**/*.php", + r"^// Adding a class alias for backwards compatibility with the previous class name.$" + + "\n" + + r"^class_alias\(.*\);$" + + "\n", + '') # format generated clients subprocess.run([ @@ -72,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/GkeConnectGateway/src/V1/Client/GatewayControlClient.php b/GkeConnectGateway/src/V1/Client/GatewayControlClient.php index 6ac0651528f7..eff0fb72a04f 100644 --- a/GkeConnectGateway/src/V1/Client/GatewayControlClient.php +++ b/GkeConnectGateway/src/V1/Client/GatewayControlClient.php @@ -34,7 +34,6 @@ use Google\Cloud\GkeConnect\Gateway\V1\GenerateCredentialsRequest; use Google\Cloud\GkeConnect\Gateway\V1\GenerateCredentialsResponse; use GuzzleHttp\Promise\PromiseInterface; -use Psr\Log\LoggerInterface; /** * Service Description: GatewayControl is the control plane API for Connect Gateway. @@ -68,9 +67,7 @@ final class GatewayControlClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; private static function getClientDefaults() { @@ -100,9 +97,7 @@ private static function defaultTransport() /** Implements ClientOptionsTrait::supportedTransports. */ private static function supportedTransports() { - return [ - 'rest', - ]; + return ['rest']; } /** @@ -152,9 +147,6 @@ private static function supportedTransports() * @type callable $clientCertSource * A callable which returns the client cert as a string. This can be used to * provide a certificate and private key to the transport layer for mTLS. - * @type false|LoggerInterface $logger - * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the - * 'GOOGLE_SDK_PHP_LOGGING' environment flag * } * * @throws ValidationException @@ -198,8 +190,10 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function generateCredentials(GenerateCredentialsRequest $request, array $callOptions = []): GenerateCredentialsResponse - { + public function generateCredentials( + GenerateCredentialsRequest $request, + array $callOptions = [] + ): GenerateCredentialsResponse { return $this->startApiCall('GenerateCredentials', $request, $callOptions)->wait(); } } diff --git a/GkeConnectGateway/src/V1/GenerateCredentialsRequest.php b/GkeConnectGateway/src/V1/GenerateCredentialsRequest.php index 8bcb057460f5..ff63067fdfdb 100644 --- a/GkeConnectGateway/src/V1/GenerateCredentialsRequest.php +++ b/GkeConnectGateway/src/V1/GenerateCredentialsRequest.php @@ -20,7 +20,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Optional. Whether to force the use of Connect Agent-based transport. * This will return a configuration that uses Connect Agent as the underlying @@ -30,7 +30,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force_use_agent = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $force_use_agent = false; + protected $force_use_agent = false; /** * Optional. The Connect Gateway version to be used in the resulting * configuration. @@ -38,7 +38,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string version = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $version = ''; + protected $version = ''; /** * Optional. The namespace to use in the kubeconfig context. * If this field is specified, the server will set the `namespace` field in @@ -46,13 +46,13 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kubernetes_namespace = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $kubernetes_namespace = ''; + protected $kubernetes_namespace = ''; /** * Optional. The operating system where the kubeconfig will be used. * * Generated from protobuf field .google.cloud.gkeconnect.gateway.v1.GenerateCredentialsRequest.OperatingSystem operating_system = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $operating_system = 0; + protected $operating_system = 0; /** * Constructor. diff --git a/GkeConnectGateway/src/V1/GenerateCredentialsRequest/OperatingSystem.php b/GkeConnectGateway/src/V1/GenerateCredentialsRequest/OperatingSystem.php index 3cd4fd313777..b3e7ea432dc4 100644 --- a/GkeConnectGateway/src/V1/GenerateCredentialsRequest/OperatingSystem.php +++ b/GkeConnectGateway/src/V1/GenerateCredentialsRequest/OperatingSystem.php @@ -54,6 +54,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(OperatingSystem::class, \Google\Cloud\GkeConnect\Gateway\V1\GenerateCredentialsRequest_OperatingSystem::class); diff --git a/GkeConnectGateway/src/V1/GenerateCredentialsResponse.php b/GkeConnectGateway/src/V1/GenerateCredentialsResponse.php index 57b11e7fb096..b828cc93beae 100644 --- a/GkeConnectGateway/src/V1/GenerateCredentialsResponse.php +++ b/GkeConnectGateway/src/V1/GenerateCredentialsResponse.php @@ -20,14 +20,14 @@ class GenerateCredentialsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes kubeconfig = 1; */ - private $kubeconfig = ''; + protected $kubeconfig = ''; /** * The generated URI of the cluster as accessed through the Connect Gateway * API. * * Generated from protobuf field string endpoint = 2; */ - private $endpoint = ''; + protected $endpoint = ''; /** * Constructor. diff --git a/GkeConnectGateway/src/V1beta1/Client/GatewayControlClient.php b/GkeConnectGateway/src/V1beta1/Client/GatewayControlClient.php index 6234da984ceb..7abdb1294fc6 100644 --- a/GkeConnectGateway/src/V1beta1/Client/GatewayControlClient.php +++ b/GkeConnectGateway/src/V1beta1/Client/GatewayControlClient.php @@ -36,7 +36,6 @@ use Google\Cloud\GkeConnect\Gateway\V1beta1\GenerateCredentialsRequest; use Google\Cloud\GkeConnect\Gateway\V1beta1\GenerateCredentialsResponse; use GuzzleHttp\Promise\PromiseInterface; -use Psr\Log\LoggerInterface; /** * Service Description: GatewayControl is the control plane API for Connect Gateway. @@ -72,9 +71,7 @@ final class GatewayControlClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; + public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; private static function getClientDefaults() { @@ -104,9 +101,7 @@ private static function defaultTransport() /** Implements ClientOptionsTrait::supportedTransports. */ private static function supportedTransports() { - return [ - 'rest', - ]; + return ['rest']; } /** @@ -156,9 +151,6 @@ private static function supportedTransports() * @type callable $clientCertSource * A callable which returns the client cert as a string. This can be used to * provide a certificate and private key to the transport layer for mTLS. - * @type false|LoggerInterface $logger - * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the - * 'GOOGLE_SDK_PHP_LOGGING' environment flag * } * * @throws ValidationException @@ -206,8 +198,10 @@ public function __call($method, $args) * * @experimental */ - public function generateCredentials(GenerateCredentialsRequest $request, array $callOptions = []): GenerateCredentialsResponse - { + public function generateCredentials( + GenerateCredentialsRequest $request, + array $callOptions = [] + ): GenerateCredentialsResponse { return $this->startApiCall('GenerateCredentials', $request, $callOptions)->wait(); } } diff --git a/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php b/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php deleted file mode 100644 index 09102373eeaf..000000000000 --- a/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php +++ /dev/null @@ -1,317 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/gateway_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/gateway_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/gateway_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/gateway_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'connectgateway.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * DeleteResource performs an HTTP DELETE on the Kubernetes API Server. - * - * The async variant is {@see GatewayServiceClient::deleteResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/delete_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('DeleteResource', $request, $callOptions)->wait(); - } - - /** - * GetResource performs an HTTP GET request on the Kubernetes API Server. - * - * The async variant is {@see GatewayServiceClient::getResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/get_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('GetResource', $request, $callOptions)->wait(); - } - - /** - * PatchResource performs an HTTP PATCH on the Kubernetes API Server. - * - * The async variant is {@see GatewayServiceClient::patchResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/patch_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function patchResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PatchResource', $request, $callOptions)->wait(); - } - - /** - * PostResource performs an HTTP POST on the Kubernetes API Server. - * - * The async variant is {@see GatewayServiceClient::postResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/post_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function postResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PostResource', $request, $callOptions)->wait(); - } - - /** - * PutResource performs an HTTP PUT on the Kubernetes API Server. - * - * The async variant is {@see GatewayServiceClient::putResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/put_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function putResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PutResource', $request, $callOptions)->wait(); - } -} diff --git a/GkeConnectGateway/src/V1beta1/Enums/GenerateCredentialsRequest/OperatingSystem.php b/GkeConnectGateway/src/V1beta1/Enums/GenerateCredentialsRequest/OperatingSystem.php deleted file mode 100644 index f4c035aa6a07..000000000000 --- a/GkeConnectGateway/src/V1beta1/Enums/GenerateCredentialsRequest/OperatingSystem.php +++ /dev/null @@ -1,38 +0,0 @@ -generateCredentials($name); - * } finally { - * $gatewayControlClient->close(); - * } - * ``` - * - * @experimental - * - * @deprecated Please use the new service client {@see \Google\Cloud\GkeConnect\Gateway\V1beta1\Client\GatewayControlClient}. - */ -class GatewayControlGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.gkeconnect.gateway.v1beta1.GatewayControl'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'connectgateway.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'connectgateway.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 function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../resources/gateway_control_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../resources/gateway_control_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/gateway_control_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::supportedTransports. */ - private static function supportedTransports() - { - return ['rest']; - } - - /** - * 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 'connectgateway.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * GenerateCredentials provides connection information that allows a user to - * access the specified membership using Connect Gateway. - * - * Sample code: - * ``` - * $gatewayControlClient = new GatewayControlClient(); - * try { - * $name = 'name'; - * $response = $gatewayControlClient->generateCredentials($name); - * } finally { - * $gatewayControlClient->close(); - * } - * ``` - * - * @param string $name Required. The Fleet membership resource. - * @param array $optionalArgs { - * Optional. - * - * @type bool $forceUseAgent - * Optional. Whether to force the use of Connect Agent-based transport. - * - * This will return a configuration that uses Connect Agent as the underlying - * transport mechanism for cluster types that would otherwise have used a - * different transport. Requires that Connect Agent be installed on the - * cluster. Setting this field to false is equivalent to not setting it. - * @type string $version - * Optional. The Connect Gateway version to be used in the resulting - * configuration. - * - * Leave this field blank to let the server choose the version (recommended). - * @type string $kubernetesNamespace - * Optional. The namespace to use in the kubeconfig context. - * - * If this field is specified, the server will set the `namespace` field in - * kubeconfig context. If not specified, the `namespace` field is omitted. - * @type int $operatingSystem - * Optional. The operating system where the kubeconfig will be used. - * For allowed values, use constants defined on {@see \Google\Cloud\GkeConnect\Gateway\V1beta1\GenerateCredentialsRequest\OperatingSystem} - * @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\GkeConnect\Gateway\V1beta1\GenerateCredentialsResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function generateCredentials($name, array $optionalArgs = []) - { - $request = new GenerateCredentialsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['forceUseAgent'])) { - $request->setForceUseAgent($optionalArgs['forceUseAgent']); - } - - if (isset($optionalArgs['version'])) { - $request->setVersion($optionalArgs['version']); - } - - if (isset($optionalArgs['kubernetesNamespace'])) { - $request->setKubernetesNamespace( - $optionalArgs['kubernetesNamespace'] - ); - } - - if (isset($optionalArgs['operatingSystem'])) { - $request->setOperatingSystem($optionalArgs['operatingSystem']); - } - - $requestParams = new RequestParamsHeaderDescriptor( - $requestParamHeaders - ); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - return $this->startCall( - 'GenerateCredentials', - GenerateCredentialsResponse::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/GkeConnectGateway/src/V1beta1/Gapic/GatewayServiceGapicClient.php b/GkeConnectGateway/src/V1beta1/Gapic/GatewayServiceGapicClient.php deleted file mode 100644 index 670df03f2a3e..000000000000 --- a/GkeConnectGateway/src/V1beta1/Gapic/GatewayServiceGapicClient.php +++ /dev/null @@ -1,466 +0,0 @@ -deleteResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @experimental - * - * @deprecated Please use the new service client {@see \Google\Cloud\GkeConnect\Gateway\V1beta1\Client\GatewayServiceClient}. - */ -class GatewayServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.gkeconnect.gateway.v1beta1.GatewayService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'connectgateway.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'connectgateway.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 function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../resources/gateway_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../resources/gateway_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../resources/gateway_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../resources/gateway_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'connectgateway.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * DeleteResource performs an HTTP DELETE on the Kubernetes API Server. - * - * Sample code: - * ``` - * $gatewayServiceClient = new GatewayServiceClient(); - * try { - * $response = $gatewayServiceClient->deleteResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $contentType - * The HTTP Content-Type header value specifying the content type of the body. - * @type string $data - * The HTTP request/response body as raw binary. - * @type Any[] $extensions - * Application specific response metadata. Must be set in the first response - * for streaming APIs. - * @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\Api\HttpBody - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function deleteResource(array $optionalArgs = []) - { - $request = new HttpBody(); - if (isset($optionalArgs['contentType'])) { - $request->setContentType($optionalArgs['contentType']); - } - - if (isset($optionalArgs['data'])) { - $request->setData($optionalArgs['data']); - } - - if (isset($optionalArgs['extensions'])) { - $request->setExtensions($optionalArgs['extensions']); - } - - return $this->startCall( - 'DeleteResource', - HttpBody::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * GetResource performs an HTTP GET request on the Kubernetes API Server. - * - * Sample code: - * ``` - * $gatewayServiceClient = new GatewayServiceClient(); - * try { - * $response = $gatewayServiceClient->getResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $contentType - * The HTTP Content-Type header value specifying the content type of the body. - * @type string $data - * The HTTP request/response body as raw binary. - * @type Any[] $extensions - * Application specific response metadata. Must be set in the first response - * for streaming APIs. - * @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\Api\HttpBody - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function getResource(array $optionalArgs = []) - { - $request = new HttpBody(); - if (isset($optionalArgs['contentType'])) { - $request->setContentType($optionalArgs['contentType']); - } - - if (isset($optionalArgs['data'])) { - $request->setData($optionalArgs['data']); - } - - if (isset($optionalArgs['extensions'])) { - $request->setExtensions($optionalArgs['extensions']); - } - - return $this->startCall( - 'GetResource', - HttpBody::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * PatchResource performs an HTTP PATCH on the Kubernetes API Server. - * - * Sample code: - * ``` - * $gatewayServiceClient = new GatewayServiceClient(); - * try { - * $response = $gatewayServiceClient->patchResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $contentType - * The HTTP Content-Type header value specifying the content type of the body. - * @type string $data - * The HTTP request/response body as raw binary. - * @type Any[] $extensions - * Application specific response metadata. Must be set in the first response - * for streaming APIs. - * @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\Api\HttpBody - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function patchResource(array $optionalArgs = []) - { - $request = new HttpBody(); - if (isset($optionalArgs['contentType'])) { - $request->setContentType($optionalArgs['contentType']); - } - - if (isset($optionalArgs['data'])) { - $request->setData($optionalArgs['data']); - } - - if (isset($optionalArgs['extensions'])) { - $request->setExtensions($optionalArgs['extensions']); - } - - return $this->startCall( - 'PatchResource', - HttpBody::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * PostResource performs an HTTP POST on the Kubernetes API Server. - * - * Sample code: - * ``` - * $gatewayServiceClient = new GatewayServiceClient(); - * try { - * $response = $gatewayServiceClient->postResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $contentType - * The HTTP Content-Type header value specifying the content type of the body. - * @type string $data - * The HTTP request/response body as raw binary. - * @type Any[] $extensions - * Application specific response metadata. Must be set in the first response - * for streaming APIs. - * @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\Api\HttpBody - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function postResource(array $optionalArgs = []) - { - $request = new HttpBody(); - if (isset($optionalArgs['contentType'])) { - $request->setContentType($optionalArgs['contentType']); - } - - if (isset($optionalArgs['data'])) { - $request->setData($optionalArgs['data']); - } - - if (isset($optionalArgs['extensions'])) { - $request->setExtensions($optionalArgs['extensions']); - } - - return $this->startCall( - 'PostResource', - HttpBody::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * PutResource performs an HTTP PUT on the Kubernetes API Server. - * - * Sample code: - * ``` - * $gatewayServiceClient = new GatewayServiceClient(); - * try { - * $response = $gatewayServiceClient->putResource(); - * } finally { - * $gatewayServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $contentType - * The HTTP Content-Type header value specifying the content type of the body. - * @type string $data - * The HTTP request/response body as raw binary. - * @type Any[] $extensions - * Application specific response metadata. Must be set in the first response - * for streaming APIs. - * @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\Api\HttpBody - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function putResource(array $optionalArgs = []) - { - $request = new HttpBody(); - if (isset($optionalArgs['contentType'])) { - $request->setContentType($optionalArgs['contentType']); - } - - if (isset($optionalArgs['data'])) { - $request->setData($optionalArgs['data']); - } - - if (isset($optionalArgs['extensions'])) { - $request->setExtensions($optionalArgs['extensions']); - } - - return $this->startCall( - 'PutResource', - HttpBody::class, - $optionalArgs, - $request - )->wait(); - } -} diff --git a/GkeConnectGateway/src/V1beta1/GatewayControlClient.php b/GkeConnectGateway/src/V1beta1/GatewayControlClient.php deleted file mode 100644 index afb71d1a3ffa..000000000000 --- a/GkeConnectGateway/src/V1beta1/GatewayControlClient.php +++ /dev/null @@ -1,36 +0,0 @@ -_simpleRequest('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/GetResource', - $argument, - ['\Google\Api\HttpBody', 'decode'], - $metadata, $options); - } - - /** - * PostResource performs an HTTP POST on the Kubernetes API Server. - * @param \Google\Api\HttpBody $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PostResource(\Google\Api\HttpBody $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PostResource', - $argument, - ['\Google\Api\HttpBody', 'decode'], - $metadata, $options); - } - - /** - * DeleteResource performs an HTTP DELETE on the Kubernetes API Server. - * @param \Google\Api\HttpBody $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteResource(\Google\Api\HttpBody $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/DeleteResource', - $argument, - ['\Google\Api\HttpBody', 'decode'], - $metadata, $options); - } - - /** - * PutResource performs an HTTP PUT on the Kubernetes API Server. - * @param \Google\Api\HttpBody $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PutResource(\Google\Api\HttpBody $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PutResource', - $argument, - ['\Google\Api\HttpBody', 'decode'], - $metadata, $options); - } - - /** - * PatchResource performs an HTTP PATCH on the Kubernetes API Server. - * @param \Google\Api\HttpBody $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PatchResource(\Google\Api\HttpBody $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PatchResource', - $argument, - ['\Google\Api\HttpBody', 'decode'], - $metadata, $options); - } - -} diff --git a/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest.php b/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest.php index 55927f357f74..9f500f5955a9 100644 --- a/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest.php +++ b/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest.php @@ -20,7 +20,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $name = ''; + protected $name = ''; /** * Optional. Whether to force the use of Connect Agent-based transport. * This will return a configuration that uses Connect Agent as the underlying @@ -30,7 +30,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool force_use_agent = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $force_use_agent = false; + protected $force_use_agent = false; /** * Optional. The Connect Gateway version to be used in the resulting * configuration. @@ -38,7 +38,7 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string version = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $version = ''; + protected $version = ''; /** * Optional. The namespace to use in the kubeconfig context. * If this field is specified, the server will set the `namespace` field in @@ -46,13 +46,13 @@ class GenerateCredentialsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kubernetes_namespace = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $kubernetes_namespace = ''; + protected $kubernetes_namespace = ''; /** * Optional. The operating system where the kubeconfig will be used. * * Generated from protobuf field .google.cloud.gkeconnect.gateway.v1beta1.GenerateCredentialsRequest.OperatingSystem operating_system = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - private $operating_system = 0; + protected $operating_system = 0; /** * Constructor. diff --git a/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest/OperatingSystem.php b/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest/OperatingSystem.php index 4ab5e2b2180c..d40a28a99bdc 100644 --- a/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest/OperatingSystem.php +++ b/GkeConnectGateway/src/V1beta1/GenerateCredentialsRequest/OperatingSystem.php @@ -54,6 +54,4 @@ public static function value($name) } } -// Adding a class alias for backwards compatibility with the previous class name. -class_alias(OperatingSystem::class, \Google\Cloud\GkeConnect\Gateway\V1beta1\GenerateCredentialsRequest_OperatingSystem::class); diff --git a/GkeConnectGateway/src/V1beta1/GenerateCredentialsResponse.php b/GkeConnectGateway/src/V1beta1/GenerateCredentialsResponse.php index 9894166472fd..327f1fe485c9 100644 --- a/GkeConnectGateway/src/V1beta1/GenerateCredentialsResponse.php +++ b/GkeConnectGateway/src/V1beta1/GenerateCredentialsResponse.php @@ -20,14 +20,14 @@ class GenerateCredentialsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes kubeconfig = 1; */ - private $kubeconfig = ''; + protected $kubeconfig = ''; /** * The generated URI of the cluster as accessed through the Connect Gateway * API. * * Generated from protobuf field string endpoint = 2; */ - private $endpoint = ''; + protected $endpoint = ''; /** * Constructor. diff --git a/GkeConnectGateway/src/V1beta1/resources/gateway_service_client_config.json b/GkeConnectGateway/src/V1beta1/resources/gateway_service_client_config.json deleted file mode 100644 index da3759343c4f..000000000000 --- a/GkeConnectGateway/src/V1beta1/resources/gateway_service_client_config.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "interfaces": { - "google.cloud.gkeconnect.gateway.v1beta1.GatewayService": { - "retry_codes": { - "no_retry_codes": [] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - } - }, - "methods": { - "DeleteResource": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "GetResource": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "PatchResource": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "PostResource": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "PutResource": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - } - } - } - } -} diff --git a/GkeConnectGateway/src/V1beta1/resources/gateway_service_descriptor_config.php b/GkeConnectGateway/src/V1beta1/resources/gateway_service_descriptor_config.php deleted file mode 100644 index 22a649faec87..000000000000 --- a/GkeConnectGateway/src/V1beta1/resources/gateway_service_descriptor_config.php +++ /dev/null @@ -1,48 +0,0 @@ - [ - 'google.cloud.gkeconnect.gateway.v1beta1.GatewayService' => [ - 'DeleteResource' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Api\HttpBody', - ], - 'GetResource' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Api\HttpBody', - ], - 'PatchResource' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Api\HttpBody', - ], - 'PostResource' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Api\HttpBody', - ], - 'PutResource' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Api\HttpBody', - ], - ], - ], -]; diff --git a/GkeConnectGateway/src/V1beta1/resources/gateway_service_rest_client_config.php b/GkeConnectGateway/src/V1beta1/resources/gateway_service_rest_client_config.php deleted file mode 100644 index 5794acf31f5d..000000000000 --- a/GkeConnectGateway/src/V1beta1/resources/gateway_service_rest_client_config.php +++ /dev/null @@ -1,48 +0,0 @@ - [ - 'google.cloud.gkeconnect.gateway.v1beta1.GatewayService' => [ - 'DeleteResource' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/**', - ], - 'GetResource' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/**', - ], - 'PatchResource' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/**', - ], - 'PostResource' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/**', - ], - 'PutResource' => [ - 'method' => 'put', - 'uriTemplate' => '/v1beta1/**', - ], - ], - ], -]; diff --git a/GkeConnectGateway/tests/Unit/V1/Client/GatewayControlClientTest.php b/GkeConnectGateway/tests/Unit/V1/Client/GatewayControlClientTest.php index e61a2b6b9720..f8aca96114b0 100644 --- a/GkeConnectGateway/tests/Unit/V1/Client/GatewayControlClientTest.php +++ b/GkeConnectGateway/tests/Unit/V1/Client/GatewayControlClientTest.php @@ -48,7 +48,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return GatewayControlClient */ @@ -77,8 +79,7 @@ public function generateCredentialsTest() $transport->addResponse($expectedResponse); // Mock request $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); $response = $gapicClient->generateCredentials($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -102,17 +103,19 @@ public function generateCredentialsExceptionTest() $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 $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); try { $gapicClient->generateCredentials($request); // If the $gapicClient method call did not throw, fail the test @@ -143,8 +146,7 @@ public function generateCredentialsAsyncTest() $transport->addResponse($expectedResponse); // Mock request $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); $response = $gapicClient->generateCredentialsAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); diff --git a/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayControlClientTest.php b/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayControlClientTest.php index 812cae3d34cb..b5b39336dc23 100644 --- a/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayControlClientTest.php +++ b/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayControlClientTest.php @@ -48,7 +48,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return GatewayControlClient */ @@ -77,15 +79,17 @@ public function generateCredentialsTest() $transport->addResponse($expectedResponse); // Mock request $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); $response = $gapicClient->generateCredentials($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.gkeconnect.gateway.v1beta1.GatewayControl/GenerateCredentials', $actualFuncCall); + $this->assertSame( + '/google.cloud.gkeconnect.gateway.v1beta1.GatewayControl/GenerateCredentials', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -102,17 +106,19 @@ public function generateCredentialsExceptionTest() $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 $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); try { $gapicClient->generateCredentials($request); // If the $gapicClient method call did not throw, fail the test @@ -143,15 +149,17 @@ public function generateCredentialsAsyncTest() $transport->addResponse($expectedResponse); // Mock request $name = 'name3373707'; - $request = (new GenerateCredentialsRequest()) - ->setName($name); + $request = (new GenerateCredentialsRequest())->setName($name); $response = $gapicClient->generateCredentialsAsync($request)->wait(); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayControl/GenerateCredentials', $actualFuncCall); + $this->assertSame( + '/google.cloud.gkeconnect.gateway.v1beta1.GatewayControl/GenerateCredentials', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); diff --git a/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayServiceClientTest.php b/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayServiceClientTest.php deleted file mode 100644 index ae83ba4026ac..000000000000 --- a/GkeConnectGateway/tests/Unit/V1beta1/Client/GatewayServiceClientTest.php +++ /dev/null @@ -1,377 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return GatewayServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new GatewayServiceClient($options); - } - - /** @test */ - public function deleteResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->deleteResource($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.gkeconnect.gateway.v1beta1.GatewayService/DeleteResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteResourceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new HttpBody(); - try { - $gapicClient->deleteResource($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->getResource($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.gkeconnect.gateway.v1beta1.GatewayService/GetResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getResourceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new HttpBody(); - try { - $gapicClient->getResource($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function patchResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->patchResource($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.gkeconnect.gateway.v1beta1.GatewayService/PatchResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function patchResourceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new HttpBody(); - try { - $gapicClient->patchResource($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function postResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->postResource($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.gkeconnect.gateway.v1beta1.GatewayService/PostResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function postResourceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new HttpBody(); - try { - $gapicClient->postResource($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function putResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->putResource($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.gkeconnect.gateway.v1beta1.GatewayService/PutResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function putResourceExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new HttpBody(); - try { - $gapicClient->putResource($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteResourceAsyncTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $request = new HttpBody(); - $response = $gapicClient->deleteResourceAsync($request)->wait(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/DeleteResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/GkeConnectGateway/tests/Unit/V1beta1/GatewayControlClientTest.php b/GkeConnectGateway/tests/Unit/V1beta1/GatewayControlClientTest.php deleted file mode 100644 index 33ddb8083932..000000000000 --- a/GkeConnectGateway/tests/Unit/V1beta1/GatewayControlClientTest.php +++ /dev/null @@ -1,123 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return GatewayControlClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new GatewayControlClient($options); - } - - /** @test */ - public function generateCredentialsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $kubeconfig = '-81'; - $endpoint = 'endpoint1741102485'; - $expectedResponse = new GenerateCredentialsResponse(); - $expectedResponse->setKubeconfig($kubeconfig); - $expectedResponse->setEndpoint($endpoint); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $response = $gapicClient->generateCredentials($name); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayControl/GenerateCredentials', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function generateCredentialsExceptionTest() - { - $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 - $name = 'name3373707'; - try { - $gapicClient->generateCredentials($name); - // 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/GkeConnectGateway/tests/Unit/V1beta1/GatewayServiceClientTest.php b/GkeConnectGateway/tests/Unit/V1beta1/GatewayServiceClientTest.php deleted file mode 100644 index 4966d21134cb..000000000000 --- a/GkeConnectGateway/tests/Unit/V1beta1/GatewayServiceClientTest.php +++ /dev/null @@ -1,341 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return GatewayServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new GatewayServiceClient($options); - } - - /** @test */ - public function deleteResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $response = $gapicClient->deleteResource(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/DeleteResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteResourceExceptionTest() - { - $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->deleteResource(); - // 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 getResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $response = $gapicClient->getResource(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/GetResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getResourceExceptionTest() - { - $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->getResource(); - // 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 patchResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $response = $gapicClient->patchResource(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PatchResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function patchResourceExceptionTest() - { - $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->patchResource(); - // 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 postResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $response = $gapicClient->postResource(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PostResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function postResourceExceptionTest() - { - $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->postResource(); - // 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 putResourceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $contentType2 = 'contentType2540291827'; - $data2 = '-35'; - $expectedResponse = new HttpBody(); - $expectedResponse->setContentType($contentType2); - $expectedResponse->setData($data2); - $transport->addResponse($expectedResponse); - $response = $gapicClient->putResource(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.gkeconnect.gateway.v1beta1.GatewayService/PutResource', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function putResourceExceptionTest() - { - $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->putResource(); - // 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()); - } -}